🚀 細胞分割模型(cell-seg-sribd)
本倉庫提供了Sribd-med團隊針對NeurIPS - CellSeg挑戰賽的解決方案。我們方法的詳細內容在論文[Multi - stream Cell Segmentation with Low - level Cues for Multi - modality Images]中有所描述。部分代碼來自NeurIPS - CellSeg - Baseline倉庫的基線代碼。
🚀 快速開始
你可以按照以下步驟復現我們的方法:
通過以下命令安裝所需依賴:
python -m pip install -r requirements.txt
✨ 主要特性
- 適用場景:適用於細胞分割任務。
- 技術標籤:涉及cell segmentation、stardist、hover - net等技術。
- 使用庫:基於transformers庫。
- 評估指標:使用F1指標進行評估。
📦 安裝指南
環境和依賴
通過以下命令安裝所需依賴:
python -m pip install -r requirements.txt
💻 使用示例
基礎用法
from skimage import io, segmentation, morphology, measure, exposure
from sribd_cellseg_models import MultiStreamCellSegModel,ModelConfig
import numpy as np
import tifffile as tif
import requests
import torch
from PIL import Image
from overlay import visualize_instances_map
import cv2
img_name = 'test_images/cell_00551.tiff'
def normalize_channel(img, lower=1, upper=99):
non_zero_vals = img[np.nonzero(img)]
percentiles = np.percentile(non_zero_vals, [lower, upper])
if percentiles[1] - percentiles[0] > 0.001:
img_norm = exposure.rescale_intensity(img, in_range=(percentiles[0], percentiles[1]), out_range='uint8')
else:
img_norm = img
return img_norm.astype(np.uint8)
if img_name.endswith('.tif') or img_name.endswith('.tiff'):
img_data = tif.imread(img_name)
else:
img_data = io.imread(img_name)
if len(img_data.shape) == 2:
img_data = np.repeat(np.expand_dims(img_data, axis=-1), 3, axis=-1)
elif len(img_data.shape) == 3 and img_data.shape[-1] > 3:
img_data = img_data[:,:, :3]
else:
pass
pre_img_data = np.zeros(img_data.shape, dtype=np.uint8)
for i in range(3):
img_channel_i = img_data[:,:,i]
if len(img_channel_i[np.nonzero(img_channel_i)])>0:
pre_img_data[:,:,i] = normalize_channel(img_channel_i, lower=1, upper=99)
my_model = MultiStreamCellSegModel.from_pretrained("Lewislou/cellseg_sribd")
checkpoints = torch.load('model.pt')
my_model.__init__(ModelConfig())
my_model.load_checkpoints(checkpoints)
with torch.no_grad():
output = my_model(pre_img_data)
overlay = visualize_instances_map(pre_img_data,star_label)
cv2.imwrite('prediction.png', cv2.cvtColor(overlay, cv2.COLOR_RGB2BGR))
📚 詳細文檔
訓練數據
競賽的訓練和調優數據可以從https://neurips22 - cellseg.grand - challenge.org/dataset/ 下載。此外,你還可以從以下鏈接下載三個公開數據集:
- Cellpose: https://www.cellpose.org/dataset
- Omnipose: http://www.cellpose.org/dataset_omnipose
- Sartorius: https://www.kaggle.com/competitions/sartorius - cell - instance - segmentation/overview
引用
如果使用了本代碼的任何部分,請適當引用並引用以下論文:
@misc{
lou2022multistream,
title={Multi - stream Cell Segmentation with Low - level Cues for Multi - modality Images},
author={WEI LOU and Xinyi Yu and Chenyu Liu and Xiang Wan and Guanbin Li and Siqi Liu and Haofeng Li},
year={2022},
url={https://openreview.net/forum?id=G24BybwKe9}
}
📄 許可證
本項目採用Apache - 2.0許可證。
屬性 |
詳情 |
模型類型 |
細胞分割模型 |
訓練數據 |
競賽訓練和調優數據(https://neurips22 - cellseg.grand - challenge.org/dataset/ )、Cellpose(https://www.cellpose.org/dataset )、Omnipose(http://www.cellpose.org/dataset_omnipose )、Sartorius(https://www.kaggle.com/competitions/sartorius - cell - instance - segmentation/overview ) |
評估指標 |
F1 |
技術標籤 |
cell segmentation、stardist、hover - net |
使用庫 |
transformers |
任務類型 |
圖像分割 |
數據集 |
Lewislou/cell_samples |