huggingface/transformers · error · ValueError
Unsupported input type {type(bboxes_center)}
Error message
Unsupported input type {type(bboxes_center)} What it means
center_to_corners_format dispatches on input type: torch tensors go to the torch kernel, numpy arrays to the numpy kernel; anything else (lists, tuples) raises ValueError. Used in detection forward passes, so it avoids silent device round-trips by refusing unknown types.
Source
Thrown at src/transformers/image_transforms.py:565
# 2 functions below inspired by https://github.com/facebookresearch/detr/blob/master/util/box_ops.py
def center_to_corners_format(bboxes_center: TensorType) -> TensorType:
"""
Converts bounding boxes from center format to corners format.
center format: contains the coordinate for the center of the box and its width, height dimensions
(center_x, center_y, width, height)
corners format: contains the coordinates for the top-left and bottom-right corners of the box
(top_left_x, top_left_y, bottom_right_x, bottom_right_y)
"""
# Function is used during model forward pass, so we use torch if relevant, without converting to numpy
if is_torch_tensor(bboxes_center):
return _center_to_corners_format_torch(bboxes_center)
elif isinstance(bboxes_center, np.ndarray):
return _center_to_corners_format_numpy(bboxes_center)
raise ValueError(f"Unsupported input type {type(bboxes_center)}")
def _corners_to_center_format_torch(bboxes_corners: "torch.Tensor") -> "torch.Tensor":
top_left_x, top_left_y, bottom_right_x, bottom_right_y = bboxes_corners.unbind(-1)
b = [
(top_left_x + bottom_right_x) / 2, # center x
(top_left_y + bottom_right_y) / 2, # center y
(bottom_right_x - top_left_x), # width
(bottom_right_y - top_left_y), # height
]
return torch.stack(b, dim=-1)
def _corners_to_center_format_numpy(bboxes_corners: np.ndarray) -> np.ndarray:
top_left_x, top_left_y, bottom_right_x, bottom_right_y = bboxes_corners.T
bboxes_center = np.stack(
[
(top_left_x + bottom_right_x) / 2, # center xView on GitHub (pinned to a597f97485)
Solutions
- Convert lists to np.ndarray: np.asarray(boxes).
- Keep boxes as whatever your framework kernel produced (torch tensors stay torch).
- Ensure shape is (..., 4) center format before converting.
Example fix
# before corners = center_to_corners_format([[50.0, 50.0, 100.0, 100.0]]) # raises # after import numpy as np corners = center_to_corners_format(np.array([[50.0, 50.0, 100.0, 100.0]]))
Defensive patterns
Strategy: type-guard
Validate before calling
import numpy as np
if not (is_torch_tensor(bboxes_center) or isinstance(bboxes_center, np.ndarray)):
bboxes_center = np.asarray(bboxes_center, dtype=float)
assert bboxes_center.shape[-1] == 4 Type guard
def is_supported_boxes(x) -> bool:
import numpy as np
from transformers.utils import is_torch_tensor
return is_torch_tensor(x) or isinstance(x, np.ndarray) Prevention
- Convert JSON/list boxes to np.asarray at ingestion.
- Keep boxes in the tensor type your postprocessing kernel emits.
When it happens
Trigger: center_to_corners_format([[50, 50, 100, 100]]) with a plain Python list, or passing a tf.Tensor / jax array.
Common situations: Feeding model outputs or config values that are plain lists into detection postprocessing (e.g. post_process_object_detection outputs are fine, but hand-built boxes are not), or mixing frameworks.
Related errors
- Unsupported input type {type(bboxes_corners)}
- `axis_value` for `HQQ` backend has to be one of [`0`, `1`] b
- You can construct a Cache either from a list `layers` of all
- You should provide exactly one of `layers` or `layer_class_t
- Cannot call `update_conv_state` on a non-LinearAttention lay
AI-assisted analysis of huggingface/transformers@a597f97485 (2026-08-14).
Data as JSON: /api/errors/e5e251089be0990b.
Report an issue: GitHub.