Skip to content

Bugs when testing pretrained CartoCell BMZ models #22

@pedgomgal1

Description

@pedgomgal1

Hi everyone,

I would like to report several issues I encountered while applying BioImage Model Zoo (BMZ) models in BiaPy. I hope this feedback helps improve the tool further.

First, I had to modify some automatically generated parameters within the .yaml when loading the BMZ models in BiaPy.

  1. Output channels were BC. I had to M as for CartoCell to align with the remaining parameters.

  2. I tried the "venomous-swan" model, and in the .yaml was automatically assigned as:

MODEL:
  BMZ:
    SOURCE_MODEL_ID: venomous-swan (BioImage Model Zoo)

Biapy crashes if I don´t remove manually " (BioImage Model Zoo)" as follows:

MODEL:
  BMZ:
    SOURCE_MODEL_ID: venomous-swan

After applying the two adjustments above, inference starts correctly and runs until the model-building step. At that point, BiaPy crashes with the following error:

100%|██████████| 60/60 [00:07<00:00,  7.58it/s]
100%|██████████| 60/60 [00:07<00:00,  8.32it/s]
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/biapy/engine/base_workflow.py", line 779, in prepare_model
[10:31:14.928383] DATA.TEST.GT_PATH changed from /home/jesus/Escritorio/Pedro/CartoCell/test/y to /home/jesus/Escritorio/Pedro/CartoCell/test/y_F.erosion-0.dilation-0_C.mode-thick_M
[10:31:14.928684] ######################
[10:31:14.928689] #   LOAD TEST DATA   #
[10:31:14.928691] ######################
[10:31:14.928699] ### LOAD ###
[10:31:14.929233] ###############
[10:31:14.929237] # Build model #
    self.bmz_pipeline = create_prediction_pipeline(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bioimageio/core/_prediction_pipeline.py", line 371, in create_prediction_pipeline
[10:31:14.929239] ###############
[10:31:14.929271] The error thrown during the BMZ model load was:
expected v0_4.ModelDescr or v0_5.ModelDescr, but got <class 'bioimageio.spec._internal.common_nodes.InvalidDescr'>
    model_adapter = model_adapter or create_model_adapter(
                                     ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/bioimageio/core/backends/_model_adapter.py", line 86, in create
    raise TypeError(
TypeError: expected v0_4.ModelDescr or v0_5.ModelDescr, but got <class 'bioimageio.spec._internal.common_nodes.InvalidDescr'>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/biapy", line 6, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/biapy/__init__.py", line 141, in main
    _biapy.run_job()
  File "/usr/local/lib/python3.11/dist-packages/biapy/_biapy.py", line 1138, in run_job
    self.test()
  File "/usr/local/lib/python3.11/dist-packages/biapy/_biapy.py", line 260, in test
    self.workflow.test()
  File "/usr/local/lib/python3.11/dist-packages/torch/utils/_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/biapy/engine/base_workflow.py", line 1219, in test
    self.prepare_model()
  File "/usr/local/lib/python3.11/dist-packages/biapy/engine/base_workflow.py", line 786, in prepare_model
    raise ValueError(
ValueError: An error ocurred when creating the BMZ model (see above). BiaPy only supports models prepared with pytorch_state_dict.

This happens during the model creation step, after test data loading and just before inference.

Sorry for the number of issue reports today — it’s been an intense debugging day. I hope this information is useful and helps improve BiaPy even further.

Best wishes,
BW

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions