From ad7d4e455eed446aa96d1f63372739b2c580099a Mon Sep 17 00:00:00 2001 From: rhoadesScholar Date: Fri, 8 Mar 2024 12:30:26 -0500 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20file=20path=20parsi?= =?UTF-8?q?ng=20typo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cellmap_models/pytorch/cellpose/add_model.py | 3 ++- src/cellmap_models/pytorch/cellpose/get_model.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cellmap_models/pytorch/cellpose/add_model.py b/src/cellmap_models/pytorch/cellpose/add_model.py index d63d68c..d51a13d 100644 --- a/src/cellmap_models/pytorch/cellpose/add_model.py +++ b/src/cellmap_models/pytorch/cellpose/add_model.py @@ -1,3 +1,4 @@ +import os import sys from typing import Optional from cellpose.io import add_model as _add_model @@ -15,7 +16,7 @@ def add_model(model_name: Optional[str] = None): model_name = sys.argv[1] base_path = MODEL_DIR get_model(model_name, base_path) - _add_model(str(base_path / f"{model_name}.pth")) + _add_model(os.path.join(base_path, f"{model_name}.pth")) print( f"Added model {model_name}. This will now be available in the cellpose model list." ) diff --git a/src/cellmap_models/pytorch/cellpose/get_model.py b/src/cellmap_models/pytorch/cellpose/get_model.py index 0122dca..2ea7188 100644 --- a/src/cellmap_models/pytorch/cellpose/get_model.py +++ b/src/cellmap_models/pytorch/cellpose/get_model.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from cellpose.utils import download_url_to_file @@ -20,10 +21,10 @@ def get_model( f"Model {model_name} is not available. Available models are {list(models_dict.keys())}." ) - if not (base_path / f"{model_name}.pth").exists(): + if not Path(base_path / f"{model_name}.pth").exists(): print(f"Downloading {model_name} from {models_dict[model_name]}") download_url_to_file( - models_dict[model_name], str(base_path / f"{model_name}.pth") + models_dict[model_name], os.path.join(base_path, f"{model_name}.pth") ) print("Downloaded model {model_name} to {base_path}.") return