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