Skip to content

Commit

Permalink
bug with size model location (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
carsen-stringer committed Oct 25, 2024
1 parent 6fb288f commit b74038d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions cellpose/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,20 @@ def model_path(model_type, model_index=0):


def size_model_path(model_type):
if os.path.exists(model_type):
return model_type + "_size.npy"
else:
torch_str = "torch"
if model_type == "cyto" or model_type == "nuclei" or model_type == "cyto2":
basename = "size_%s%s_0.npy" % (model_type, torch_str)
else:
torch_str = "torch"
if (model_type == "cyto" or model_type == "nuclei" or
model_type == "cyto2" or model_type == "cyto3"):
if model_type == "cyto3":
basename = "size_%s.npy" % model_type
else:
basename = "size_%s%s_0.npy" % (model_type, torch_str)
return cache_model_path(basename)

else:
if os.path.exists(model_type) and os.path.exists(model_type + "_size.npy"):
return model_type + "_size.npy"
else:
raise FileNotFoundError(f"size model not found ({model_type + '_size.npy'})")


def cache_model_path(basename):
MODEL_DIR.mkdir(parents=True, exist_ok=True)
Expand Down

0 comments on commit b74038d

Please sign in to comment.