Importing Fine-tuned Models

Napari-OmniEM can import compatible fine-tuned OmniEM heads through Add Solution. This page uses two example model families to show which artifacts you need and how to register them with the plugin.

Models and required files

This page demonstrates two model families from the omniem-train examples/ folder:

Example Model purpose Task type Variants
EMPIAR-11831 4× super-resolution Image-to-Image 2D
ME2-Beta Mitochondria segmentation Image-to-Label 2D and 3D

Prepare these items for each model variant:

Item Purpose
model.yaml Defines the OmniEM model and is selected as the model config in Add Solution.
weights/head_best.pt Contains the task head selected for a Head-only import.

Use each variant's config and head from the same model run. For ME2-Beta, the 2D and 3D variants require their own model.yaml and head_best.pt files.

These examples use the default EMDINOv1-ViTL backbone (4246a479), which is already registered in Napari-OmniEM; no backbone weights are required. If a model uses a different backbone, follow Add a backbone before importing its head.


Example 1: 4× super-resolution (Image-to-Image)

Source: omniem-train/examples/EMPIAR-11831/ouputs/empair11931_sr4x/ (SBF-SEM tobacco tissue). The head restores detail lost to 4× downsampling. Its model.yaml:

arch: omniemv1
encoder: emdinov1
img_z: 1
out_channels: 1          # one grayscale map
kernel3d_z: null
task_type: image2image
resize4emdino: true

Import it:

  1. Open Preferences (⚙️) → Tasks and Models → Solutions, then select the existing Super-resolution task or create a compatible Image-to-Image task.
  2. Click Add Solution, then Select model config and pick the run's model.yaml.
  3. Choose the Head-only strategy, select weights/head_best.pt, and pair it with EMDINOv1-ViTL.
  4. Confirm. The head is copied into the managed weights folder and the solution appears in the task.

Import the super-resolution head

Use it: run the imported model like any Image-to-Image solution; see In-memory inference. This head was trained for 4× super-resolution, so set Scale (×) <= 4.0 to use its intended factor.


Example 2: mitochondria segmentation (Image-to-Label)

Source: omniem-train/examples/ME2-Beta (FIB-SEM data from the MitoEM 2.0 benchmark). The head maps each EM image to a two-class mask: background (0) and mitochondria (1). The example provides two configurations for the same data:

Variant img_z kernel3d_z Sample shape
2D (run_mito_2d) 1 null 224 × 224 × 1
3D (run_mito_3d) 16 3 224 × 224 × 16

The 2D model.yaml:

arch: omniemv1
encoder: emdinov1
img_z: 1
out_channels: 2          # background + mitochondria
kernel3d_z: null
task_type: image2label
resize4emdino: false

Import it:

  1. Select the existing Mitochondria Segmentation task. Its Background and Mitochondria labels match out_channels: 2.
  2. Click Add Solution, select the run's model.yaml, choose Head-only, pick weights/head_best.pt, and pair it with EMDINOv1-ViTL.
  3. Confirm. Repeat with the 3D run's model.yaml + head_best.pt to add the 3D variant as a second solution (it needs z ≥ 16).

Import the mitochondria head

Use it: run the imported model like any Image-to-Label solution. Its output is a mask with Background and Mitochondria labels.


After importing

Imported solutions behave like the built-in solutions: they appear in the Task and Solution menus for both in-memory and local inference, and you can export or share them. To manage the shared backbone they run on, see Backbone management.


References

  • Wickramanayake, J. S., & Czymmek, K. J. (2023). A conventional fixation volume electron microscopy protocol for plants. Methods in Cell Biology, 177, 83-99.
  • Liu, P. (2026). MitoEM 2.0: A Benchmark for Challenging 3D Mitochondria Instance Segmentation from EM Images [Dataset]. Zenodo.