Skip to content

New predict command: tiled prediction not working for model v0.4 #415

@constantinpape

Description

@constantinpape

Tiled prediction seems to not be implemented for v0.4 models:

import bioimageio.core
import imageio.v3 as imageio
from xarray import DataArray

from bioimageio.spec.model.v0_5 import AxisId

image = imageio.imread("/home/pape/.cache/micro_sam/sample_data/livecell-2d-image.png")
model = bioimageio.core.load_description("hiding-tiger")
model.inputs[0].data_type = "float32"

input_descr = model.inputs[0]
# this still does not work for me! (It would be great to fix it)
# inputs = {input_descr.name: DataArray(image[None, None], dims=tuple(input_descr.axes))}
inputs = {input_descr.name: DataArray(image[None, None], dims=("batch", "channel", "y", "x"))}

# tile_shape = {"y": 512, "x": 512}
tile_shape = {input_descr.name: {AxisId("x"): 512, AxisId("y"): 512}}
pred = bioimageio.core.predict(model=model, inputs=inputs, input_block_shape=tile_shape)

fails with

Traceback (most recent call last):
  File "/home/pape/Work/playground/bioimageio/new-pred/check_new_pred.py", line 18, in <module>
    pred = bioimageio.core.predict(model=model, inputs=inputs, input_block_shape=tile_shape)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pape/Work/bioimageio/core-bioimage-io-python/bioimageio/core/prediction.py", line 100, in predict
    output = pp.predict_sample_with_fixed_blocking(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pape/Work/bioimageio/core-bioimage-io-python/bioimageio/core/_prediction_pipeline.py", line 208, in predict_sample_with_fixed_blocking
    self.predict_sample_block(
  File "/home/pape/Work/bioimageio/core-bioimage-io-python/bioimageio/core/_prediction_pipeline.py", line 114, in predict_sample_block
    raise NotImplementedError(
NotImplementedError: predict_sample_block not implemented for model 0.4.10

Metadata

Metadata

Assignees

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