Spaces:
Runtime error
Runtime error
Download app.py from Garimind/GariMindFaceDeep: direct link, hf CLI and curl.
- Browser
- Download file 826 Bytes
-
https://huggingface.co/spaces/Garimind/GariMindFaceDeep/resolve/main/app.py
- Command line
-
hf download hf://spaces/Garimind/GariMindFaceDeep/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Garimind/GariMindFaceDeep/resolve/main/app.py
826 Bytes
| from deepface import DeepFace | |
| import gradio as gr | |
| from PIL import Image | |
| import os | |
| # Nombre de la imagen base | |
| BASE_IMAGE = "usuario_base.jpg" | |
| def verificar(imagen): | |
| try: | |
| if not os.path.exists(BASE_IMAGE): | |
| return {"error": "No se encuentra la imagen base."} | |
| # Comparar imágenes | |
| resultado = DeepFace.verify(img1_path=imagen, img2_path=BASE_IMAGE, enforce_detection=True) | |
| return { | |
| "match": resultado["verified"], | |
| "similarity": round(resultado["distance"], 4), | |
| "model": resultado["model"] | |
| } | |
| except Exception as e: | |
| return {"error": str(e)} | |
| # Interfaz Gradio | |
| iface = gr.Interface( | |
| fn=verificar, | |
| inputs=gr.Image(type="filepath"), | |
| outputs="json", | |
| title="GariMindFace – Verificador Facial" | |
| ) | |
| iface.launch() | |