Spaces:
Sleeping
Sleeping
Mr-HASSAN
commited on
Commit
·
b239850
1
Parent(s):
ef9a68f
Add Arabic character mapping for proper letter display
Browse files- Added ARABIC_MAP dictionary to convert English class names to Arabic characters
- Detector now returns proper Arabic letters (ا ب ت...) instead of English names (aleff, bb, ta...)
- Letters displayed correctly in Arabic throughout the UI
- Supports all 32 Arabic sign language letters including special combinations (لا, ال)
- utils/detector.py +40 -2
utils/detector.py
CHANGED
|
@@ -6,6 +6,42 @@ from typing import Dict, List, Any
|
|
| 6 |
import os
|
| 7 |
import gc
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
class ArabicSignDetector:
|
| 10 |
def __init__(self, model_path: str = None):
|
| 11 |
print("🔄 Initializing ArabicSignDetector...")
|
|
@@ -104,10 +140,12 @@ class ArabicSignDetector:
|
|
| 104 |
for i in range(len(boxes.cls)):
|
| 105 |
class_id = int(boxes.cls[i])
|
| 106 |
confidence = float(boxes.conf[i])
|
| 107 |
-
|
| 108 |
|
| 109 |
if confidence > self.confidence_threshold:
|
| 110 |
-
|
|
|
|
|
|
|
| 111 |
confidences.append(confidence)
|
| 112 |
|
| 113 |
# Clear GPU memory after inference
|
|
|
|
| 6 |
import os
|
| 7 |
import gc
|
| 8 |
|
| 9 |
+
# Arabic letter mapping from English class names to Arabic characters
|
| 10 |
+
ARABIC_MAP = {
|
| 11 |
+
"aleff": "ا",
|
| 12 |
+
"bb": "ب",
|
| 13 |
+
"ta": "ت",
|
| 14 |
+
"thaa": "ث",
|
| 15 |
+
"jeem": "ج",
|
| 16 |
+
"haa": "ح",
|
| 17 |
+
"khaa": "خ",
|
| 18 |
+
"dal": "د",
|
| 19 |
+
"thal": "ذ",
|
| 20 |
+
"ra": "ر",
|
| 21 |
+
"zay": "ز",
|
| 22 |
+
"seen": "س",
|
| 23 |
+
"sheen": "ش",
|
| 24 |
+
"saad": "ص",
|
| 25 |
+
"dhad": "ض",
|
| 26 |
+
"taa": "ط",
|
| 27 |
+
"dha": "ظ",
|
| 28 |
+
"ain": "ع",
|
| 29 |
+
"ghain": "غ",
|
| 30 |
+
"fa": "ف",
|
| 31 |
+
"gaaf": "ق",
|
| 32 |
+
"kaaf": "ك",
|
| 33 |
+
"laam": "ل",
|
| 34 |
+
"la": "لا",
|
| 35 |
+
"meem": "م",
|
| 36 |
+
"nun": "ن",
|
| 37 |
+
"ha": "ه",
|
| 38 |
+
"waw": "و",
|
| 39 |
+
"ya": "ي",
|
| 40 |
+
"yaa": "ي",
|
| 41 |
+
"toot": "ة",
|
| 42 |
+
"al": "ال"
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
class ArabicSignDetector:
|
| 46 |
def __init__(self, model_path: str = None):
|
| 47 |
print("🔄 Initializing ArabicSignDetector...")
|
|
|
|
| 140 |
for i in range(len(boxes.cls)):
|
| 141 |
class_id = int(boxes.cls[i])
|
| 142 |
confidence = float(boxes.conf[i])
|
| 143 |
+
letter_english = self.model.names.get(class_id, "")
|
| 144 |
|
| 145 |
if confidence > self.confidence_threshold:
|
| 146 |
+
# Convert English class name to Arabic character
|
| 147 |
+
letter_arabic = ARABIC_MAP.get(letter_english.lower(), letter_english)
|
| 148 |
+
detected_letters.append(letter_arabic)
|
| 149 |
confidences.append(confidence)
|
| 150 |
|
| 151 |
# Clear GPU memory after inference
|