Skip to content

Commit d45651f

Browse files
committed
Fix Cellpose v3 compatibility: update API calls and enforce v3 requirement
- Fix segmentation_instances_cyto3.py to use CellposeModel class - Update model.eval() to unpack 3 return values instead of 4 - Enforce Cellpose v3 (>=3.0.0, <4.0.0) in install_dependencies.py - Add note to README about using faster Cellpose v3
1 parent 7e292d2 commit d45651f

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ To start the text-based user interface in your terminal, change directory to the
119119
python ./scripts/user_welcome.py
120120
```
121121

122+
**Note:** T-MIDAS terminal uses the faster Cellpose v3 for optimal segmentation performance.
123+
122124
## Acknowledgements and Citations
123125

124126
This project relies on several open-source libraries and tools. We would like to acknowledge and thank the creators of these projects:

scripts/install_dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,6 @@ def get_mamba_version(mamba_executable):
132132
run_command(cmd_prefix + "python -m pip install napari[all]")
133133

134134
print("Installing cellpose...")
135-
run_command(cmd_prefix + "python -m pip install cellpose")
135+
run_command(cmd_prefix + "python -m pip install 'cellpose>=3.0.0,<4.0.0'")
136136

137137
print("All dependencies installed successfully.")

scripts/segmentation_instances_cyto3.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ def process_image(input_file, input_folder, model, channels, diameter, flow_thre
4646
labeled_time_points = np.zeros(img.shape, dtype=np.uint32)
4747
for t in tqdm(range(img.shape[0]), desc="Processing time points"):
4848
img_t = img[t]
49-
mask, _, _, _ = model.eval(img_t, diameter=diameter, flow_threshold=flow_threshold,
50-
channels=channels, niter=2000, z_axis=0 if is_3d else None, do_3D=is_3d)
49+
mask, _, _ = model.eval(img_t, diameter=diameter, flow_threshold=flow_threshold,
50+
channels=channels, niter=2000, z_axis=0 if is_3d else None, do_3D=is_3d)
5151
labeled_time_points[t] = mask
5252
result = labeled_time_points
5353
else:
54-
result, _, _, _ = model.eval(img, diameter=diameter, flow_threshold=flow_threshold,
55-
channels=channels, niter=2000, z_axis=0 if is_3d else None, do_3D=is_3d)
54+
result, _, _ = model.eval(img, diameter=diameter, flow_threshold=flow_threshold,
55+
channels=channels, niter=2000, z_axis=0 if is_3d else None, do_3D=is_3d)
5656

5757
output_file = os.path.join(input_folder, input_file.replace(".tif", "_labels.tif"))
5858
imwrite(output_file, result.astype(np.uint32), compression='zlib')
@@ -77,7 +77,7 @@ def main():
7777
dim_order = args.dim_order
7878

7979
flow_threshold = 0.4
80-
model = models.Cellpose(gpu=use_GPU, model_type=args.model_type)
80+
model = models.CellposeModel(gpu=use_GPU, model_type=args.model_type)
8181

8282
input_files = [f for f in os.listdir(input_folder) if f.endswith('.tif') and not f.endswith('_labels.tif')]
8383

0 commit comments

Comments
 (0)