diff --git a/src/main.py b/src/main.py index f0ca8b0..036b263 100644 --- a/src/main.py +++ b/src/main.py @@ -361,6 +361,11 @@ async def detect_image( orig_name = file.filename or "upload" kind, ext = _detect_upload_kind(orig_name, image_bytes) + if kind == "image": + arr = np.frombuffer(image_bytes, dtype=np.uint8) + if cv2.imdecode(arr, cv2.IMREAD_COLOR) is None: + raise HTTPException(status_code=400, detail="Invalid image data") + config_dict = {} if config: config_dict = json.loads(config)