roboflow/supervision · error · ValueError
Unsupported interpolation mode: {interpolation}
Error message
Unsupported interpolation mode: {interpolation} What it means
The fallback resize implements only two interpolation modes: INTER_NEAREST (index-based gather) and INTER_LINEAR (Pillow bilinear or NumPy affine sampling). Any other cv2 interpolation constant (INTER_CUBIC, INTER_AREA, INTER_LANCZOS4, etc.) is rejected rather than silently approximated.
Source
Thrown at src/supervision/_cv2/_image.py:157
source_height, source_width = src.shape[:2]
width, height = dsize if dsize is not None else (0, 0)
if width == 0 or height == 0:
width = round(source_width * fx)
height = round(source_height * fy)
if min(width, height, source_width, source_height) <= 0:
raise ValueError("Resize dimensions must be positive")
if interpolation == _INTER_NEAREST:
y_indices = np.minimum(
(np.arange(height) * source_height // height), source_height - 1
)
x_indices = np.minimum(
(np.arange(width) * source_width // width), source_width - 1
)
return np.ascontiguousarray(src[y_indices[:, np.newaxis], x_indices])
if interpolation != _INTER_LINEAR:
raise ValueError(f"Unsupported interpolation mode: {interpolation}")
if src.dtype == np.uint8 and (
src.ndim == 2 or (src.ndim == 3 and src.shape[2] == 3)
):
from PIL import Image
size = (width, height)
image = Image.fromarray(src)
if width >= source_width and height >= source_height:
resized = image.resize(size, resample=Image.Resampling.BILINEAR)
else:
# Affine sampling keeps Pillow from widening its bilinear kernel
# during reduction and maps pixel centers like INTER_LINEAR.
resized = image.transform(
size,
Image.Transform.AFFINE,
(source_width / width, 0, 0, 0, source_height / height, 0),
resample=Image.Resampling.BILINEAR,View on GitHub (pinned to 7f254d9784)
Solutions
- Use cv2.INTER_LINEAR or cv2.INTER_NEAREST, the two supported modes.
- Install opencv-python (or opencv-python-headless) so Supervision delegates to real cv2 and all modes work.
- If you need another kernel, pre-resize with PIL/scipy yourself and skip the fallback path.
Example fix
# before small = cv2.resize(frame, (w, h), interpolation=cv2.INTER_AREA) # after (fallback-compatible) small = cv2.resize(frame, (w, h), interpolation=cv2.INTER_LINEAR)
Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED = {cv2.INTER_NEAREST, cv2.INTER_LINEAR}
interp = interp if interp in SUPPORTED else cv2.INTER_LINEAR
resized = cv2.resize(frame, (w, h), interpolation=interp) Prevention
- Restrict resize calls to INTER_NEAREST/INTER_LINEAR in fallback environments
- Install opencv-python when other kernels are required
- Document the two-mode limitation in code that must run cv2-free
When it happens
Trigger: Calling cv2.resize(..., interpolation=cv2.INTER_AREA) or INTER_CUBIC/INTER_LANCZOS4/INTER_NEAREST_EXACT etc. while running on the Supervision OpenCV fallback.
Common situations: Code written against real OpenCV that uses INTER_AREA for downscaling (a common high-quality shrink idiom) or INTER_CUBIC for upscaling, then executed in an environment where opencv-python is not installed (slim Docker images, CI without cv2).
Related errors
- Resize dimensions must be positive
- PyAV fallback supports file paths, not webcam device indexes
- addWeighted inputs must have equal shapes
- Mean mask must match the image height and width
- Unsupported flip code: {flip_code}
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/9e31c0ed9d98aeac.
Report an issue: GitHub.