EngReem85 commited on
Commit
ebc55f0
·
verified ·
1 Parent(s): 515e044

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -6,10 +6,11 @@ import tempfile
6
  import os
7
  import math
8
 
 
9
  mp_pose = mp.solutions.pose
10
  pose = mp_pose.Pose(static_image_mode=False, min_detection_confidence=0.8, model_complexity=2)
11
 
12
- def _dist(p1, p2):
13
  return math.hypot(p1[0]-p2[0], p1[1]-p2[1])
14
 
15
  def _angle(a, b, c):
@@ -39,6 +40,7 @@ def analyze_gait(video_file):
39
  if video_file is None:
40
  return "<div style='direction:rtl;text-align:right'>❌ يرجى رفع فيديو أولًا.</div>", "<div></div>"
41
 
 
42
  if hasattr(video_file, "name"):
43
  video_path = video_file.name
44
  else:
@@ -158,15 +160,16 @@ def analyze_gait(video_file):
158
 
159
  html = f"""
160
  <div style='direction:rtl;text-align:right;color:{color};font-weight:700;font-size:18px'>{level}</div>
161
- <div>📍 الجانب المتأثر: <b>{side}</b></div>
162
- <div>🩺 الحالة المحتملة: <b>غير محددة</b></div>
163
- <div>📊 درجة الخطورة: <b>{score:.1f}/10</b></div>
164
- <div>{desc}</div>
165
  {booking}
166
  <div style='font-size:13px;color:#555;margin-top:8px;direction:rtl;text-align:right'>⚠️ التحليل يعتمد على مؤشرات متعددة ولا يُغني عن الفحص الطبي.</div>
167
  """
168
  return html, _gauge_html(norm_score)
169
 
 
170
  instructions = """
171
  <div style='direction:rtl;text-align:right'>
172
  <h3>🎥 تعليمات التصوير لضمان دقة التحليل:</h3>
@@ -181,6 +184,7 @@ instructions = """
181
  </div>
182
  """
183
 
 
184
  custom_css = """
185
  button, .btn, .gr-button {
186
  background-color: #2e7d32 !important;
@@ -191,7 +195,7 @@ button, .btn, .gr-button {
191
  """
192
 
193
  with gr.Blocks(title="تحليل المشية العصبية - v8.2 (واجهة خضراء)", css=custom_css) as demo:
194
- gr.Markdown("<h2 style='direction:rtl;text-align:right'>🩺 نظام تحليل المشية العصبية – الإصدار 8.2</h2>")
195
  gr.HTML(instructions)
196
  with gr.Row():
197
  with gr.Column(scale=1):
@@ -207,6 +211,5 @@ if __name__ == "__main__":
207
 
208
 
209
 
210
-
211
 
212
 
 
6
  import os
7
  import math
8
 
9
+ # إعداد Mediapipe Pose
10
  mp_pose = mp.solutions.pose
11
  pose = mp_pose.Pose(static_image_mode=False, min_detection_confidence=0.8, model_complexity=2)
12
 
13
+ def _dist(p1, p2):
14
  return math.hypot(p1[0]-p2[0], p1[1]-p2[1])
15
 
16
  def _angle(a, b, c):
 
40
  if video_file is None:
41
  return "<div style='direction:rtl;text-align:right'>❌ يرجى رفع فيديو أولًا.</div>", "<div></div>"
42
 
43
+ # حفظ مؤقت للفيديو
44
  if hasattr(video_file, "name"):
45
  video_path = video_file.name
46
  else:
 
160
 
161
  html = f"""
162
  <div style='direction:rtl;text-align:right;color:{color};font-weight:700;font-size:18px'>{level}</div>
163
+ <div style='direction:rtl;text-align:right'>📍 الجانب المتأثر: <b>{side}</b></div>
164
+ <div style='direction:rtl;text-align:right'>🩺 الحالة المحتملة: <b>غير محددة</b></div>
165
+ <div style='direction:rtl;text-align:right'>📊 درجة الخطورة: <b>{score:.1f}/10</b></div>
166
+ <div style='direction:rtl;text-align:right'>{desc}</div>
167
  {booking}
168
  <div style='font-size:13px;color:#555;margin-top:8px;direction:rtl;text-align:right'>⚠️ التحليل يعتمد على مؤشرات متعددة ولا يُغني عن الفحص الطبي.</div>
169
  """
170
  return html, _gauge_html(norm_score)
171
 
172
+ # تعليمات التصوير
173
  instructions = """
174
  <div style='direction:rtl;text-align:right'>
175
  <h3>🎥 تعليمات التصوير لضمان دقة التحليل:</h3>
 
184
  </div>
185
  """
186
 
187
+ # ✅ CSS للأزرار فقط باللون الأخضر
188
  custom_css = """
189
  button, .btn, .gr-button {
190
  background-color: #2e7d32 !important;
 
195
  """
196
 
197
  with gr.Blocks(title="تحليل المشية العصبية - v8.2 (واجهة خضراء)", css=custom_css) as demo:
198
+ gr.Markdown("<h2 style='direction:rtl;text-align:right;color:#2e7d32;'>🩺 نظام تحليل المشية العصبية – الإصدار 8.2</h2>")
199
  gr.HTML(instructions)
200
  with gr.Row():
201
  with gr.Column(scale=1):
 
211
 
212
 
213
 
 
214
 
215