tensorflow/models · error · ImageReadError
OpenCV could not read the image at {image_path!s}. The file
Error message
OpenCV could not read the image at {image_path!s}. The file may be missing, corrupt, or in an unsupported format. What it means
Error "OpenCV could not read the image at {image_path!s}. The file may be missing, corrupt, or in an unsupported format." thrown in tensorflow/models.
Source
Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/image_ops.py:60
implementation. The two implementations are not bit-identical (PIL and
OpenCV use slightly different Lanczos filter parameters) but are visually
equivalent and produce nearly identical downstream detections.
Args:
image_path: Path to the image file on disk.
max_short_side: Maximum allowed length of the shortest side. If the image is
larger, it is downscaled preserving aspect ratio.
Returns:
The loaded and (optionally) resized image as a PIL RGB Image.
Raises:
ImageReadError: If OpenCV is unable to decode the file (missing, corrupt,
or unsupported format).
"""
bgr_image = cv2.imread(str(image_path))
if bgr_image is None:
raise ImageReadError(
f"OpenCV could not read the image at {image_path!s}. The file may be "
"missing, corrupt, or in an unsupported format."
)
height, width = bgr_image.shape[:2]
new_width, new_height = _compute_resized_dimensions(
width=width, height=height, max_short_side=max_short_side
)
if (new_width, new_height) != (width, height):
bgr_resized = cv2.resize(
bgr_image,
(new_width, new_height),
interpolation=cv2.INTER_LANCZOS4,
)
else:
bgr_resized = bgr_image
rgb_resized = cv2.cvtColor(bgr_resized, cv2.COLOR_BGR2RGB)
return Image.fromarray(rgb_resized)
View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/image_ops.py:60 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/d5ba98c182ab2820.
Report an issue: GitHub.