Skip to content

Conversation

@ThijsVroegh
Copy link

@ThijsVroegh ThijsVroegh commented Apr 23, 2025

This pull request addresses the initial broadcast issue with using DIANNA ( issue #1) by making use of a new custom RISE function. Key changes include a new visualization overlay function, and improved preprocessing and feature comparison logic.

Visualization Enhancements:

  • Introduced visualize_edge_heatmap_overlay in edge_detection/visualizer.py to overlay edge maps and heatmaps for improved interpretability. This function includes configurable parameters for edge detection, transparency, and color mapping. (edge_detection/visualizer.py)

Model Refactoring:

  • Refactored model.py to replace OpenCV-based edge detection with skimage functions, integrate a standardized preprocess_image function, and improve batch processing with progress indicators. (model.py) [1] [2]
  • Updated compare_image_with_dataset to use the refactored edge detection and feature extraction logic, including adjustments to probability calculations and output formatting. (model.py)

Additional Changes:

  • Refactored the code and split code into helker functions in utils, visualization and edge_detection folders to maintain code clarity
  • Detailed README on how to use and interpret XAI results in the context of artist classification

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements multiple enhancements for the XAI system including improved visualization for heatmaps and edges, refactoring model prediction and feature extraction logic, and additional utility functions and tests for robustness.

  • Introduced new visualization functions (heatmap, difference maps, side-by-side displays, and edge-enhanced overlays).
  • Refactored model.py to replace OpenCV edge detection with scikit-image functions and standardized image preprocessing.
  • Added new utility modules for metrics, configuration, and file operations; improved test coverage across the codebase.

Reviewed Changes

Copilot reviewed 52 out of 53 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
visualization/heatmap.py New heatmap and multi-image plotting functions
visualization/init.py Initialization file for visualization functions
utils/metrics.py Metrics calculations and interpretation functions
utils/file_utils.py Directory and file path utility functions
utils/config.py Configuration parameters for the XAI system
tests/* Extensive tests for model functionality and cv utilities
model.py Refactored model integration and feature extraction
edge_detection/* New functions for edge detection and overlay visualization
Files not reviewed (1)
  • results/summary/0_Edinburgh_Nat_Gallery.jpg_nmasks_100_pkeep_0.5_res_8_integrated_metrics.npz: Language not supported

Comment on lines +314 to +318
probabilities[0] -= 0.5

if mean_diff > 400:
mean_diff = 400
probabilities[0] = probabilities[0] - 0.3
probabilities[0] -= 0.5
Copy link

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The adjustment logic subtracts 0.5 from the probability when mean_diff is less than 99, which may result in negative probability values. Please verify and consider adding a guard to prevent probabilities from dropping below 0.

Copilot uses AI. Check for mistakes.
Comment on lines +314 to +318
probabilities[0] -= 0.5

if mean_diff > 400:
mean_diff = 400
probabilities[0] = probabilities[0] - 0.3
probabilities[0] -= 0.5
Copy link

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtracting 0.5 from the predicted probability in multiple conditions might lead to negative outcomes. Ensure that the adjustment algorithm is correctly calibrated and that a lower bound is enforced.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix the code for consistent numpy array usage and passing across the different steps in the DIANNA pipeline

2 participants