Skip to main content

napari-bioimageio

napari plugin for managing AI models in the BioImage Model Zoo.

WARNING: This is an alpha release. The API may change in future versions, and please feel free to create issues to report bugs or provide feedbacks.

Installation

pip install napari-bioimageio

(If you don't have napari installed, run pip install napari[pyqt5])

Usage

This library is meant for helping developers to ease the handling of models in napari.

We provide a set of API functions for managing and selecting models.

show_model_manager()

Show the model manager with a model list pulled from the BioImage Model Zoo, the user can explore all the available models, download or remove models.

show_model_selector(filter=None)

Display a dialog for selecting models from the BioImage Model Zoo, the user can either select an existing model or download from the BioImage Model Zoo.

The selecte model information (a dictionary) will be returned if the user selected a model, otherwise it returns None.

Once the user selected the model, you can access the name, and also the file path to the model resource description file (via the rdf_source key). With the bioimageio.core library (installed via pip install bioimageio.core or conda install -c conda-forge bioimageio.core), you can run inference directly, the following examples shows how to implement it:

# Popup a model selection dialog for choosing the model
model_info = show_model_selector(filter=nuclear_segmentation_model_filter)

if model_info:
  self.nucseg_model_source = model_info["rdf_source"]
  # Load model 
  model_description = bioimageio.core.load_resource_description(model_info["rdf_source"])
  input_image = imageio.imread("./my-image.tif")

  with bioimageio.core.create_prediction_pipeline(
      bioimageio_model=model_description
  ) as pipeline:
    output_image = bioimageio.core.prediction.predict_with_padding(
        pipeline, input_image, padding=padding
    )

Note: To run the models, you need to setup the conda environment properly according to the installation guide of bioimageio.core.

For more examples, see this example notebook for bioimageio.core.

You can also access the weight files directly by searching the model folder (e.g. extract the model folder path via os.path.dirname(model_description["rdf_source"])), this will be useful if you prefer to use your own model inference logic.

show_model_uploader()

Display a dialog to instruct the user to upload a model package to the BioImage Model Zoo. Currently, it only shows a message, in the future, we will try to support direct uploading with user's credentials obtained from Zenodo (a public data repository used by the BioImage Model Zoo to store models).

To create a BioImageIO-compatible model package, you can use the build_model function as demonstrated in this notebook.

Development

  • Install and set up development environment.

    pip install -r requirements_dev.txt
    

    This will install all requirements. It will also install this package in development mode, so that code changes are applied immediately without reinstall necessary.

  • Here's a list of development tools we use.

  • It's recommended to use the corresponding code formatter and linters also in your code editor to get instant feedback. A popular editor that can do this is vscode.

  • Run all tests, check formatting and linting.

    tox
    
  • Run a single tox environment.

    tox -e lint
    
  • Reinstall all tox environments.

    tox -r
    
  • Run pytest and all tests.

    pytest
    
  • Run pytest and calculate coverage for the package.

    pytest --cov-report term-missing --cov=napari-bioimageio
    
  • Continuous integration is by default supported via GitHub actions. GitHub actions is free for public repositories and comes with 2000 free Ubuntu build minutes per month for private repositories.

Metadata

Release files for napari-bioimageio 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for napari-bioimageio 0.1.3
File Size Uploaded
napari_bioimageio-0.1.3.tar.gz 25.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for napari-bioimageio 0.1.3
File Interpreter ABI Platform
napari_bioimageio-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 50.0 kB

Release files / napari_bioimageio-0.1.3.tar.gz

Download URL napari_bioimageio-0.1.3.tar.gz
Size 25.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7474b6aef715bc2933c61121a840532bc7a4717fba77a84f88a89395945af081
BLAKE2b-256 checksum
How to use checksums
7e4ed775e6c2a269e02c5567d208c4e50ec3d75b0137126c047cea3ff2794b7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / napari_bioimageio-0.1.3-py3-none-any.whl

Download URL napari_bioimageio-0.1.3-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c93571bd49979aec28d3d9060e5e8e3ee86b3f1258a4ed94e2d6e7df6b48df36
BLAKE2b-256 checksum
How to use checksums
a1963f912fe4857b92cd5fd1b8ac518f4f7443683d9d6a84cca0bf4fcea80ba0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page