seawolf2357 commited on
Commit
ee684a6
·
verified ·
1 Parent(s): 3e242b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -16
app.py CHANGED
@@ -252,16 +252,35 @@ def generate_motion(source_image_path, driving_audio_path, emotion_name,
252
  print(f" Target FPS: {target_fps}")
253
 
254
  try:
255
- # Call the pipeline's inference method with the WAV audio
256
- result_video_path = pipeline.driven_sample(
257
- image_path=source_image_path,
258
- audio_path=wav_audio_path,
259
- cfg_scale=float(cfg_scale),
260
- emo=emotion_id,
261
- save_dir=".",
262
- smooth=smooth_enabled, # Use the checkbox value
263
- silent_audio_path=DEFAULT_SILENT_AUDIO_PATH,
264
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
 
266
  # Apply frame interpolation if requested
267
  if target_fps > 24: # Assuming default is around 24 FPS
@@ -351,9 +370,9 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
351
 
352
  with gr.Row():
353
  smooth_checkbox = gr.Checkbox(
354
- label="Enable Smoothing",
355
- value=True,
356
- info="Enables frame smoothing for more natural motion (increases processing time)"
357
  )
358
 
359
  with gr.Row():
@@ -406,9 +425,9 @@ with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 960px
406
  # Examples section
407
  gr.Examples(
408
  examples=[
409
- ["src/examples/reference_images/7.jpg", "src/examples/driving_audios/5.wav", "None", 1.0, True, 30],
410
- ["src/examples/reference_images/7.jpg", "src/examples/driving_audios/5.wav", "Happy", 0.8, True, 30],
411
- ["src/examples/reference_images/7.jpg", "src/examples/driving_audios/5.wav", "Sad", 1.2, True, 24],
412
  ],
413
  inputs=[source_image, driving_audio, emotion_dropdown, cfg_slider, smooth_checkbox, fps_slider],
414
  outputs=output_video,
 
252
  print(f" Target FPS: {target_fps}")
253
 
254
  try:
255
+ # Temporarily disable smoothing if it causes CUDA tensor issues
256
+ # Check if smooth causes issues and handle gracefully
257
+ try:
258
+ # Try with smoothing first
259
+ result_video_path = pipeline.driven_sample(
260
+ image_path=source_image_path,
261
+ audio_path=wav_audio_path,
262
+ cfg_scale=float(cfg_scale),
263
+ emo=emotion_id,
264
+ save_dir=".",
265
+ smooth=smooth_enabled, # Use the checkbox value
266
+ silent_audio_path=DEFAULT_SILENT_AUDIO_PATH,
267
+ )
268
+ except TypeError as tensor_error:
269
+ if "can't convert cuda" in str(tensor_error) and smooth_enabled:
270
+ print("Warning: Smoothing caused CUDA tensor error. Retrying without smoothing...")
271
+ # Retry without smoothing
272
+ result_video_path = pipeline.driven_sample(
273
+ image_path=source_image_path,
274
+ audio_path=wav_audio_path,
275
+ cfg_scale=float(cfg_scale),
276
+ emo=emotion_id,
277
+ save_dir=".",
278
+ smooth=False, # Disable smoothing as fallback
279
+ silent_audio_path=DEFAULT_SILENT_AUDIO_PATH,
280
+ )
281
+ print("Generated video without smoothing due to technical limitations.")
282
+ else:
283
+ raise tensor_error
284
 
285
  # Apply frame interpolation if requested
286
  if target_fps > 24: # Assuming default is around 24 FPS
 
370
 
371
  with gr.Row():
372
  smooth_checkbox = gr.Checkbox(
373
+ label="Enable Smoothing (Experimental)",
374
+ value=False, # Changed to False due to CUDA issues
375
+ info="May cause errors on some systems. If errors occur, disable this option."
376
  )
377
 
378
  with gr.Row():
 
425
  # Examples section
426
  gr.Examples(
427
  examples=[
428
+ ["src/examples/reference_images/7.jpg", "src/examples/driving_audios/5.wav", "None", 1.0, False, 30],
429
+ ["src/examples/reference_images/7.jpg", "src/examples/driving_audios/5.wav", "Happy", 0.8, False, 30],
430
+ ["src/examples/reference_images/7.jpg", "src/examples/driving_audios/5.wav", "Sad", 1.2, False, 24],
431
  ],
432
  inputs=[source_image, driving_audio, emotion_dropdown, cfg_slider, smooth_checkbox, fps_slider],
433
  outputs=output_video,