Spaces:
Runtime error
Runtime error
File size: 620 Bytes
2c3822b d3bcdcd 2c3822b d3bcdcd 2c3822b d3bcdcd 2c3822b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | from ocr.base import GeminiExtractor
_PROMPT = """
Find the photograph of the person on this card. Get the exact position of the entire photo.
Return JSON:
{
"label": "face_photo",
"box_2d": [ymin, xmin, ymax, xmax]
}
Coordinates must be normalized between 0 and 1000.
Return ONLY JSON.
"""
# Single model; resize=False so returned bbox coordinates match the
# original image dimensions used later in crop_face().
_extractor = GeminiExtractor(_PROMPT, models=["gemini-2.5-flash"], resize=False)
def detect_face(image_bytes: bytes) -> dict:
result = _extractor.extract(image_bytes)
return result["data"]
|