Fix focus endpoint crash
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -91,7 +90,7 @@ def detect_face(image: np.ndarray) -> BBox | None:
|
||||
faces = FACE_CASCADE.detectMultiScale(gray, scaleFactor=1.08, minNeighbors=5, minSize=(24, 24))
|
||||
if len(faces) == 0:
|
||||
return None
|
||||
x, y, w, h = max((map(int, face) for face in faces), key=lambda rect: rect[2] * rect[3])
|
||||
x, y, w, h = max((tuple(map(int, face)) for face in faces), key=lambda rect: rect[2] * rect[3])
|
||||
return BBox(x=x, y=y, w=w, h=h)
|
||||
|
||||
|
||||
@@ -192,5 +191,5 @@ def process_image(image_bytes: bytes, filename: str, buffer_ratio: float = 0.15,
|
||||
"crop_data_url": _data_url(crop_bytes, mime_type),
|
||||
"annotated_data_url": _data_url(annotated_bytes, mime_type),
|
||||
"mime_type": mime_type,
|
||||
"crop_bytes_io": BytesIO(crop_bytes),
|
||||
"crop_bytes": crop_bytes,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user