Open constantinpape opened 3 months ago
Yes, blocking is not implemented for model 0.4.
I think it'll be best to update all relevant models in the model zoo instead of making this backwards compatible.
many models, like hiding-tiger can be converted automatically, so when we use format_version="latest"
or format_version="0.5"
it works as is:
import collections.abc
from typing import Any
import imageio.v3 as imageio
from xarray import DataArray
import bioimageio.core
import bioimageio.spec
from bioimageio.spec.model.v0_5 import AxisId, NDArray
model = bioimageio.core.load_model("hiding-tiger", format_version="0.5")
assert isinstance(model, bioimageio.spec.model.v0_5.ModelDescr)
assert not isinstance(model.inputs[0].data, collections.abc.Sequence)
# input data type should be float32 now (after updating hiding-tiger to version 1.1)
print(model.inputs[0].data.type)
input_descr = model.inputs[0]
image: NDArray[Any] = imageio.imread(
"/home/pape/.cache/micro_sam/sample_data/livecell-2d-image.png"
)
# this still does not work for me! (It would be great to fix it)
# inputs = {input_descr.id: DataArray(image[None, None], dims=tuple(input_descr.axes))}
# -> fix:
inputs = {
input_descr.id: DataArray(
image[None, None],
dims=tuple(a.id for a in input_descr.axes), # use id of every axis
)
}
# alternative:
# inputs = bioimageio.core.digest_spec.load_sample_for_model(
# model=model,
# paths={model.inputs[0].id: Path("image path")},
# )
# tile_shape = {"y": 512, "x": 512}
tile_shape = {input_descr.id: {AxisId("x"): 512, AxisId("y"): 512}}
pred = bioimageio.core.predict(model=model, inputs=inputs, input_block_shape=tile_shape)
The model conversion does not work for me (which is a separate issue tied to the changes you made for this model, see message in the chat)
The model conversion does not work for me (which is a separate issue tied to the changes you made for this model, see message in the chat)
fixed
Tiled prediction seems to not be implemented for v0.4 models:
fails with