Spaces:
Runtime error
Runtime error
Download ocr/gemini_face_extractor.py from AdityaAKUMAR/OCR_API: direct link, hf CLI and curl.
- Browser
- Download file 620 Bytes
-
https://huggingface.co/spaces/AdityaAKUMAR/OCR_API/resolve/main/ocr/gemini_face_extractor.py
- Command line
-
hf download hf://spaces/AdityaAKUMAR/OCR_API/ocr/gemini_face_extractor.py
-
curl -L -o gemini_face_extractor.py https://huggingface.co/spaces/AdityaAKUMAR/OCR_API/resolve/main/ocr/gemini_face_extractor.py
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"] | |