Add Optuna-weighted SSIM loss and align validation selection#32
Open
MattsonCam wants to merge 13 commits into
Open
Add Optuna-weighted SSIM loss and align validation selection#32MattsonCam wants to merge 13 commits into
MattsonCam wants to merge 13 commits into
Conversation
added 6 commits
July 15, 2026 12:16
added 7 commits
July 15, 2026 16:05
Run ID:5cbf036ef8284509850ab17794c3271a Run Name:amusing-fly-350 Optimization of a DAPI-to-Gold image-to-image translation model with: **Note**: This run may have included uncentered cached crops once transformed - ConvNeXtUNet Generator - Single 2D crop input and single 2D crop target - Cache-backed filtered nucleus crops generated from the configured data directory - Train-split z-score normalization for inputs and targets - L1 plus Optuna-weighted SSIM optimization objective in z-score space with denormalized L2, PSNR, SSIM, and Pearson correlation metric logging - Resampling of dataset w/o anti-aliasing -> dtype clipping (to stay within the correct range) -> z-score normalization - Means and stds from the training set were stored for z-scoring of the validation set - No final activation function after the model output (such as sigmoid)
Experiment ID:3 Run ID:fcb64e1219794669a6ee40f27e88dea9 Run Name:wistful-kite-582 - ConvNeXtUNet Generator - Single 2D crop input and single 2D crop target - Cache-backed filtered nucleus crops generated from the configured data directory - Train-split z-score normalization for inputs and targets - L1 plus Optuna-weighted SSIM optimization objective in z-score space with denormalized L2, PSNR, SSIM, and Pearson correlation metric logging - Resampling of dataset w/o anti-aliasing -> dtype clipping (to stay within the correct range) -> z-score normalization - Means and stds from the training set were stored for z-scoring of the validation set - No final activation function after the model output (such as sigmoid) - Effectively removed patience
wli51
approved these changes
Jul 21, 2026
| raise ValueError("The generated predictions and targets must be the same shape.") | ||
|
|
||
|
|
||
| def resolve_ssim_data_range( |
There was a problem hiding this comment.
this might be unecessary as the torchmetrics.functional.image.structural_similarity_index_measure be default does the same min max operation on incoming data if data_range is set as None
| from typing import Optional | ||
|
|
||
| import torch | ||
| from torchmetrics.functional.image import structural_similarity_index_measure |
There was a problem hiding this comment.
the functional API may not be the most efficient to use as training objectives, consider switching to torchmetrics.image.StructuralSimilarityIndexMeasure
| def compute_l1_ssim_mean_components( | ||
| generated_predictions: torch.Tensor, | ||
| targets: torch.Tensor, | ||
| ssim_weight: float, |
There was a problem hiding this comment.
nitpicking, might want to add guard rails to prevent this term from being negative so that the negative applied on SSIM cannot be undone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a mixed L1 plus auxiliary SSIM training objective, with the SSIM contribution tuned per trial by Optuna. The branch also logs batch-level L1, SSIM, and total losses during training, and aligns validation-based checkpoint selection and patience tracking with the same z-score-space total loss used for optimization, while keeping the existing denormalized image-quality metrics unchanged.