st192011 commited on
Commit
a8e25e5
·
verified ·
1 Parent(s): f552d94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -7
app.py CHANGED
@@ -66,22 +66,33 @@ def update_video_display(selection):
66
  def run_omnisign_vlm(video_path):
67
  """
68
  Submits the video to the private backend.
69
- CRITICAL: Must use positional arguments for handle_file().
70
  """
71
- if not video_path: return {"Error": "No input detected."}
72
- if not client: return {"Neural Engine Offline": 0.0}
 
 
 
 
 
73
 
74
  try:
75
- # --- THE FIX IS HERE ---
76
- # We pass handle_file(video_path) as the FIRST argument (positional).
77
- # We do NOT use 'video_file=' or 'video=' as a keyword.
78
  result = client.predict(
79
  handle_file(video_path),
80
  api_name="/predict_sign"
81
  )
 
 
 
 
 
 
 
82
  return result
 
83
  except Exception as e:
84
- return {f"Neural Analysis Failed: {str(e)}": 0.0}
85
 
86
  # 6. UI DESIGN
87
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
66
  def run_omnisign_vlm(video_path):
67
  """
68
  Submits the video to the private backend.
69
+ Fixed to ensure gr.Label always receives {str: float}
70
  """
71
+ # FIX 1: Value must be 0.0 (float), not a string message
72
+ if not video_path:
73
+ return {"⚠️ No Input Selected": 0.0}
74
+
75
+ # FIX 2: Value must be 0.0 (float)
76
+ if not client:
77
+ return {"⚠️ Neural Engine Offline": 0.0}
78
 
79
  try:
80
+ # 1. Send to Private Space
 
 
81
  result = client.predict(
82
  handle_file(video_path),
83
  api_name="/predict_sign"
84
  )
85
+
86
+ # 2. Safety Check on Result
87
+ # Sometimes connection errors return strings instead of dicts.
88
+ # We must intercept that before giving it to gr.Label
89
+ if isinstance(result, str):
90
+ return {f"⚠️ Backend Error: {result}": 0.0}
91
+
92
  return result
93
+
94
  except Exception as e:
95
+ return {f" Analysis Failed: {str(e)}": 0.0}
96
 
97
  # 6. UI DESIGN
98
  with gr.Blocks(theme=gr.themes.Soft()) as demo: