Downloads · 30 days
0
csmp-hub/cellvit-histo-cin2-nuc-v1
cellvit-histo-cin2-nuc-v1 is a image segmentation model from csmp-hub. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
- cellsegmodels.pytorch implementation of CellVit: https://arxiv.org/abs/2306.15350 - Backbone encoder: pre-trained samvitbasepatch16 from pytorch-image-models https://github.com/huggingface/pytorch-image-models
Downloads · 30 days
0
Access
Public
Updated May 8, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md4.9 KB · 76%
From the Hugging Face model README
pip install cellseg-models-pytorch
pip install albumentations
from cellseg_models_pytorch.models.cellvit import CellVit
model = CellVit.from_pretrained("hgsc_v1_efficientnet_b5")
from albumentations import Resize, Compose
from cellseg_models_pytorch.utils import FileHandler
from cellseg_models_pytorch.transforms.albu_transforms import MinMaxNormalization
model.set_inference_mode()
# Resize to multiple of 32 of your own choosing
transform = Compose([Resize(1024, 1024), MinMaxNormalization()])
im = FileHandler.read_img(IMG_PATH)
im = transform(image=im)["image"]
prob = model.predict(im)
out = model.post_process(prob)
# out = {"nuc": [(nuc instances (H, W), nuc types (H, W))], "cyto": None, "tissue": None}
import torch
from cellseg_models_pytorch.utils import FileHandler
model.set_inference_mode()
# dont use random matrices IRL
batch = torch.rand(8, 3, 1024, 1024)
prob = model.predict(im)
out = model.post_process(prob)
# out = {
# "nuc": [
# (nuc instances (H, W), nuc types (H, W)),
# (nuc instances (H, W), nuc types (H, W)),
# .
# .
# .
# (nuc instances (H, W), nuc types (H, W))
# ],
# "cyto": None,
# "tissue": None
#}
from matplotlib import pyplot as plt
from skimage.color import label2rgb
fig, ax = plt.subplots(1, 3, figsize=(18, 6))
ax[0].imshow(im)
ax[1].imshow(label2rgb(out["nuc"][0][0], bg_label=0)) # inst_map
ax[2].imshow(label2rgb(out["nuc"][0][1], bg_label=0)) # type_map
Semi-manually annotated CIN2 samples from a (private) cohort of Helsinki University Hospital
Contains:
nuc_classes = {
0: "background",
1: "neoplastic",
2: "inflammatory",
3: "connective",
4: "dead",
5: "glandular_epithelial",
6: "squamous_epithelial",
}
First, the image crops in the training data were tiled into 224x224px patches with a sliding window (stride=32px).
Rest of the training procedures follow this notebook: [link]
cellseg_models.pytorch:
@misc{https://doi.org/10.5281/zenodo.12666959,
doi = {10.5281/ZENODO.12666959},
url = {https://zenodo.org/doi/10.5281/zenodo.12666959},
author = {Okunator, },
title = {okunator/cellseg_models.pytorch: v0.2.0},
publisher = {Zenodo},
year = {2024},
copyright = {Creative Commons Attribution 4.0 International}
}
CellVit original paper:
@article{CellViT,
title = {CellViT: Vision Transformers for precise cell segmentation and classification},
journal = {Medical Image Analysis},
volume = {94},
pages = {103143},
year = {2024},
issn = {1361-8415},
doi = {https://doi.org/10.1016/j.media.2024.103143},
url = {https://www.sciencedirect.com/science/article/pii/S1361841524000689},
author = {Fabian Hörst and Moritz Rempe and Lukas Heine and Constantin Seibold and Julius Keyl and Giulia Baldini and Selma Ugurel and Jens Siveke and Barbara Grünwald and Jan Egger and Jens Kleesiek},
}
These model weights are released under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
While the Apache 2.0 License grants broad permissions, we kindly request that users adhere to the following guidelines: Medical or Clinical Use: This model is not intended for use in medical diagnosis, treatment, or prevention of disease of real patients. It should not be used as a substitute for professional medical advice.