Invalid model description from rdf on model zoo
I am trying to load a model from the model zoo. Steps: Approach 1
-
pip install bioimageio.core>=0.7 - I went to download this model
- I downloaded the rdf as
nuclei.yaml - I ran this code snippet:
from bioimageio.core import load_description_and_test
from bioimageio.spec import InvalidDescr
model_id = "nuclei.yaml"
model_description = load_description_and_test(model_id)
if isinstance(model_description, InvalidDescr):
raise Exception("Invalid model description")
- I got this error:
Traceback (most recent call last):
File "/Users/pattonw/Work/Packages/dacapo/scratch/scratch3.py", line 10, in <module>
model_description = load_description_and_test(model_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pattonw/Work/Packages/dacapo/.venv/lib/python3.11/site-packages/bioimageio/core/_resource_tests.py", line 174, in load_description_and_test
rd = load_description(source, format_version=format_version)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pattonw/Work/Packages/dacapo/.venv/lib/python3.11/site-packages/bioimageio/spec/_io.py", line 58, in load_description
opened = open_bioimageio_yaml(source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pattonw/Work/Packages/dacapo/.venv/lib/python3.11/site-packages/bioimageio/spec/_internal/io_utils.py", line 107, in open_bioimageio_yaml
downloaded = download(source, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pattonw/Work/Packages/dacapo/.venv/lib/python3.11/site-packages/bioimageio/spec/_internal/io.py", line 675, in resolve
strict_source = interprete_file_source(source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pattonw/Work/Packages/dacapo/.venv/lib/python3.11/site-packages/bioimageio/spec/_internal/io.py", line 555, in interprete_file_source
strict = _file_source_adapter.validate_python(file_source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pattonw/Work/Packages/dacapo/.venv/lib/python3.11/site-packages/pydantic/type_adapter.py", line 412, in validate_python
return self.validator.validate_python(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 3 validation errors for union[function-after[HttpUrl(), str],RelativeFilePath,function-after[validate_file(), lax-or-strict[lax=union[json-or-python[json=function-after[path_validator(), str],python=is-instance[Path]],function-after[path_validator(), str]],strict=json-or-python[json=function-after[path_validator(), str],python=is-instance[Path]]]]]
function-after[HttpUrl(), str]
Input should be a valid URL, input is empty [type=url_parsing, input_value='', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/url_parsing
RelativeFilePath
Value error, . is not a valid file path. [type=value_error, input_value='', input_type=str]
For further information visit https://errors.pydantic.dev/2.10/v/value_error
function-after[validate_file(), lax-or-strict[lax=union[json-or-python[json=function-after[path_validator(), str],python=is-instance[Path]],function-after[path_validator(), str]],strict=json-or-python[json=function-after[path_validator(), str],python=is-instance[Path]]]]
Path does not point to a file [type=path_not_file, input_value='', input_type=str]
- I reinstalled via
pip install git+https://github.com/bioimage-io/core-bioimage-io-python, tried again and gotException: Invalid model Description
Downloading the zip and using the model name "affable-shark" both seem to work and provide valid descriptions.
Is this a bug in bioimageio.core, a bug in the downloaded rdf, or a user error?
The rdf.yaml file contains relative paths that are resolved relative to its location (e.g. a documentation: README.md inside https://example.com/rdf.yaml is resolved to https://example.com/README.md.
This is why when downloading via bioimage.io a zip file is downloaded containing all essential files (and maybe additional URLs as references for citation etc).
Furthermore we only support a limited pattern of file names as rdf.yaml files:
rdf.yaml or bioimageio.yaml or any file name ending with .rdf.yaml or .bioimageio.yaml
- I went and downloaded...
For the sake of improving our documentation in the right places it would be great to know how you downloaded only the rdf.yaml file. (URL taken from the collection.json? Copied from the RDF's source view on bioimage.io?)
To conclude, your options that should work are:
>>> from bioimageio.spec import InvalidDescr, load_description
>>>
>>> sources = (
... "affable-shark", # (resolves to latest version)
... "affable-shark/1", # (version specific bioimage.io identifier)
... "10.5281/zenodo.11092561", # concept doi of zenodo backup (='affable-shark')
... "10.5281/zenodo.11092562", # record doi of zenodo backup (='affable-shark/1')
... "10.5281/zenodo.5764892", # legacy id from our previous implementation (='affable-shark')
... #
... # (version specific, not recommended as it relies on the particular S3 server we are currently using)
... "https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/1.1/files/rdf.yaml",
... )
>>>
>>> other_example_sources = (
... "https://example.com/local_package.zip", # broken in current, latest release (we also do not provide static zip file URLs at the moment)
... #
... # manual download -> loading from a local source
... "local_package.zip", # broken in current, latest release
... "local_folder", # assuming this folder has an `rdf.yaml`, `*.rdf.yaml`, `bioimageio.yaml` or `*.bioimageio.yaml` file inside.
... "rdf.yaml", # or `*.rdf.yaml`, `bioimageio.yaml` or `*.bioimageio.yaml`
... # note: Any relative paths inside `rdf.yaml` need to be available from the parent folder of the rdf.yaml
... )
>>>
>>> for src in sources:
... descr = load_description(src)
... assert not isinstance(descr, InvalidDescr)
2025-... INFO ... loading affable-shark from https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/1.1/files/rdf.yaml
2025-... INFO ... loading affable-shark/1 from https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/1/files/rdf.yaml
2025-... INFO ... loading 10.5281/zenodo.11092561 from https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/1.1/files/rdf.yaml
2025-... INFO ... loading 10.5281/zenodo.11092562 from https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/1/files/rdf.yaml
2025-... INFO ... loading 10.5281/zenodo.5764892 from https://uk1s3.embassy.ebi.ac.uk/public-datasets/bioimage.io/affable-shark/1.1/files/rdf.yaml
Ah, ok. Thanks for the info. This makes a lot of sense. I didn't realize the rdf contained only relative paths.
As for how I got the rdf: I just clicked on the model I wanted: affable-shark, hit the little download button, and clicked the first link source RDF file
I was given the default name of "rdf.yaml" but I was testing a few different models so I renamed it to "nuclei.yaml" for my convenience not realizing that the name was important.