Muhammadidrees commited on
Commit
f162467
·
verified ·
1 Parent(s): 64a59c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -22
app.py CHANGED
@@ -51,7 +51,7 @@ except Exception as e:
51
  raise e # fail fast if model load fails
52
 
53
 
54
- pipe,fantasytalking,wav2vec_processor,wav2vec = None,None,None,None
55
  @spaces.GPU(duration=1200)
56
  def generate_video(
57
  image_path,
@@ -65,30 +65,35 @@ def generate_video(
65
  inference_steps,
66
  seed,
67
  ):
68
- # Create the temp directory if it doesn't exist
69
- output_dir = Path("./output")
70
- output_dir.mkdir(parents=True, exist_ok=True)
71
 
72
- # Convert paths to absolute Path objects and normalize them
73
- print(image_path)
74
- image_path = Path(image_path).absolute().as_posix()
75
- audio_path = Path(audio_path).absolute().as_posix()
76
 
77
- # Parse the arguments
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- args = create_args(
80
- image_path=image_path,
81
- audio_path=audio_path,
82
- prompt=prompt,
83
- output_dir=str(output_dir),
84
- audio_weight=audio_weight,
85
- prompt_cfg_scale=prompt_cfg_scale,
86
- audio_cfg_scale=audio_cfg_scale,
87
- image_size=image_size,
88
- max_num_frames=max_num_frames,
89
- inference_steps=inference_steps,
90
- seed=seed,
91
- )
92
 
93
 
94
 
 
51
  raise e # fail fast if model load fails
52
 
53
 
54
+ # pipe,fantasytalking,wav2vec_processor,wav2vec = None,None,None,None
55
  @spaces.GPU(duration=1200)
56
  def generate_video(
57
  image_path,
 
65
  inference_steps,
66
  seed,
67
  ):
68
+ try:
69
+ output_dir = Path("./output")
70
+ output_dir.mkdir(parents=True, exist_ok=True)
71
 
72
+ image_path = Path(image_path).absolute().as_posix()
73
+ audio_path = Path(audio_path).absolute().as_posix()
 
 
74
 
75
+ args = create_args(
76
+ image_path=image_path,
77
+ audio_path=audio_path,
78
+ prompt=prompt or "A person is talking.",
79
+ output_dir=str(output_dir),
80
+ audio_weight=audio_weight,
81
+ prompt_cfg_scale=prompt_cfg_scale,
82
+ audio_cfg_scale=audio_cfg_scale,
83
+ image_size=image_size,
84
+ max_num_frames=max_num_frames,
85
+ inference_steps=inference_steps,
86
+ seed=seed,
87
+ )
88
 
89
+ # Run inference using preloaded models
90
+ save_path = main(args, pipe, fantasytalking, wav2vec_processor, wav2vec)
91
+ print(f"✅ Video saved at {save_path}")
92
+ return save_path
93
+
94
+ except Exception as e:
95
+ print(f"❌ Error generating video: {e}")
96
+ return None
 
 
 
 
 
97
 
98
 
99