U-Net for cells in immunofluorescence (bioimage.io powerful-chipmunk) β safetensors
This is the CovidIFCellSegmentationBoundaryModel by Constantin Pape (EMBL Heidelberg), known on bioimage.io as powerful-chipmunk, converted from the original PyTorch state dict to safetensors.
It segments cells in immunofluorescence microscopy images. For each pixel it predicts the probability of a cell (foreground) and of a cell boundary. It was trained on Vero E6 cells imaged with a high-throughput microscope for a COVID-19 antibody test.
The weights are unchanged. They are only stored in another file format. I did not retrain or fine-tune anything.
I made this conversion for EVAnalyzer, which runs the U-Net through its own Rust implementation and does not need Python or PyTorch. The file is a plain safetensors file, so any other tool that reads safetensors can load it too.
Files
| File | Content |
|---|---|
powerful-chipmunk.evanet |
the weights as safetensors, f32, about 116 MB |
.evanet is EVAnalyzer's extension for neural network models. The file itself is a
standard safetensors file, so you can rename it to .safetensors if your tool needs that.
SHA-256 of powerful-chipmunk.evanet:
9b855afbaf5029440fdecaffa7d2769ee002d4a9165649d4c90bbb71026d6bf7
Architecture
torch-em's UNet2d (2D U-Net):
| Argument | Value |
|---|---|
in_channels |
1 |
out_channels |
2 (foreground, boundaries) |
depth |
4 |
initial_features |
64 |
gain |
2 |
| normalization | InstanceNorm (torch-em's default) |
final_activation |
Sigmoid |
What changed in the conversion
- The 46 tensors keep torch-em's PyTorch names (
base.block.1.weight, ...,out_conv.weight) and are stored as f32. Nothing was left out. __metadata__holds the architecture and the source:evanalyzer_arch:unet2darch_version:1config:{"in_channels":1,"out_channels":2,"depth":4,"initial_features":64,"gain":2,"norm":"instance","final_activation":"sigmoid"}preprocessing:zero_mean_unit_variancename,description,source,license,citation
Check against the original
After the conversion, the file was loaded back and run on the bioimage.io package's own test
input (test_input_0.npy, 512 Γ 512), normalized as described below. Against the package's
expected output (test_output_0.npy), the largest difference is 3.3 Γ 10β»β΅, and no pixel
changes sides of 0.5.
Use in Python with torch-em
from safetensors.torch import load_file
from torch_em.model import UNet2d
net = UNet2d(in_channels=1, out_channels=2, depth=4, initial_features=64, gain=2,
final_activation="Sigmoid")
net.load_state_dict(load_file("powerful-chipmunk.evanet"))
net.eval()
Input and output
- Input: one channel, the cell stain. Height and width must be multiples of 16 (at least
64). Normalize each image to zero mean and unit variance first:
(x - mean) / (std + 1e-6)over all pixels. - Output: 2 channels with values from 0 to 1. Channel 0 is the foreground (cell) probability, channel 1 the boundary probability.
- To get single cells, the original authors combine the boundaries with a nucleus segmentation: a seeded watershed grows each nucleus into its cell, limited by the foreground and stopped at the boundaries.
In EVAnalyzer: the step AI UNet Segmentation with Output mode = independent channels, Foreground channel = 0 and Boundary channel = 1. For touching cells, segment the nuclei first (e.g. with the nucleus U-Net or StarDist) and grow them into the cells.
Training
From the original documentation: trained with torch-em on immunofluorescence images of Vero E6 cells from Pape et al. (2021) (Dice loss, Adam, learning rate 1e-4, 1243 epochs).
License
The original weights are published under CC-BY-4.0 (bioimage.io model powerful-chipmunk, Constantin Pape). This conversion keeps that license. The training data (Zenodo 5092850) is published under CC-BY-4.0.
Citation
If you use this model, please cite the original work:
- Constantin Pape: torch-em, the training library. doi:10.5281/zenodo.5108853
- Ronneberger, Fischer, Brox (2015): U-Net: Convolutional Networks for Biomedical Image Segmentation. doi:10.1007/978-3-319-24574-4_28
- Pape et al. (2021): Microscopy-based assay for semi-quantitative detection of SARS-CoV-2 specific antibodies in human sera. BioEssays. doi:10.1002/bies.202000257
- The model on Zenodo: doi:10.5281/zenodo.5847355
Credits
All credit for the model goes to Constantin Pape (EMBL Heidelberg) and the bioimage.io community. This repository is not affiliated with or endorsed by them.