Skip to content

Read CELLSEG3D_WEIGHTS_DIR on weights load - #150

Merged
C-Achard merged 5 commits into
mainfrom
weights-dir-followup
Dec 1, 2026
Merged

C-Achard merged 5 commits into
mainfrom
weights-dir-followup

Conversation

@C-Achard

@C-Achard C-Achard commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #149 by @guiwitz

Main changes

  • 'WeightsDownloader.download_weights` resolves on each call
  • WeightsInfo.path defaults to the folder resolved at instantiation
  • PRETRAINED_WEIGHTS_DIR was removed from config and workers_utils; replaced by utils.get_pretrained_weights_dir() or the path returned by download_weights.
  • utils.PRETRAINED_URLS_DIR is renamed PACKAGE_PRETRAINED_DIR, as it's also the default weights folder.
  • Adds a Windows example to inference guide

@C-Achard C-Achard added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 1, 2026
@C-Achard C-Achard self-assigned this Dec 1, 2026
@C-Achard C-Achard changed the title Read CELLSEG3D_WEIGHTS_DIR when weights are loaded Read CELLSEG3D_WEIGHTS_DIR on weights load Dec 1, 2026
@C-Achard
C-Achard requested a balanced review from Copilot December 1, 2026 11:46
@C-Achard C-Achard added this to the v0.2.6 milestone Dec 1, 2026

Copilot AI left a comment

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.

🟡 Changes recommended

Removing PRETRAINED_WEIGHTS_DIR from config leaves the Colab training notebook importing a nonexistent export, causing an ImportError before training can start.

1 open issue
What changed in this PR

This follow-up to #149 makes CellSeg3D resolve the weights directory when needed, allowing CELLSEG3D_WEIGHTS_DIR to be set after import.

Changes:

  • Resolve download destinations per call and default WeightsInfo.path at instantiation.
  • Update training, inference, and tests to use the downloader’s returned file path.
  • Document PowerShell configuration and clarify that existing weights are not moved.
File Description
napari_cellseg3d/​utils.py Rename the package directory constant and clarify runtime resolution.
napari_cellseg3d/​dev_scripts/​colab_training.py Resolve the directory dynamically for logging.
napari_cellseg3d/​config.py Set the default weights path at instantiation.
napari_cellseg3d/​code_models/​workers_utils.py Resolve each download destination and return the weights path.
napari_cellseg3d/​code_models/​worker_training.py Load pretrained weights from the returned path.
napari_cellseg3d/​code_models/​worker_inference.py Use the returned path for inference weights.
napari_cellseg3d/​code_models/​models/​model_test.py Resolve the destination when saving test weights.
napari_cellseg3d/​_tests/​test_weight_download.py Cover custom directories, existing files, and returned paths.
napari_cellseg3d/​_tests/​test_models.py Check compatibility using returned weights paths.
napari_cellseg3d/​_tests/​test_inference.py Use the returned ONNX download path.
docs/​source/​guides/​inference_module_guide.rst Add Windows instructions and explain existing-file behavior.

Review effort: Balanced

Comment thread napari_cellseg3d/config.py Resolved

Copilot AI left a comment

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.

🟢 Approval recommended

No active review issues block the updates to dynamically resolve pretrained weights directories.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@C-Achard
C-Achard merged commit 405e094 into main Dec 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants