Fabrice-TIERCELIN commited on
Commit
4426f1f
·
verified ·
1 Parent(s): 29be167

" rather than '

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -31,7 +31,7 @@ if torch.cuda.device_count() > 0:
31
  snapshot_download(repo_id="openai/clip-vit-large-patch14", repo_type="model", local_dir="ckpts/text_encoder_2", force_download=True)
32
 
33
  def initialize_model(model_path):
34
- print('initialize_model: ' + model_path)
35
  if torch.cuda.device_count() == 0:
36
  return None
37
 
@@ -42,7 +42,7 @@ def initialize_model(model_path):
42
 
43
  print(f"`models_root` exists: {models_root_path}")
44
  hunyuan_video_sampler = HunyuanVideoSampler.from_pretrained(models_root_path, args=args)
45
- print('Model initialized: ' + model_path)
46
  return hunyuan_video_sampler
47
 
48
  model = initialize_model("ckpts")
@@ -57,7 +57,7 @@ def generate_video(
57
  flow_shift,
58
  embedded_guidance_scale
59
  ):
60
- print('generate_video (prompt: ' + prompt + ')')
61
  return generate_video_gpu(
62
  model,
63
  prompt,
@@ -82,16 +82,16 @@ def generate_video_gpu(
82
  flow_shift,
83
  embedded_guidance_scale
84
  ):
85
- print('generate_video_gpu (prompt: ' + prompt + ')')
86
  if torch.cuda.device_count() == 0:
87
- gr.Warning('Set this space to GPU config to make it work.')
88
  return None
89
 
90
  seed = None if seed == -1 else seed
91
  width, height = resolution.split("x")
92
  width, height = int(width), int(height)
93
  negative_prompt = "" # not applicable in the inference
94
- print('Predicting video...')
95
 
96
  outputs = model.predict(
97
  prompt=prompt,
@@ -108,8 +108,8 @@ def generate_video_gpu(
108
  embedded_guidance_scale=embedded_guidance_scale
109
  )
110
 
111
- print('Video predicted')
112
- samples = outputs['samples']
113
  sample = samples[0].unsqueeze(0)
114
 
115
  save_path = "./gradio_outputs"
@@ -118,9 +118,9 @@ def generate_video_gpu(
118
  time_flag = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d-%H:%M:%S")
119
  video_path = f"{save_path}/{time_flag}_seed{outputs['seeds'][0]}_{outputs['prompts'][0][:100].replace('/','')}.mp4"
120
  save_videos_grid(sample, video_path, fps=24)
121
- logger.info(f'Sample saved to: {video_path}')
122
 
123
- print('Return the video')
124
  return video_path
125
 
126
  def create_demo(model_path):
 
31
  snapshot_download(repo_id="openai/clip-vit-large-patch14", repo_type="model", local_dir="ckpts/text_encoder_2", force_download=True)
32
 
33
  def initialize_model(model_path):
34
+ print("initialize_model: " + model_path)
35
  if torch.cuda.device_count() == 0:
36
  return None
37
 
 
42
 
43
  print(f"`models_root` exists: {models_root_path}")
44
  hunyuan_video_sampler = HunyuanVideoSampler.from_pretrained(models_root_path, args=args)
45
+ print("Model initialized: " + model_path)
46
  return hunyuan_video_sampler
47
 
48
  model = initialize_model("ckpts")
 
57
  flow_shift,
58
  embedded_guidance_scale
59
  ):
60
+ print("generate_video (prompt: " + prompt + ")")
61
  return generate_video_gpu(
62
  model,
63
  prompt,
 
82
  flow_shift,
83
  embedded_guidance_scale
84
  ):
85
+ print("generate_video_gpu (prompt: " + prompt + ")")
86
  if torch.cuda.device_count() == 0:
87
+ gr.Warning("Set this space to GPU config to make it work.")
88
  return None
89
 
90
  seed = None if seed == -1 else seed
91
  width, height = resolution.split("x")
92
  width, height = int(width), int(height)
93
  negative_prompt = "" # not applicable in the inference
94
+ print("Predicting video...")
95
 
96
  outputs = model.predict(
97
  prompt=prompt,
 
108
  embedded_guidance_scale=embedded_guidance_scale
109
  )
110
 
111
+ print("Video predicted")
112
+ samples = outputs["samples"]
113
  sample = samples[0].unsqueeze(0)
114
 
115
  save_path = "./gradio_outputs"
 
118
  time_flag = datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d-%H:%M:%S")
119
  video_path = f"{save_path}/{time_flag}_seed{outputs['seeds'][0]}_{outputs['prompts'][0][:100].replace('/','')}.mp4"
120
  save_videos_grid(sample, video_path, fps=24)
121
+ logger.info(f"Sample saved to: {video_path}")
122
 
123
+ print("Return the video")
124
  return video_path
125
 
126
  def create_demo(model_path):