RamAnanth1 commited on
Commit
25a83f9
β€’
1 Parent(s): ba984b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -10
app.py CHANGED
@@ -23,21 +23,24 @@ from huggingface_hub import hf_hub_download
23
  config_path = "model_config.yaml"
24
  config = OmegaConf.load(config_path)
25
 
26
-
27
  # Download model
28
  REPO_ID = 'VideoCrafter/t2v-version-1-1'
29
  filename_list = ['models/base_t2v/model.ckpt',
30
  'models/videolora/lora_001_Loving_Vincent_style.ckpt',
31
  'models/videolora/lora_002_frozenmovie_style.ckpt',
32
  'models/videolora/lora_003_MakotoShinkaiYourName_style.ckpt',
33
- 'models/videolora/lora_004_coco_style.ckpt']
 
 
34
  for filename in filename_list:
35
  if not os.path.exists(filename):
36
  hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='./', local_dir_use_symlinks=False)
37
 
 
38
 
 
39
 
40
- ckpt_path = 'models/base_t2v/model.ckpt'
41
 
42
  # # get model & sampler
43
  model, _, _ = load_model(config, ckpt_path,
@@ -170,7 +173,13 @@ def save_results(videos,
170
  return os.path.join(save_subdir, f"{save_name}_{i:03d}.mp4")
171
 
172
  def save_results_control(batch_samples, batch_conds):
173
- return
 
 
 
 
 
 
174
 
175
  def get_video(prompt, seed, ddim_steps):
176
  seed_everything(seed)
@@ -206,12 +215,12 @@ def get_video_lora(prompt, seed, ddim_steps, model_choice):
206
 
207
  def get_video_control(prompt, input_video, seed, ddim_steps):
208
  seed_everything(seed)
209
- # h,w = 512//8, 512//8
210
- # noise_shape = [1, model.channels, model.temporal_length,h,w]
211
- # batch_samples, batch_conds = adapter_guided_synthesis(model, prompt,input_video,noise_shape, sampler=ddim_sampler, n_samples = 1,
212
- # ddim_steps=ddim_steps
213
- # )
214
- # return save_results_control(batch_samples, batch_conds)
215
  return input_video
216
 
217
  from gradio_t2v import create_demo as create_demo_basic
 
23
  config_path = "model_config.yaml"
24
  config = OmegaConf.load(config_path)
25
 
 
26
  # Download model
27
  REPO_ID = 'VideoCrafter/t2v-version-1-1'
28
  filename_list = ['models/base_t2v/model.ckpt',
29
  'models/videolora/lora_001_Loving_Vincent_style.ckpt',
30
  'models/videolora/lora_002_frozenmovie_style.ckpt',
31
  'models/videolora/lora_003_MakotoShinkaiYourName_style.ckpt',
32
+ 'models/videolora/lora_004_coco_style.ckpt',
33
+ 'models/adapter_t2v_depth/adapter.pth']
34
+
35
  for filename in filename_list:
36
  if not os.path.exists(filename):
37
  hf_hub_download(repo_id=REPO_ID, filename=filename, local_dir='./', local_dir_use_symlinks=False)
38
 
39
+ ckpt_path = 'models/base_t2v/model.ckpt'
40
 
41
+ midas_path_url = 'https://github.com/isl-org/DPT/releases/download/1_0/dpt_hybrid-midas-501f0c75.pt'
42
 
43
+ subprocess.run(shlex.split(f'wget {midas_path_url} -O models/adapter_t2v_depth/dpt_hybrid-midas.pt'))
44
 
45
  # # get model & sampler
46
  model, _, _ = load_model(config, ckpt_path,
 
173
  return os.path.join(save_subdir, f"{save_name}_{i:03d}.mp4")
174
 
175
  def save_results_control(batch_samples, batch_conds):
176
+ save_subdir = os.path.join("videos")
177
+ os.makedirs(save_subdir, exist_ok=True)
178
+
179
+ tensor_to_mp4(video=batch_conds.detach().cpu(), savepath=os.path.join(save_subdir, f'results_depth.mp4'), fps=10)
180
+ tensor_to_mp4(video=batch_samples.detach().cpu(), savepath=os.path.join(save_subdir, f'results_sample.mp4'), fps=10)
181
+
182
+ return os.path.join(save_subdir, f'results_depth.mp4'), os.path.join(save_subdir, f'results_sample.mp4')
183
 
184
  def get_video(prompt, seed, ddim_steps):
185
  seed_everything(seed)
 
215
 
216
  def get_video_control(prompt, input_video, seed, ddim_steps):
217
  seed_everything(seed)
218
+ h,w = 512//8, 512//8
219
+ noise_shape = [1, model.channels, model_control.temporal_length,h,w]
220
+ batch_samples, batch_conds = adapter_guided_synthesis(model, prompt,input_video,noise_shape, sampler=ddim_sampler, n_samples = 1,
221
+ ddim_steps=ddim_steps
222
+ )
223
+ #return save_results_control(batch_samples, batch_conds)
224
  return input_video
225
 
226
  from gradio_t2v import create_demo as create_demo_basic