[Bugfix][Frontend] Enforce image pixel limits for video input references (#6963)
Signed-off-by: BANANASJIM <bananasjim1@gmail.com>
This commit is contained in:
1 parent
43b697541a
commit
358b7d79c1
4 files changed
+124
-8
No files matched your search
@@ -161,6 +161,8 @@ from vllm_omni.entrypoints.openai.stores import VIDEO_STORE, VIDEO_TASKS
|
||||
from vllm_omni.entrypoints.openai.utils import get_stage_type, parse_lora_request
|
||||
from vllm_omni.entrypoints.openai.video_api_utils import (
|
||||
VideoFrames,
|
||||
_decode_image_bytes,
|
||||
_validate_image_pixel_limit,
|
||||
decode_audio_url,
|
||||
decode_input_reference,
|
||||
)
|
||||
@@ -3438,6 +3440,15 @@ def _validate_minimax_h3_image_payload(
|
||||
try:
|
||||
with Image.open(io.BytesIO(payload)) as image:
|
||||
image_format = str(image.format or "").lower()
|
||||
if image_format in MINIMAX_H3_REFERENCE_IMAGE_FORMATS:
|
||||
_validate_image_pixel_limit(image)
|
||||
except InvalidInputReferenceError as exc:
|
||||
raise HTTPException(HTTPStatus.BAD_REQUEST.value, detail=str(exc)) from exc
|
||||
except Image.DecompressionBombError as exc:
|
||||
raise HTTPException(
|
||||
HTTPStatus.BAD_REQUEST.value,
|
||||
detail=f"Invalid uploaded image reference: {filename}; image exceeds the decoder pixel limit.",
|
||||
) from exc
|
||||
except (OSError, ValueError) as exc:
|
||||
if allow_non_image:
|
||||
return
|
||||
@@ -3478,10 +3489,14 @@ async def _persist_uploaded_media_references(
|
||||
if kind == "image":
|
||||
try:
|
||||
_validate_minimax_h3_image_payload(payload, filename=upload.filename)
|
||||
with Image.open(io.BytesIO(payload)) as image:
|
||||
images.append(image.convert("RGB"))
|
||||
except (OSError, ValueError) as exc:
|
||||
raise HTTPException(400, detail=f"Invalid uploaded image reference: {upload.filename}") from exc
|
||||
images.append(
|
||||
_decode_image_bytes(
|
||||
payload,
|
||||
source=f"uploaded image reference: {upload.filename}",
|
||||
)
|
||||
)
|
||||
except InvalidInputReferenceError as exc:
|
||||
raise HTTPException(HTTPStatus.BAD_REQUEST.value, detail=str(exc)) from exc
|
||||
continue
|
||||
suffix = Path(upload.filename or "").suffix.lower()
|
||||
if kind == "video" and suffix and suffix not in MINIMAX_H3_REFERENCE_VIDEO_SUFFIXES:
|
||||
|
||||
Reference in new issue
Block a user