Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

napari_bioimageio-0.1.3.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

napari_bioimageio-0.1.3-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file napari_bioimageio-0.1.3.tar.gz.

File metadata

  • Download URL: napari_bioimageio-0.1.3.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for napari_bioimageio-0.1.3.tar.gz
Algorithm Hash digest
SHA256 7474b6aef715bc2933c61121a840532bc7a4717fba77a84f88a89395945af081
MD5 711f490ae1009a6754af4ceed895b0d0
BLAKE2b-256 7e4ed775e6c2a269e02c5567d208c4e50ec3d75b0137126c047cea3ff2794b7e

See more details on using hashes here.

File details

Details for the file napari_bioimageio-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for napari_bioimageio-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c93571bd49979aec28d3d9060e5e8e3ee86b3f1258a4ed94e2d6e7df6b48df36
MD5 0f7188170d828858f76a637ef1c95455
BLAKE2b-256 a1963f912fe4857b92cd5fd1b8ac518f4f7443683d9d6a84cca0bf4fcea80ba0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page