File size: 2,915 Bytes
e0ed750 dd2cf59 7981e4e 1eeed94 7981e4e 1eeed94 7981e4e d4776d1 7981e4e d4776d1 7981e4e d4776d1 7981e4e d4776d1 31e9a7d d4776d1 31e9a7d 7981e4e 1eeed94 7981e4e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
---
license: apache-2.0
language:
- en
metrics:
- f1
tags:
- cell segmentation
- stardist
- hover-net
library_name: transformers
pipeline_tag: image-segmentation
datasets:
- Lewislou/cell_samples
---
# Model Card for cell-seg-sribd
<!-- Provide a quick summary of what the model is/does. -->
This repository provides the solution of team Sribd-med for NeurIPS-CellSeg Challenge. The details of our method are described in our paper [Multi-stream Cell Segmentation with Low-level Cues for Multi-modality Images]. Some parts of the codes are from the baseline codes of the NeurIPS-CellSeg-Baseline repository,
You can reproduce our method as follows step by step:
### How to Get Started with the Model
Install requirements by python -m pip install -r requirements.txt
## Training Details
### Training Data
The competition training and tuning data can be downloaded from https://neurips22-cellseg.grand-challenge.org/dataset/ Besides, you can download three publiced data from the following link: Cellpose: https://www.cellpose.org/dataset Omnipose: http://www.cellpose.org/dataset_omnipose Sartorius: https://www.kaggle.com/competitions/sartorius-cell-instance-segmentation/overview
## Environments and Requirements:
Install requirements by
```shell
python -m pip install -r requirements.txt
```
### How to use
Here is how to use this model:
```python
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
img_name = 'cell_00023.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)
# normalize image data
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)
#dummy_input = np.zeros((512,512,3)).astype(np.uint8)
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)
``` |