AL-NAQEEP commited on
Commit
c8159c4
·
verified ·
1 Parent(s): 358fd6d

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +46 -0
  2. my_model.pkl +3 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import numpy as np
4
+
5
+ # تحميل النموذج
6
+ model = joblib.load("my_model.pkl")
7
+
8
+ # عدد الميزات المطلوبة
9
+ NUM_FEATURES = 18
10
+
11
+ # دالة التنبؤ
12
+ def predict_from_input(text_input):
13
+ try:
14
+ # تقسيم المدخلات بفاصلة أو مسافة
15
+ if "," in text_input:
16
+ values = [float(x.strip()) for x in text_input.split(",")]
17
+ else:
18
+ values = [float(x.strip()) for x in text_input.split()]
19
+
20
+ if len(values) != NUM_FEATURES:
21
+ return f"❌ يجب إدخال {NUM_FEATURES} قيمة مفصولة بفاصلة أو مسافة فقط."
22
+
23
+ arr = np.array(values).reshape(1, -1)
24
+ pred = model.predict(arr)[0]
25
+
26
+ if pred == 1:
27
+ return "✅ التنبؤ: المجموعة 1 ( حالة نشطة)"
28
+ else:
29
+ return "✅ التنبؤ: المجموعة 0 ( حالة مستقرة)"
30
+ except Exception as e:
31
+ return f"❌ حدث خطأ أثناء المعالجة: {str(e)}"
32
+
33
+ # واجهة Gradio
34
+ iface = gr.Interface(
35
+ fn=predict_from_input,
36
+ inputs=gr.Textbox(
37
+ label="🧾 أدخل 18 قيمة مفصولة بفاصلة أو مسافة",
38
+ placeholder="مثال: 1, 30, 12, 1, 0, 1, 2, 1, 0, 1, 1, 1, 1, 0, 0, 1, 2, 2",
39
+ lines=2
40
+ ),
41
+ outputs="text",
42
+ title="🔍 نموذج تصنيف المرضى",
43
+ description="أدخل القيم الرقمية للـ 18 ميزة بالترتيب كما كانت في التدريب."
44
+ )
45
+
46
+ iface.launch()
my_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53727c4cbc5b9c44a6a1895cac2660d73e655b6cacaaab9e350ba31f3bfcb930
3
+ size 752601
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ scikit-learn
3
+ numpy
4
+ joblib