yaya36095 commited on
Commit
17a6685
·
verified ·
1 Parent(s): ca4a6ac

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +1 -4
handler.py CHANGED
@@ -48,9 +48,6 @@ class EndpointHandler:
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}")
56
  raise
@@ -90,7 +87,7 @@ class EndpointHandler:
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)
 
48
 
49
  self.model.to(self.device).eval()
50
 
 
 
 
51
  except Exception as e:
52
  print(f"خطأ أثناء تهيئة النموذج: {e}")
53
  raise
 
87
 
88
  results = []
89
  for i, prob in enumerate(probs):
90
+ label = str(self.model.config.id2label[i]) # هنا المفتاح الصحيح
91
  results.append({
92
  "label": label,
93
  "score": round(prob.item(), 4)