Feat: Add finetuning code & dice loss support for IO#62
Feat: Add finetuning code & dice loss support for IO#62basardemir wants to merge 16 commits intomainfrom
Conversation
- Add config-based multi-dataset finetuning with weighted sampling - Support paired/unpaired datasets with optional segmentations - Implement Dice loss for anatomical structure alignment - Add comprehensive finetuning documentation and examples - Include dataset caching and auto-download of pretrained weights - Add per-dataset validation and TensorBoard logging
Add numpy<2.0 constraint to prevent AttributeError with np.bool. NumPy 2.0+ removed the deprecated np.bool alias that older ITK versions depend on.
| Training progress is logged to TensorBoard: | ||
|
|
||
| ```bash | ||
| tensorboard --logdir=results/my_finetuning_experiment |
There was a problem hiding this comment.
Are the log files saved in the specified output folder, such as " tensorboard --logdir=my_config[training][output_folder]/my_finetuning_experiment"?
| ```bash | ||
| # Navigate to finetuning directory | ||
| cd uniGradICON/ | ||
| pip install . |
There was a problem hiding this comment.
Do we need to consider users who install using "pip install unigradicon"?
| return 'standard' | ||
|
|
||
|
|
||
| def create_dataset_from_config(dataset_config: Dict[str, Any], input_shape: Tuple[int, ...]) -> dataset.Dataset: |
There was a problem hiding this comment.
Do we need to validate that the image files in the dataset JSON file exist?
| desired_coordinate_orientation=desired_coordinate_orientation, | ||
| use_image_direction=True) | ||
|
|
||
| class Dataset: |
There was a problem hiding this comment.
Is this Dataset class inherited from torch.utils.data.Dataset?
| samples_per_epoch = config['training'].get('samples_per_epoch', total_samples) | ||
|
|
||
| total_weight = sum(weights) | ||
| normalized_weights = [w / total_weight for w in weights] |
There was a problem hiding this comment.
Do we want the weight to balance the sizes of the datasets, namely, by sampling more data from the smaller dataset? The current implementation seems to assign a lower weight to datasets of smaller size.
… dataset file validation, refactor datasets to torch base classes, and correct weighted sampling.
…egmentations in TensorBoard, update docs
* Test build * Prepare test setting * Add 'Add_build_workflow' branch to trigger build and deploy workflow * Add step in the workflow to find an empty gpu * 1. improve the GPU selection logic 2. Run CLI test with CPU * Enhance GPU selection logic with detailed logging and re-evaluation for optimal GPU choice * Use another GPU. * Fix CUDA_VISIBLE_DEVICES environment variable type for GPU unit tests * Remove explicit GPU environment variable for unit tests to allow dynamic selection * Update build workflow to require upload options * Refactor build workflow: rename job, update upload steps, and clean up commented code * Update build workflow: remove upload_to_pypi input and comment out TestPyPI conditions * Fix typo. * fix bug * Revert the version back to 1.0.4 * Fix the version number * Refactor workflow: remove process.exit call and rename step to download test data
…TensorBoard viz, Learn2Reg examples, and fix Dice background/memory leak/DICOM/shape bugs
…ture finetuning to dict-based pipeline with 2 dataset types
No description provided.