Skip to content

Implement rescaling inputs for domain adaptation#157

Open
stmartineau99 wants to merge 4 commits intomainfrom
sage-branch
Open

Implement rescaling inputs for domain adaptation#157
stmartineau99 wants to merge 4 commits intomainfrom
sage-branch

Conversation

@stmartineau99
Copy link
Copy Markdown
Contributor

@stmartineau99 stmartineau99 commented Feb 24, 2026

motivation

  • a source model was trained on data with vsize 10A, so the adapted model should also be trained on 10A data.

two ideas to solve this problem:

  1. rescaling after patch extraction
  2. rescale full volume inputs then write to temp files

I decided to try option 2. because option 1. requires rescaling then resizing to get back to the original patch size. We are already writing to temp files so I thought rescaling could be done at this step, because just rescaling (one interpolation) would probably result in less information lost than rescale + resize (two interpolations).

changes to semisupervised_training.py get_unsupervised_loader

  • rescaling inputs to target_vsize, applied differently to float data and int data (mask)
  • rescaling factor is automatically calculated by reading the voxel size from an .mrc file
  • rescaled volumes are written to temporary files, which are given to RawDataset()
  • rewrite get_stacked_paths() to be more memory efficient, write to $TMPDIR instead of /tmp
  • tested case 2 (raw + sample mask) - works
  • tested case 4 (raw only) - works

changes to domain_adaptation.py mean_teacher_adaptation

  • add target_vsize argument
  • moved data loaders and check_loader, to before torch_em.load_model
  • before it was loading the model from the checkpoint which would spawn a bunch of workers resulting in freezing; this can be avoided when checking the loader

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like this was added by accident.

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