Inference

Napari-OmniEM offers two inference workflows:

  • In-memory (main panel): the quickest way to run a model, best for interactive exploration and small-to-medium data that fits in memory.
  • Local (on-disk) (πŸ“ wizard): streams large volumes from disk with bounded memory and multi-GPU support.

Task and solution selection and the sliding-window parameters work the same way in both workflows. See Tips & common pitfalls below.


Choose an inference mode

Use the size of your data and the required output quality to choose a mode:

Choose data
    β”œβ”€ Too large to fit in memory or requires multiple GPUs
    β”‚      └─ Local (on-disk)
    └─ Fits in memory
           β”œβ”€ Seam-free output needed and sufficient GPU memory available
           β”‚      └─ Full Volume
           └─ Otherwise
                  └─ In-memory (tiled)

Select task and solution β†’ Configure β†’ Run β†’ View or save

Continue with in-memory tiled inference, Full Volume mode, or local on-disk inference.


In-memory inference

In-memory inference runs directly in the main Napari-OmniEM panel on data loaded as napari image layers. It is the quickest way to run a model and is best for interactive exploration, debugging, and small-to-medium EM datasets.

Everything stays in memory

The input volume, intermediate tiles, and result all occupy GPU or CPU memory during the run, so the available memory limits this mode. For volumes too large to hold in memory, use Local inference instead.

You can run in one of two modes:

  • Sliding window (default): splits the volume into overlapping tiles, runs each tile through the model, and stitches the results together. It uses less GPU memory and can handle larger inputs.
  • Full Volume: the whole image is fed to the model in a single forward pass. Avoids stitching seams but needs more GPU memory. See Full Volume mode below.

Select data

  • Load image data into napari by selecting File β†’ Open File(s).

    • The data appear as one or more Image layers.
  • Loaded layers are detected automatically. If one is missing (rarely), click πŸ”„ Synchronize Data to rescan.

  • Select the target image from the Data dropdown list.

  • If the selected input is a 3D volume, specify the z-dimension:

    • By default, Napari-OmniEM selects the axis with the shortest length.

    • Change the selection if your data use a different axis convention.

Select task and solution

  • Choose the Task that corresponds to your processing goal: an Image-to-Image task (e.g. denoising, super-resolution) or an Image-to-Label task (e.g. mitochondria segmentation).

  • Select a compatible Solution from the Solution list.

    • The list is filtered automatically by the selected data: only solutions whose dimensionality and modality match the chosen layer are enabled, so you cannot select an incompatible model.
  • Not sure which to choose? Click the πŸ’‘ button next to the Task or Solution dropdown to show its details. For more detailed descriptions of the built-in models, see the Model Zoo.

Terminology

A Task defines the problem to solve. A Solution is a specific model and configuration that solves that task.

This terminology is consistent across in-memory and local inference.

Panel with data, task, and solution selected

Output options by task type

The panel shows different output controls depending on the task type:

  • Image-to-Image: a single Scale (Γ—) control (range 1.0–8.0, step 0.5). The ratio is applied to the in-plane (X/Y) axes together; the Z axis is never scaled. 1.0 keeps the size; restoration never downscales. The panel shows the resulting output shape as you adjust the value. Some models are trained for modest scaling.
  • Image-to-Label: a read-only table showing the label β†’ value mapping used in the output mask. No additional configuration is required.

Scale control for Image-to-Image

Advanced settings

The Advanced section contains settings for the current run. Their defaults come from Preferences. If you are unsure which values to use, keep the defaults for your first run.

  • Full Volume: enables Full Volume mode; see the next section.

Sliding-window only (disabled in Full Volume mode):

  • Overlap, Batch Size, XY Input Size: tiling controls; see Sliding Window Parameters.
  • Blend mode: how overlapping tiles are combined (constant or gaussian).

Both modes:

  • Normalization source: scan-data (statistics measured over the whole volume) or model (the model's built-in statistics).

Full Volume mode

Tick Full Volume to feed the whole image to the model in a single forward pass instead of tiling. This avoids sliding-window stitching seams and works for both Image-to-Image and Image-to-Label tasks, but it uses more GPU memory. The sliding-window controls (overlap, batch size, XY input size, and blend mode) are disabled; the normalization setting still applies.

Advanced settings with Full Volume enabled

If the input is not square, you are asked whether to use its height or width as the square input size. Napari-OmniEM restores the original aspect ratio and applies the requested output scale afterward; it does not crop the image.

Run inference

  • Click Run model to open the inference dialog. It shows the device, the planned work (either the batch count or padded input and output shapes), and the estimated GPU memory range for the run.

Pre-inference memory-estimate dialog

  • Start the run from the dialog. When it finishes, the OK button becomes Redo so you can rerun with different settings. The result appears in napari as a new layer.

  • For Image-to-Image results, you can rescale output intensity back to the input's range with the Post-process β†’ Image-to-Image tool.


Local (on-disk) inference

Open local (on-disk) inference by clicking the πŸ“ button in the main Napari-OmniEM panel. Napari-OmniEM loads data from local files using dask.array and stores intermediate results are stored as temporary HDF5 files (more efficient backends are planned). It is a step-by-step wizard: Input Data β†’ Task β†’ Advanced settings β†’ Run β†’ Output.

Open the panel

  • Click the πŸ“ icon in the main Napari-OmniEM panel.
  • This option is enabled only when a compatible GPU is available.

Step 1: Select data

  • Click Browse File to select a local image or volume. Common image formats read by dask-image are supported, such as TIFF (including multipage stacks, which load as 3D volumes), PNG, and JPEG. The data must be 2D (H, W), 3D (Z, H, W), or a colour variant (H, W, C) / (Z, H, W, C); other shapes are rejected.
  • The model works on single-channel data. If you load a colour or multi-channel image, a Channel selector appears so you can reduce it to one channel:
    • Convert to grayscale (weighted) (default): combine the colour channels into one grayscale channel.
    • Extract single channel: keep one channel, chosen by its 0-based index.
  • If the data are 3D, specify the z-dimension:
    • By default, the axis with the shortest length is selected.
    • Override this if your data use a different axis convention.

Local wizard: Input Data page

Everything streams from disk

Every inputβ€”2D, colour, or 3Dβ€”is processed as a streamed 3D volume with bounded memory use. Even large 2D images can therefore run without being loaded into memory in full.

Step 2: Select task and solution

  • Task and solution selection is the same as in in-memory inference.
  • Incompatible tasks and solutions are shown but disabled.

Step 3: Advanced settings (sliding window & devices)

In addition to the standard sliding-window parameters, local inference provides:

  • Device selection

    • GPU-only inference; at least one GPU must be chosen.
    • You can select multiple GPUs for parallel inference. Each selected GPU holds a complete model replica (backbone and head). The shared backbone is not deduplicated across GPUs, so total VRAM use increases in proportion to the number of GPUs.
  • Normalization source: scan-data (whole-volume statistics), model (built-in statistics), or manual (enter mean/std yourself). Manual is offered only here, in the on-disk wizard.

  • Temporary folder: where the scratch file is written during inference.

Local wizard: Advanced settings page

Step 4: Run inference

A persistent banner displays the run's estimated GPU memory requirement and the multi-GPU caveat described above.

Local wizard: Inference page with memory banner

  • Click Run to start inference.
  • When inference finishes, Run changes to Redo, so you can rerun with modified settings.

Step 5: Save output

Supported output options include:

  1. Open in napari

  2. Load the input data, the results, or both.

  3. Use this option cautiously with very large datasets.

  4. Standard file formats

  5. TIFF

  6. PNG (2D results only)
  7. NumPy (.npy)

  8. Chunked storage formats

  9. Zarr

  10. NumPyStack

How local inference differs

Compared with in-memory inference, local inference:

  • Enables multi-GPU parallel inference when multiple GPUs are available.

  • Writes a scratch file whose size is driven by the output: the pre-flight banner shows the estimate. Upscaling (Image-to-Image with Scale > 1) raises it substantially.

  • Supports saving outputs in multiple formats, with optional visualization in napari.

  • Cannot chain an Image-to-Image result into an Image-to-Label run in a single pass. Save the first result, then reload it for the second run.

  • Does not offer Full Volume mode (that is an in-memory option).


Tips & common pitfalls

Shared guidance for both modes. For what each tiling control does, see Sliding Window Parameters.

What uses memory

The input volume, model, intermediate tiles, and result all require storage during inference. In-memory mode keeps them in RAM or VRAM; local mode streams the volume from disk and holds only a bounded working set. A higher Scale (Γ—), a larger XY input size, or Full Volume mode all raise the peak.

If you run out of memory

Try these in order:

  • Reduce Batch Size (even 1 is acceptable).
  • Reduce the XY input size.
  • Lower the Scale (Γ—), or turn Full Volume off (in-memory).
  • Switch to local inference, which streams data from disk.

Balancing performance and memory

Most controls trade memory for speed or quality, so pick the largest settings your hardware allows:

  • A larger Batch Size raises throughput but uses more memory; it does not change output quality.
  • A larger XY input size gives the model more context (often better results) at a higher memory cost.
  • Full Volume avoids stitching seams but needs the most memory; sliding window trades a small seam risk for a much smaller footprint.

Start from the defaults, then raise one setting at a time until you approach your memory limit.

Shared backbone

Models that use the same backbone keep one resident copy of it, so switching between such solutions does not reload the encoder and keeps GPU use low. See Task, solution, and backbone management.

Memory warnings

Before each run, the plugin estimates the required memory and compares it with the available GPU and CPU memory and your configured limits. If the run may not fit, the plugin warns you. You can adjust the settings or select Proceed anyway at your own risk. See memory limits in Preferences.

Scratch disk (local inference)

On-disk inference writes an output-sized scratch HDF5 file. Size the disk from the pre-flight banner, not a fixed rule of thumb; upscaling raises the requirement substantially.

Temporary files are cleaned up on close

An on-disk result is backed by a scratch HDF5 file so the whole volume never sits in RAM. Closing the Local Inference window deletes that window's scratch automatically; results you opened into napari are in-memory copies and are kept. Use 🧰 β†’ Memory Management β†’ Clear temporal data only to remove leftovers from an interrupted run.