Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Size model not downloaded when using cwd as model path #1015

Open
sea-shunned opened this issue Sep 20, 2024 · 0 comments
Open

[BUG] Size model not downloaded when using cwd as model path #1015

sea-shunned opened this issue Sep 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sea-shunned
Copy link

Describe the bug
If the CELLPOSE_LOCAL_MODELS_PATH is set to the current working directory (cwd), then the model is downloaded properly but the size model fails to download and leads to a FileNotFoundError. This can be a problem in a Nextflow environment where staging happens locally.

Note that this problem occurs whether or not the model is downloaded, but the download step for the CellposeModel does execute properly, just not the SizeModel.

This is due to the os.path.exists(model_type) line here, which only checks the cwd and thus evaluates to True, skipping the caching for the size file in the else clause.

To Reproduce

import os
from pathlib import Path

# Set path to cwd to replicate Nextflow work dir
os.environ["CELLPOSE_LOCAL_MODELS_PATH"] = str(Path.cwd())

from cellpose import models

cp_model = models.Cellpose(model_type="cyto3")

Probably need to add another check there for whether the associated size npy file exists, or you may prefer another way!

@sea-shunned sea-shunned added the bug Something isn't working label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant