U-Net for mitochondria in electron microscopy (bioimage.io shivering-raccoon) – safetensors

This is the MitchondriaEMSegmentation2D model by Constantin Pape (EMBL Heidelberg), known on bioimage.io as shivering-raccoon, converted from the original PyTorch state dict to safetensors. ("Mitchondria" is the original model's spelling.)

It segments mitochondria in electron microscopy (EM) images. For each pixel it predicts the probability of a mitochondrion (foreground) and of a mitochondrion boundary. It takes the raw EM image.

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
shivering-raccoon.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 shivering-raccoon.evanet: 2ff0c909d47529be72d28973a1b0a8dd1e51584823eb67b5943b6ad2d6ffb24c

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: unet2d
    • arch_version: 1
    • config: {"in_channels":1,"out_channels":2,"depth":4,"initial_features":64,"gain":2,"norm":"instance","final_activation":"sigmoid"}
    • preprocessing: zero_mean_unit_variance
    • name, 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, 8-bit EM), normalized as described below. Against the package's expected output (test_output_0.npy), the largest difference is 1.05 Γ— 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("shivering-raccoon.evanet"))
net.eval()

Input and output

  • Input: one channel, the raw EM image. Height and width must be multiples of 16 (at least 32). 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 (mitochondrion) probability, channel 1 the boundary probability.
  • To get single mitochondria, remove the boundaries from the foreground and label the connected regions, or use a watershed on the boundaries.

In EVAnalyzer: the step AI UNet Segmentation with Output mode = independent channels, Foreground channel = 0 and Boundary channel = 1, followed by Extract Objects.

Training

From the original documentation: trained with torch-em on the VNC dataset, serial-section TEM of the Drosophila ventral nerve cord (Dice loss, Adam, learning rate 1e-4, 5 epochs of 500 batches). Images from other EM methods or other tissues may need a check before you rely on the results.

License

The original weights are published under CC-BY-4.0 (bioimage.io model shivering-raccoon, Constantin Pape). This conversion keeps that license. The training data, the VNC dataset on figshare, is published under CC-BY-4.0.

Citation

If you use this model, please cite the original work:

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.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support