roboflow / inference

A fast, easy-to-use, production-ready inference server for computer vision supporting deployment of many popular model architectures and fine-tuned models.
https://inference.roboflow.com
Other
1.15k stars 85 forks source link

Fix instance segmentation batching #387

Closed grzegorz-roboflow closed 2 months ago

grzegorz-roboflow commented 2 months ago

Description

Below example results in error:

from typing import List

from inference import get_model
from inference.core.entities.responses.inference import InstanceSegmentationInferenceResponse

model = get_model(model_id="chess-pieces-and-chess-board-instance-segmentation/1")

results: List[InstanceSegmentationInferenceResponse] = model.infer(["20240423_121344.jpg", "20240423_121349.jpg"])

Exception:

Traceback (most recent call last):
  File "/path/to/inference/inference/core/models/instance_segmentation_base.py", line 97, in infer
    return super().infer(
  File "/path/to/inference/inference/core/models/roboflow.py", line 627, in infer
    return super().infer(image, **kwargs)
  File "/path/to/inference/inference/core/models/base.py", line 28, in infer
    postprocessed = self.postprocess(predicted_arrays, returned_metadata, **kwargs)
  File "/path/to/inference/inference/core/models/instance_segmentation_base.py", line 134, in postprocess
    predictions = np.array(predictions)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Type of change

Please delete options that are not relevant.

How has this change been tested, please provide a testcase or example of how you tested the change?

Executed above script with two images where each image is resulting in different number of segmentations and exception is not thrown anymore

Any specific deployment considerations

N/A 20240423_121344 20240423_121349

Docs

N/A