Baseta commited on
Commit
0eb4c39
·
verified ·
1 Parent(s): f6c7d84

Update app.py from anycoder

Browse files
Files changed (1) hide show
  1. app.py +13 -7
app.py CHANGED
@@ -204,7 +204,8 @@ custom_theme = gr.themes.Soft(
204
  block_border_color="*neutral_200",
205
  )
206
 
207
- with gr.Blocks(theme=custom_theme, css=create_custom_css()) as demo:
 
208
  # Header
209
  gr.HTML("""
210
  <div class="main-header">
@@ -309,23 +310,27 @@ with gr.Blocks(theme=custom_theme, css=create_custom_css()) as demo:
309
  height=400
310
  )
311
 
312
- # Event handlers
313
  def handle_generate_text(prompt, duration, style, quality, motion, seed):
314
  if not prompt.strip():
315
  raise gr.Error("Please enter a prompt!")
316
 
317
  # Show progress
318
- progress_text.visible = True
319
 
320
  # Generate video with progress updates
321
  for progress in generate_video_from_text(prompt, duration, style, quality, motion, seed):
322
  if isinstance(progress, str):
323
- progress_text.value = progress
 
 
 
 
324
 
325
  # Show result
326
  video_url = generate_video_from_text(prompt, duration, style, quality, motion, seed)
327
  if isinstance(video_url, str):
328
- return {
329
  video_output: gr.Video(value=video_url, visible=True),
330
  progress_text: gr.Textbox(value="✅ Video generated successfully!", visible=True)
331
  }
@@ -333,7 +338,7 @@ with gr.Blocks(theme=custom_theme, css=create_custom_css()) as demo:
333
  generate_btn.click(
334
  fn=handle_generate_text,
335
  inputs=[prompt_input, duration_slider, style_dropdown, quality_dropdown, motion_slider, seed_input],
336
- outputs=[video_output, progress_text],
337
  api_visibility="public"
338
  )
339
 
@@ -464,9 +469,10 @@ with gr.Blocks(theme=custom_theme, css=create_custom_css()) as demo:
464
  interactive=False
465
  )
466
 
467
- # Launch the application
468
  demo.launch(
469
  theme=custom_theme,
 
470
  footer_links=[
471
  {"label": "Documentation", "url": "https://huggingface.co/spaces/akhaliq/anycoder"},
472
  {"label": "GitHub", "url": "https://github.com/gradio-app/gradio"},
 
204
  block_border_color="*neutral_200",
205
  )
206
 
207
+ # Gradio 6: NO parameters in gr.Blocks() constructor!
208
+ with gr.Blocks() as demo:
209
  # Header
210
  gr.HTML("""
211
  <div class="main-header">
 
310
  height=400
311
  )
312
 
313
+ # Event handlers - Fixed for Gradio 6
314
  def handle_generate_text(prompt, duration, style, quality, motion, seed):
315
  if not prompt.strip():
316
  raise gr.Error("Please enter a prompt!")
317
 
318
  # Show progress
319
+ progress_updates = []
320
 
321
  # Generate video with progress updates
322
  for progress in generate_video_from_text(prompt, duration, style, quality, motion, seed):
323
  if isinstance(progress, str):
324
+ progress_updates.append(progress)
325
+ yield {
326
+ progress_text: gr.Textbox(value=progress, visible=True),
327
+ video_output: gr.Video(visible=False)
328
+ }
329
 
330
  # Show result
331
  video_url = generate_video_from_text(prompt, duration, style, quality, motion, seed)
332
  if isinstance(video_url, str):
333
+ yield {
334
  video_output: gr.Video(value=video_url, visible=True),
335
  progress_text: gr.Textbox(value="✅ Video generated successfully!", visible=True)
336
  }
 
338
  generate_btn.click(
339
  fn=handle_generate_text,
340
  inputs=[prompt_input, duration_slider, style_dropdown, quality_dropdown, motion_slider, seed_input],
341
+ outputs=[progress_text, video_output],
342
  api_visibility="public"
343
  )
344
 
 
469
  interactive=False
470
  )
471
 
472
+ # Gradio 6: ALL app parameters go in launch()!
473
  demo.launch(
474
  theme=custom_theme,
475
+ css=create_custom_css(),
476
  footer_links=[
477
  {"label": "Documentation", "url": "https://huggingface.co/spaces/akhaliq/anycoder"},
478
  {"label": "GitHub", "url": "https://github.com/gradio-app/gradio"},