roll-ai commited on
Commit
bc8f7b7
·
verified ·
1 Parent(s): 828b5b4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -8
app.py CHANGED
@@ -1,13 +1,19 @@
1
-
2
  import gradio as gr
3
  import os
4
  import torch
5
  from PIL import Image
6
  from inference.flovd_demo import generate_video
7
- import requests
8
- import shutil
9
  from huggingface_hub import snapshot_download
10
 
 
 
 
 
 
 
 
 
 
11
  # Get the HF token from environment variable
12
  hf_token = os.getenv("HF_TOKEN")
13
 
@@ -17,11 +23,12 @@ snapshot_download(
17
  repo_type="dataset",
18
  local_dir="./ckpt",
19
  allow_patterns="ckpt/**",
 
20
  token=hf_token
21
  )
22
 
23
- # Print the directory tree of ./ckpt
24
- print("📂 Contents of ./ckpt directory:")
25
  for root, dirs, files in os.walk("./ckpt"):
26
  level = root.replace("./ckpt", "").count(os.sep)
27
  indent = " " * 4 * level
@@ -32,7 +39,6 @@ for root, dirs, files in os.walk("./ckpt"):
32
 
33
  # --------- UI Function ---------
34
  def run_flovd(prompt, image, cam_pose_name):
35
- download_if_missing()
36
  image_path = "./temp_input.png"
37
  image.save(image_path)
38
 
@@ -42,10 +48,16 @@ def run_flovd(prompt, image, cam_pose_name):
42
  omsm_path=OMSM_PATH,
43
  image_path=image_path,
44
  cam_pose_name=cam_pose_name,
45
- output_path="./output/",
 
 
 
 
46
  dtype=torch.float16,
 
47
  )
48
- return "./output/generated_videos/your_video.mp4"
 
49
 
50
  # --------- Launch Gradio ---------
51
  iface = gr.Interface(
@@ -58,4 +70,5 @@ iface = gr.Interface(
58
  outputs=gr.Video(label="Generated Video"),
59
  title="FloVD - Optical Flow Video Diffusion with Camera Motion",
60
  )
 
61
  iface.launch(server_name="0.0.0.0", server_port=7860)
 
 
1
  import gradio as gr
2
  import os
3
  import torch
4
  from PIL import Image
5
  from inference.flovd_demo import generate_video
 
 
6
  from huggingface_hub import snapshot_download
7
 
8
+ # Constants
9
+ FVSM_PATH = "./ckpt/FVSM/FloVD_FVSM_Controlnet.pt"
10
+ OMSM_PATH = "./ckpt/OMSM/"
11
+ DEPTH_CKPT_PATH = "./ckpt/others/depth_anything_v2_metric_hypersim_vitb.pth"
12
+ OUTPUT_PATH = "./results/"
13
+ POSE_TYPE = "re10k"
14
+ CONTROLNET_GUIDANCE_END = 0.4
15
+ SPEED = 1.0
16
+
17
  # Get the HF token from environment variable
18
  hf_token = os.getenv("HF_TOKEN")
19
 
 
23
  repo_type="dataset",
24
  local_dir="./ckpt",
25
  allow_patterns="ckpt/**",
26
+ cache_dir="./hf_cache", # avoid permission issues
27
  token=hf_token
28
  )
29
 
30
+ # Print the directory structure of ckpt
31
+ print("\n📂 Contents of ./ckpt directory:")
32
  for root, dirs, files in os.walk("./ckpt"):
33
  level = root.replace("./ckpt", "").count(os.sep)
34
  indent = " " * 4 * level
 
39
 
40
  # --------- UI Function ---------
41
  def run_flovd(prompt, image, cam_pose_name):
 
42
  image_path = "./temp_input.png"
43
  image.save(image_path)
44
 
 
48
  omsm_path=OMSM_PATH,
49
  image_path=image_path,
50
  cam_pose_name=cam_pose_name,
51
+ output_path=OUTPUT_PATH,
52
+ controlnet_guidance_end=CONTROLNET_GUIDANCE_END,
53
+ pose_type=POSE_TYPE,
54
+ speed=SPEED,
55
+ depth_ckpt_path=DEPTH_CKPT_PATH,
56
  dtype=torch.float16,
57
+ use_flow_integration=True,
58
  )
59
+
60
+ return "./results/generated_videos/your_video.mp4"
61
 
62
  # --------- Launch Gradio ---------
63
  iface = gr.Interface(
 
70
  outputs=gr.Video(label="Generated Video"),
71
  title="FloVD - Optical Flow Video Diffusion with Camera Motion",
72
  )
73
+
74
  iface.launch(server_name="0.0.0.0", server_port=7860)