Spaces:
Sleeping
Sleeping
Kesheratmex commited on
Commit ·
b05e7f0
1
Parent(s): a3cdd41
Add Spanish translations for detection labels
Browse filesAdd a translation dictionary mapping technical terms to Spanish equivalents and update the drawing routine to use these translations when labeling detections. This improves multilingual support and makes the output more user‑friendly for Spanish‑speaking users.
app.py
CHANGED
|
@@ -66,6 +66,39 @@ DETECTION_CATEGORIES = {
|
|
| 66 |
}
|
| 67 |
}
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
def detect_multiple_categories(wrapper, image_path, base_threshold=0.1):
|
| 70 |
"""
|
| 71 |
Realiza detección con AMBOS modelos (OWL-V2 + Grounding DINO) y combina resultados.
|
|
@@ -168,8 +201,11 @@ def draw_categorized_detections(img, categorized_detections):
|
|
| 168 |
# Obtener el nombre específico del objeto detectado
|
| 169 |
label = detection.get("label", "unknown")
|
| 170 |
|
| 171 |
-
#
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
# Fuente más pequeña
|
| 175 |
font_scale = 0.4
|
|
|
|
| 66 |
}
|
| 67 |
}
|
| 68 |
|
| 69 |
+
# Diccionario de traducción de términos técnicos al español
|
| 70 |
+
TRANSLATIONS = {
|
| 71 |
+
# Elementos estructurales
|
| 72 |
+
"bolt": "perno",
|
| 73 |
+
"screw": "tornillo",
|
| 74 |
+
"fastener": "sujetador",
|
| 75 |
+
"tornillo": "tornillo",
|
| 76 |
+
|
| 77 |
+
# Daños
|
| 78 |
+
"damage": "daño",
|
| 79 |
+
"crack": "grieta",
|
| 80 |
+
"break": "rotura",
|
| 81 |
+
"daño": "daño",
|
| 82 |
+
"grieta": "grieta",
|
| 83 |
+
|
| 84 |
+
# Suciedad
|
| 85 |
+
"dirt": "suciedad",
|
| 86 |
+
"stain": "mancha",
|
| 87 |
+
"contamination": "contaminación",
|
| 88 |
+
"suciedad": "suciedad",
|
| 89 |
+
"mancha": "mancha",
|
| 90 |
+
|
| 91 |
+
# Erosión
|
| 92 |
+
"erosion": "erosión",
|
| 93 |
+
"wear": "desgaste",
|
| 94 |
+
"corrosion": "corrosión",
|
| 95 |
+
"erosión": "erosión",
|
| 96 |
+
"desgaste": "desgaste",
|
| 97 |
+
|
| 98 |
+
# Términos generales
|
| 99 |
+
"unknown": "desconocido"
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
def detect_multiple_categories(wrapper, image_path, base_threshold=0.1):
|
| 103 |
"""
|
| 104 |
Realiza detección con AMBOS modelos (OWL-V2 + Grounding DINO) y combina resultados.
|
|
|
|
| 201 |
# Obtener el nombre específico del objeto detectado
|
| 202 |
label = detection.get("label", "unknown")
|
| 203 |
|
| 204 |
+
# Traducir al español
|
| 205 |
+
label_spanish = TRANSLATIONS.get(label, label)
|
| 206 |
+
|
| 207 |
+
# Texto con nombre específico del objeto en español
|
| 208 |
+
text = f"{label_spanish}: {confidence:.2f}"
|
| 209 |
|
| 210 |
# Fuente más pequeña
|
| 211 |
font_scale = 0.4
|