Spaces:
Runtime error
Runtime error
Create app.py
Browse filesInitial commit
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Cargar modelo preentrenado (ej: Detectron2 o YOLO)
|
5 |
+
detector = pipeline("object-detection", model="facebook/detr-resnet-50")
|
6 |
+
|
7 |
+
def detect_waste(image):
|
8 |
+
# Ejecutar detecci贸n de objetos
|
9 |
+
results = detector(image)
|
10 |
+
|
11 |
+
# Formatear resultados: {objeto: confianza}
|
12 |
+
return {result["label"]: float(result["score"]) for result in results}
|
13 |
+
|
14 |
+
# Interfaz Gradio
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=detect_waste,
|
17 |
+
inputs=gr.Image(type="pil", label="Sube una imagen"),
|
18 |
+
outputs=gr.Label(label="Detecciones"),
|
19 |
+
title="Detecci贸n de Desechos S贸lidos",
|
20 |
+
description="Sube una foto para detectar desechos como pl谩stico, vidrio, etc."
|
21 |
+
)
|
22 |
+
|
23 |
+
iface.launch()
|