Skip to content

Make the model folder adjustable - #149

Merged
C-Achard merged 1 commit into
AdaptiveMotorControlLab:mainfrom
guiwitz:flexible-model-path
Dec 1, 2026
Merged

C-Achard merged 1 commit into
AdaptiveMotorControlLab:mainfrom
guiwitz:flexible-model-path

Conversation

@guiwitz

@guiwitz guiwitz commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Hi team CellSeg3D,

after the nice presentation given by @C-Achard at SwissBIAS, I tried to install CellSeg3D on our HPC image analysis platform. After solving the issue mentioned here, I managed to run the software which gave impressive results!

Currently it seems that CellSeg3D always defaults to the installation folder to download models via

PRETRAINED_WEIGHTS_DIR = Path(__file__).parent.resolve() / Path("models/pretrained")

Downloading inside the package itself is usually not recommended and in particular creates problems in the case where the installation folder is somehow locked. This is my case where I provide software on HPC in the form of uneditable containers.

This PR implements a solution where the downloads folder can be set via an environment variable, similarly to what is done for other packages such as pytorch (TORCH_HOME) or spotiflow (SPOTIFLOW_CACHE_DIR).

The current implementation uses CELLSEG3D_WEIGHTS_DIR which can be read inside the software via utils.get_pretrained_weights_dir(). A note has also been added to the documentation.

I'm happy to revise if you think something doesn't fit with the overall package design. Also let me know if I missed a more obvious way to set that path!

@C-Achard C-Achard self-assigned this Dec 1, 2026
@C-Achard C-Achard added enhancement New feature or request feature request A new feature to add labels Dec 1, 2026
@C-Achard C-Achard modified the milestones: v0.2.5, v0.2.6 Dec 1, 2026

@C-Achard C-Achard left a comment •

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.

Hello @guiwitz,

Thanks for opening this, and glad it works on your data!

This is a useful change, I will merge it as is; sorry for the inconvenience with the hardcoded version.

I'll make a quick follow-up PR so that the env var value is reloaded when calling rather than evaluated once at import time (mostly for notebooks, so there is no import/env var cells ordering considerations), plus some cross-platform examples in the docs, otherwise all good.

Thanks again,
Cyril

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

Labels

enhancement New feature or request feature request A new feature to add

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants