1conda create -n cellpose python=3.10
2conda activate cellpose
3pip install cellpose==4.2.1 torch opencv-python numpy huggingface_hub
1from cellpose import models
2import cv2, numpy as np
3
4# 加载分割模型
5model = models.CellposeModel(
6 gpu=True,
7 pretrained_model='models/cpsam_v2_fold3/best_model'
8)
9
10# 推理
11img = cv2.imread('kidney_section.jpg')
12masks, flows, styles = model.eval(
13 img,
14 diameter=414,
15 flow_threshold=0.3,
16 cellprob_threshold=-0.5,
17 channels=[0, 0]
18)
1python predict_tubule.py \
2 --img_dir data/test_images \
3 --seg_model models/cpsam_v2_fold3/best_model \
4 --cls_model models/classifier/cnn_classifier_fold0.pth \
5 --out_dir results/output \
6 --flow_threshold 0.3 \
7 --cellprob_threshold -0.5