Skip to content

XVI. Bioimage.io I (spec)

carlosuc3m edited this page Sep 13, 2023 · 1 revision

JDLL was first developed to load models from the Bioimage.io in the Icy Bioimaging software and although it evolved into a library that can be used to build more general software, it is still tightly integrated and linked to the Bioimage.io.

The thigh integration with the Bioimage.io model repo allows retrieving the models available there and their information and specifications, an easy download of Bioimage.io models, an easy load of Bioimage.io models and methods to retrieve the specifications of the Bioimage.io models.

Rdf.yaml file in JDLL

The Bioimage.io rdf.yaml file is the key component that enables reproducibility and portability to the Bioimage.io models. It contains important information ranging from authorship and licensing to technical details that allow reloading the model.

Retrieving the infomormation contained in it is very important, this is why JDLL contains several tools for it, in orde to handle the internal connection with the Bioiamge.io but also to allow the user to have an easy access to the specs of the model.

The JDLL object used to manage the information of the rdf.yaml file is the ModelDescriptor. The rdf.yaml file can be read both from a local path and from an URL.

To create a ModelDescriptor object from a local rdf.yaml file:

String rdfPath = "/path/to/model/rdf.yaml":
boolean verbose = false;
// Create the model descriptor
ModelDescriptor descriptor = ModelDescriptor.readFromLocalFile(rdfPath , verbose);

To retrieve the information of an online model and create the ModelDescriptor object from a web resource:

String rdfSource = "https://bioimage-io.github.io/collection-bioimage-io/rdfs/10.5281/zenodo.5874741/5874742/rdf.yaml";
ModelDescriptor descriptor = BioimageioRepo.retreiveDescriptorFromURL(rdfSource);

Note that the URL provided needs to be a valid URL and that it should point to a raw file that only contains a model rdf.yaml file. These URLs correspond to the field rdf_source in the rdf.yaml file of a model.

Once a ModelDescriptor is created, all the fields and information can be retrieved using getters: descriptor.getWeights(), descriptor.getName()...

For more information, please read the next sections.

Retrieving information about available Bioimage.io models

The Bioimage.io repo is an active repo where models are constantly being added. In order to follow the changes, improvements and additions to it, JDLL is able to dinamically load the online information about the models.

The following code 'connects' to the Bioimage.io repo and retrieves all the models with their information:

BioimageioRepo br = BioimageioRepo.connect();
Map<Path, ModelDescriptor> infoMap = br.listAllModels();

where infoMap contains the path to the url of the rdf.yaml file of a model as the key and a ModelDescriptor instance containing all the info in the rdf.yaml file as the value. The map contains all the models available in the Bioimage.io repo.