Export CPnet to BioImage.IO Model Zoo#988
Conversation
Removed unnecessary packages. Now BioImage.IO can test Cellpose models with resnet_torch.py without Cellpose installed
`transform.convert_image()` no longer normalises the input.
`model_id` and `model_icon` should be `None` for new models
|
thank you! |
|
Hi @qin-yu, could you please write a short blurb in our readthedocs describing how to export a model to bioimage.io? I think it would make sense here: https://github.com/MouseLand/cellpose/blob/main/docs/models.rst#user-trained-models. I can also do this but I think you're the expert here, thanks so much for adding this to cellpose |
Sure! I'll let you know once it's done. |
|
Hi @qin-yu , can we move the overwriting of load_state_dict into your subclass ( cellpose/cellpose/resnet_torch.py Line 279 in 729b701 |
If we restore the old |
Hi @carsen-stringer!
I made a "export" module for Cellpose. Please have a look! This PR attempts to close #956 and provides an
export.pymodule with a CLI interface to facilitate users to upload their custom Cellpose models (CPnets) to Bioimage.IO Model Zoo.Usage
To install the dependencies:
CLI interface:
$ python export.py --help usage: export.py [-h] [--channels CHANNELS CHANNELS] --path_pretrained_model PATH_PRETRAINED_MODEL --path_readme PATH_README --list_path_cover_images LIST_PATH_COVER_IMAGES [LIST_PATH_COVER_IMAGES ...] [--model_id MODEL_ID] [--model_icon MODEL_ICON] --model_version MODEL_VERSION --model_name MODEL_NAME --model_documentation MODEL_DOCUMENTATION --model_authors MODEL_AUTHORS --model_cite MODEL_CITE --model_tags MODEL_TAGS [MODEL_TAGS ...] --model_license MODEL_LICENSE --model_repo MODEL_REPO BioImage.IO model packaging for Cellpose optional arguments: -h, --help show this help message and exit --channels CHANNELS CHANNELS Cyto-only = [2, 0], Cyto + Nuclei = [2, 1], Nuclei-only = [1, 0] --path_pretrained_model PATH_PRETRAINED_MODEL Path to pretrained model file, e.g., cellpose_residual_on_style_on_concatenation_off_1135_rest_2023_05_04_23_41_31.252995 --path_readme PATH_README Path to README file --list_path_cover_images LIST_PATH_COVER_IMAGES [LIST_PATH_COVER_IMAGES ...] List of paths to cover images --model_id MODEL_ID Model ID, provide if already exists --model_icon MODEL_ICON Model icon, provide if already exists --model_version MODEL_VERSION Model version, new model should be 0.1.0 --model_name MODEL_NAME Model name, e.g., My Cool Cellpose --model_documentation MODEL_DOCUMENTATION Model documentation, e.g., A cool Cellpose model trained for my cool dataset. --model_authors MODEL_AUTHORS Model authors in JSON format, e.g., '[{"name": "Qin Yu", "affiliation": "EMBL", "github_user": "qin-yu", "orcid": "0000-0002-4652-0795"}]' --model_cite MODEL_CITE Model citation in JSON format, e.g., '[{"text": "For more details of the model itself, see the manuscript", "doi": "10.1101/2024.02.19.580954", "url": null}]' --model_tags MODEL_TAGS [MODEL_TAGS ...] Model tags, e.g., cellpose 3d 2d --model_license MODEL_LICENSE Model license, e.g., MIT --model_repo MODEL_REPO Model repository URLThis creates a bioimage.io package in a new directory
models/MODEL_NAME/cellpose_model.zipwhich can be uploaded via https://bioimageio-uploader.netlify.app/#/uploader/addDetails
CPnetclass pass tests frombioimageio.core, one small refactor of.load_model()method was made, which only includes formal changes but keeps the semantics.CPnetBioImageIOunpacks the nested output fromCPnetand make it compatible tobioimageio.spectest_inputfor all Cellpose models