Skip to content

Feat: Add finetuning code & dice loss support for IO#62

Open
basardemir wants to merge 16 commits intomainfrom
feat-add-finetuning
Open

Feat: Add finetuning code & dice loss support for IO#62
basardemir wants to merge 16 commits intomainfrom
feat-add-finetuning

Conversation

@basardemir
Copy link
Copy Markdown
Collaborator

No description provided.

basardemir and others added 4 commits September 25, 2025 14:47
- 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
Basar Demir added 3 commits December 18, 2025 08:28
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.
Comment thread finetuning/README.md Outdated
Training progress is logged to TensorBoard:

```bash
tensorboard --logdir=results/my_finetuning_experiment
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are the log files saved in the specified output folder, such as " tensorboard --logdir=my_config[training][output_folder]/my_finetuning_experiment"?

Comment thread finetuning/README.md Outdated
```bash
# Navigate to finetuning directory
cd uniGradICON/
pip install .
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to consider users who install using "pip install unigradicon"?

Comment thread finetuning/config_loader.py Outdated
return 'standard'


def create_dataset_from_config(dataset_config: Dict[str, Any], input_shape: Tuple[int, ...]) -> dataset.Dataset:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to validate that the image files in the dataset JSON file exist?

Comment thread finetuning/dataset.py Outdated
desired_coordinate_orientation=desired_coordinate_orientation,
use_image_direction=True)

class Dataset:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Basar Demir and others added 9 commits January 28, 2026 14:50
… dataset file validation, refactor datasets to torch base classes, and correct weighted sampling.
* 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
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.

2 participants