Package: napari-bioimageio
napari-bioimageionapari plugin for managing AI models in theBioImage 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.Installationpip install napari-bioimageio(If you don't have napari installed, runpip install napari[pyqt5])UsageThis 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 returnsNone.Once the user selected the model, you can access the name, and also the file path to the model resource description file (via therdf_sourcekey). With thebioimageio.corelibrary (installed viapip install bioimageio.coreorconda 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 modelmodel_info=show_model_selector(filter=nuclear_segmentation_model_filter)ifmodel_info:self.nucseg_model_source=model_info["rdf_source"]# Load modelmodel_description=bioimageio.core.load_resource_description(model_info["rdf_source"])input_image=imageio.imread("./my-image.tif")withbioimageio.core.create_prediction_pipeline(bioimageio_model=model_description)aspipeline: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 theinstallation guide of bioimageio.core.For more examples, seethis example notebookforbioimageio.core.You can also access the weight files directly by searching the model folder (e.g. extract the model folder path viaos.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 thebuild_modelfunction as demonstrated inthis notebook.DevelopmentInstall and set up development environment.pipinstall-rrequirements_dev.txtThis 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.blackflake8mypypydocstylepylintpytesttoxIt'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 isvscode.Run all tests, check formatting and linting.toxRun a single tox environment.tox-elintReinstall all tox environments.tox-rRun pytest and all tests.pytestRun pytest and calculate coverage for the package.pytest--cov-reportterm-missing--cov=napari-bioimageioContinuous integration is by default supported viaGitHub actions. GitHub actions is free for public repositories and comes with 2000 free Ubuntu build minutes per month for private repositories.