OCR_API / ocr /gemini_face_extractor.py
AdityaAjithKumar
Added Aadhar Support
2c3822b
Raw
History Blame Contribute Delete
620 Bytes
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"]