Update handler.py
Browse files- handler.py +4 -2
handler.py
CHANGED
@@ -47,7 +47,9 @@ class EndpointHandler:
|
|
47 |
print("تم تحميل الأوزان بنجاح")
|
48 |
|
49 |
self.model.to(self.device).eval()
|
50 |
-
|
|
|
|
|
51 |
|
52 |
except Exception as e:
|
53 |
print(f"خطأ أثناء تهيئة النموذج: {e}")
|
@@ -88,7 +90,7 @@ class EndpointHandler:
|
|
88 |
|
89 |
results = []
|
90 |
for i, prob in enumerate(probs):
|
91 |
-
label = self.labels[str(i)]
|
92 |
results.append({
|
93 |
"label": label,
|
94 |
"score": round(prob.item(), 4)
|
|
|
47 |
print("تم تحميل الأوزان بنجاح")
|
48 |
|
49 |
self.model.to(self.device).eval()
|
50 |
+
|
51 |
+
# ✅ تعديل مهم جداً: تحويل المفاتيح إلى نصوص
|
52 |
+
self.labels = {str(k): v for k, v in self.model.config.id2label.items()}
|
53 |
|
54 |
except Exception as e:
|
55 |
print(f"خطأ أثناء تهيئة النموذج: {e}")
|
|
|
90 |
|
91 |
results = []
|
92 |
for i, prob in enumerate(probs):
|
93 |
+
label = self.labels[str(i)] # 🔥 المفتاح أصبح مضمون هنا
|
94 |
results.append({
|
95 |
"label": label,
|
96 |
"score": round(prob.item(), 4)
|