Spaces:
Sleeping
Sleeping
Daniel Avila Rey commited on
Commit ·
0eaf332
1
Parent(s): 02c4595
Fix Label Name
Browse files
app.py
CHANGED
|
@@ -27,8 +27,12 @@ def detect_objects(image):
|
|
| 27 |
|
| 28 |
# Mostrar los objetos detectados
|
| 29 |
detected_objects = []
|
|
|
|
| 30 |
for score, label, box in zip(scores, labels, boxes):
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
return "\n".join(detected_objects)
|
| 34 |
|
|
|
|
| 27 |
|
| 28 |
# Mostrar los objetos detectados
|
| 29 |
detected_objects = []
|
| 30 |
+
id2label = model.config.id2label # Diccionario ID -> Nombre
|
| 31 |
for score, label, box in zip(scores, labels, boxes):
|
| 32 |
+
label_name = id2label[int(label)]
|
| 33 |
+
detected_objects.append(
|
| 34 |
+
f"Objeto: {label_name}, Score: {score:.2f}, Box: {box.tolist()}"
|
| 35 |
+
)
|
| 36 |
|
| 37 |
return "\n".join(detected_objects)
|
| 38 |
|