HeshamHaroon commited on
Commit
ffef688
Β·
1 Parent(s): b2e2daa

fix: remove gr.Group from outputs to avoid Gradio API schema bug

Browse files

- Root cause: gr.Group as output generates schema with boolean
additionalProperties which crashes gradio_client introspection
- Removed result_group from outputs list (6 outputs instead of 7)
- Result section always visible, video/audio values passed directly
- Set ssr_mode=False in launch()
- Unpin gradio version (compatible with Python 3.13)

Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +10 -43
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: "\U0001F3AC"
4
  colorFrom: yellow
5
  colorTo: green
6
  sdk: gradio
7
- sdk_version: 5.18.0
8
  app_file: app.py
9
  pinned: true
10
  license: mit
 
4
  colorFrom: yellow
5
  colorTo: green
6
  sdk: gradio
7
+ sdk_version: 5.50.0
8
  app_file: app.py
9
  pinned: true
10
  license: mit
app.py CHANGED
@@ -174,24 +174,10 @@ def process_video(
174
  sub_size: int,
175
  ) -> Generator:
176
  """
177
- Drive run_pipeline() and yield 7 UI updates per stage event:
178
- [pipeline_html, log_text, result_group, video_output, audio_output, srt_preview, srt_download]
179
  """
180
  log_lines: list[str] = []
181
-
182
- # Initial state β€” pipeline idle
183
- yield (
184
- build_pipeline_html(),
185
- "",
186
- gr.update(visible=False),
187
- gr.update(visible=False),
188
- gr.update(visible=False),
189
- "",
190
- None,
191
- )
192
-
193
- # Track highest completed stage (1-based from pipeline_runner)
194
- last_stage = 0
195
  video_path = None
196
  audio_path = None
197
  srt_content = ""
@@ -211,22 +197,8 @@ def process_video(
211
  subtitle_font_size=sub_size,
212
  ):
213
  log_lines.append(log_msg)
214
- last_stage = max(last_stage, stage_idx)
215
-
216
- # Check if pipeline produced an error
217
- if result.get("error"):
218
- yield (
219
- build_pipeline_html(active=stage_idx - 1, done_up_to=stage_idx - 1),
220
- "\n".join(log_lines),
221
- gr.update(visible=False),
222
- gr.update(visible=False),
223
- gr.update(visible=False),
224
- "",
225
- None,
226
- )
227
- continue
228
 
229
- # Check for final results β€” pipeline_runner uses "final_path" and "srt_path"
230
  if result.get("final_path"):
231
  fpath = result["final_path"]
232
  if fpath.endswith((".mp4", ".mkv", ".avi", ".mov", ".webm")):
@@ -240,21 +212,15 @@ def process_video(
240
  except Exception:
241
  pass
242
 
243
- has_result = video_path is not None or audio_path is not None
244
  is_done = result.get("done", False)
245
-
246
- # Pipeline visualizer: current stage is active, previous are done
247
- # stage_idx is 1-based; done_up_to means stages < done_up_to are done
248
  done_up_to = stage_idx - 1 if not is_done else len(STAGE_NAMES)
249
  active = stage_idx - 1 if not is_done and stage_idx <= len(STAGE_NAMES) else -1
250
 
251
- want_video = output_type == "video"
252
  yield (
253
  build_pipeline_html(active=active, done_up_to=done_up_to),
254
  "\n".join(log_lines),
255
- gr.update(visible=has_result),
256
- gr.update(visible=want_video and video_path is not None, value=video_path),
257
- gr.update(visible=audio_path is not None, value=audio_path),
258
  srt_content,
259
  srt_path,
260
  )
@@ -384,8 +350,8 @@ with gr.Blocks(
384
  show_copy_button=True,
385
  )
386
 
387
- # ── Result group ─────────────────────────────────────────────────────────
388
- with gr.Group(visible=False) as result_group:
389
  gr.Markdown("### RESULT")
390
  with gr.Row():
391
  video_output = gr.Video(
@@ -452,7 +418,6 @@ with gr.Blocks(
452
  outputs=[
453
  pipeline_display,
454
  log_output,
455
- result_group,
456
  video_output,
457
  audio_output,
458
  srt_preview,
@@ -465,5 +430,7 @@ with gr.Blocks(
465
  # Launch
466
  # ---------------------------------------------------------------------------
467
 
 
 
468
  if __name__ == "__main__":
469
- demo.queue().launch()
 
174
  sub_size: int,
175
  ) -> Generator:
176
  """
177
+ Drive run_pipeline() and yield 6 UI updates per stage event:
178
+ [pipeline_html, log_text, video_output, audio_output, srt_preview, srt_download]
179
  """
180
  log_lines: list[str] = []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  video_path = None
182
  audio_path = None
183
  srt_content = ""
 
197
  subtitle_font_size=sub_size,
198
  ):
199
  log_lines.append(log_msg)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
 
201
+ # Collect final results
202
  if result.get("final_path"):
203
  fpath = result["final_path"]
204
  if fpath.endswith((".mp4", ".mkv", ".avi", ".mov", ".webm")):
 
212
  except Exception:
213
  pass
214
 
 
215
  is_done = result.get("done", False)
 
 
 
216
  done_up_to = stage_idx - 1 if not is_done else len(STAGE_NAMES)
217
  active = stage_idx - 1 if not is_done and stage_idx <= len(STAGE_NAMES) else -1
218
 
 
219
  yield (
220
  build_pipeline_html(active=active, done_up_to=done_up_to),
221
  "\n".join(log_lines),
222
+ video_path,
223
+ audio_path,
 
224
  srt_content,
225
  srt_path,
226
  )
 
350
  show_copy_button=True,
351
  )
352
 
353
+ # ── Result section ───────────────────────────────────────────────────────
354
+ with gr.Group():
355
  gr.Markdown("### RESULT")
356
  with gr.Row():
357
  video_output = gr.Video(
 
418
  outputs=[
419
  pipeline_display,
420
  log_output,
 
421
  video_output,
422
  audio_output,
423
  srt_preview,
 
430
  # Launch
431
  # ---------------------------------------------------------------------------
432
 
433
+ demo.queue()
434
+
435
  if __name__ == "__main__":
436
+ demo.launch(ssr_mode=False)
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
  mazinger[all-qwen]
2
- gradio==5.18.0
 
1
  mazinger[all-qwen]
2
+ gradio>=5.18.0,<6