Skip to content

Optional inputs not working #386

@constantinpape

Description

@constantinpape

It seems that optional inputs are not working. See the example for running a SAM model with only box prompts below:

import bioimageio.core
import numpy as np

from bioimageio.core.digest_spec import create_sample_for_model
from bioimageio.spec.utils import download

model_description = bioimageio.core.load_description("diplomatic-bug/staged/1")

image = np.load(download(model_description.inputs[0].test_tensor).path)
embeddings = np.load(download(model_description.inputs[5].test_tensor).path)
box_prompts = np.load(download(model_description.inputs[1].test_tensor).path)

sample = create_sample_for_model(
    model=model_description, image=image, embeddings=embeddings, box_prompts=box_prompts
).as_single_block()
with bioimageio.core.create_prediction_pipeline(model_description) as pp:
    prediction = pp.predict_sample_block(sample)

This fails with:

Traceback (most recent call last):
  File "/home/pape/Work/my_projects/micro-sam/bio_mre.py", line 17, in <module>
    prediction = pp.predict_sample_block(sample)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pape/Work/bioimageio/core-bioimage-io-python/bioimageio/core/_prediction_pipeline.py", line 121, in predict_sample_block
    self.apply_preprocessing(sample_block)
  File "/home/pape/Work/bioimageio/core-bioimage-io-python/bioimageio/core/_prediction_pipeline.py", line 271, in apply_preprocessing
    op(sample)
  File "/home/pape/Work/bioimageio/core-bioimage-io-python/bioimageio/core/proc_ops.py", line 76, in __call__
    input_tensor = sample.members[self.input]
                   ~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'point_prompts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions