bioimage-io / spec-bioimage-io

Specification for the bioimage.io model description file.
https://bioimage-io.github.io/spec-bioimage-io/
MIT License
18 stars 17 forks source link

`get_resource_package_content()` given weights priority, downloads the weights #638

Closed thodkatz closed 4 weeks ago

thodkatz commented 1 month ago

Hey hey!

Having this:

from bioimageio.spec import load_description
from bioimageio.spec._package import get_resource_package_content

BIOIMAGEIO_WEIGHTS_PRIORITY = ["torchscript", "pytorch_state_dict", "tensorflow_saved_model_bundle"]
model = 'affable-shark'

rd = load_description(model, perform_io_checks=False)

package_content = get_resource_package_content(rd)

, the rdf expectedly is fetched, and the get_resource_package_content retrieves all the content, including all the available weights format. But the content is not downloaded. They can be retrieved with the download() function provided by spec.

, but if we use the weights priority argument:

from bioimageio.spec import load_description
from bioimageio.spec._package import get_resource_package_content

BIOIMAGEIO_WEIGHTS_PRIORITY = ["torchscript", "pytorch_state_dict", "tensorflow_saved_model_bundle"]
model = 'affable-shark'

rd = load_description(model, perform_io_checks=False)

package_content = get_resource_package_content(rd, weights_priority_order=BIOIMAGEIO_WEIGHTS_PRIORITY)

All the weights are downloaded, and the get_resource_package_content returns only the first available weight provided by BIOIMAGEIO_WEIGHTS_PRIORITY.

I am not sure how we want to utilize the priority feature, but I think the weights shouldn't be downloaded, and the get_resource_package_content should retrieve only the contents with no other side action :)

FynnBe commented 1 month ago

totally! thanks for sharing this bug. I'll make sure that weights_priority_order does not change the behavior to download despite perform_io_checks=False