Package: napari-czann-segment
napari-czann-segmentSemantic Segmentation of multidimensional images using Deep Learning ONNX models packaged as *.czann files.Thisnapariplugin was generated withCookiecutterusing@napari'scookiecutter-napari-plugintemplate.InstallationBefore installing, please setup a conda environment. If you have never worked with conda environments, go throughthis tutorialfirst.You can then installnapari-czann-segmentviapip:pip install napari-czann-segmentWhat does the plugin doThe plugin allows you to:Use a *.czann file containing the Deep Neural Network (ONNX) for semantic segmentation and metadataSegmentation will be applied per 2D plane for all dimensionsProcessing larger multidimensional images it uses thecztilepackage to chunk the individual 2d arrays using a specific overlap.multidimensional images will be processed plane-by-planeWhat does the plugin NOT doBefore one can actually use a model it needs to be trained, which is NOT done by this plugin.There are two main ways hwo such a model can be created:Train the segmentation model fully automated onAPEERand download the *.czann fileTrain your model in a Jupyter notebook etc. and package it using theczmodelpython package as an *.czannUsing this pluginSample DataA test image and a *.czann model file can be downloadedhere.PGC_20X.ome.tiff--> usePGC_20X_nucleus_detector.czannto segmentIn order to use this plugin the user has to do the following things:Open the image using "File - Open Files(s)" (requiresnapari-aicsimageioplugin).Clicknapari-czann-segment: Segment with CZANN modelin the "Plugins" menu.Select a czann fileto use the model for segmentation.metadata of the model will be shown (see example below)ParameterValueExplanationmodel_typeModelType.SINGLE_CLASS_SEMANTIC_SEGMENTATIONsee:czmodelfor detailsinput_shape[1024, 1024, 1]tile dimensions of model inputoutput_shape[1024, 1024, 3]tile dimensions of model outputmodel_idba32bc6d-6bc9-4774-8b47-20646c7cb838unique GUID for that modelmin_overlap[128, 128]tile overlap used during training (for this model)classes['background', 'grains', 'inclusions']available classesmodel_nameAPEER-trained modelname of the modelAdjust theminimum overlapfor the tiling (optional, seecztilefor details).Select thelayerto be segmented.ToggleUse GPU for inferencecheckbox to enable / disable using a GPU (Nvidia) for the segmentation (experimental feature).PressSegment Selected Image Layerto run the segmentation.A successful is obviously only the starting point for further image analysis steps to extract the desired numbers from the segmented image.
Another example is shown below demonstrating a simple "Grain Size Analysis" using a deep-learning model trained onAPEERused innapariRemarksIMPORTANT: Currently the plugin only supports using models trained on asingle channelimage. Therefore, make sure that during the training onAPEERor somewhere else the correct inputs images are used.
It is quite simple to train a single RGB image, which actually has three channels, load this image innapariand notice only then that the model will not work, because the image will 3 channels insidenapari.Only the CPU will be used for the inference using the ONNX runtime for theONNX-CPUruntimeGPUs are supported but require theONNX-GPUruntime and the respective CUDA libraries.Please check theYAMLfor an example environment with GPU support.See alsopytorchfor instruction on how to install pytorchFor developersPlease clone this repository first using your favorite tool.Ideally one creates a newcondaenvironment or use an existing environment that already containsNapari.Feel free to create a new environment using theYAMLfile at your own risk:cd the-github-repo-with-YAML-file
conda env create --file conda_env_napari_czann_segment.yml
conda activate napari_czmodelInstall the plugin locallyPlease run the following command:pip install -e .To install latest development version:pip install git+https://github.com/sebi06/napari_czann_segment.gitContributingContributions and Feedback are very welcome.LicenseDistributed under the terms of theBSD-3license,
"napari-czann-segment" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.