Spaces:
Sleeping
Sleeping
Download app.py from Vanessacl/objeto_detection_space: direct link, hf CLI and curl.
- Browser
- Download file 717 Bytes
-
https://huggingface.co/spaces/Vanessacl/objeto_detection_space/resolve/main/app.py
- Command line
-
hf download hf://spaces/Vanessacl/objeto_detection_space/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Vanessacl/objeto_detection_space/resolve/main/app.py
717 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| print("Cargando modelo...") | |
| detector = pipeline("object-detection", model="facebook/detr-resnet-50") | |
| def detect(image): | |
| if image is None: return "Por favor, sube una imagen." | |
| results = detector(image) | |
| output = [] | |
| for res in results: | |
| line = f"✅ {res['label']} (Confianza: {round(res['score'], 2)})" | |
| output.append(line) | |
| return "\n".join(output) if output else "No se detectó nada." | |
| demo = gr.Interface( | |
| fn=detect, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Textbox(), | |
| title="Mi Detector de Objetos IA", | |
| description="Sube una foto para identificar objetos." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |