File size: 717 Bytes
59a35fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27

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()