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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -61
app.py CHANGED
@@ -29,65 +29,33 @@ for root, dirs, files in os.walk("./ckpt"):
29
  subindent = " " * 4 * (level + 1)
30
  for f in files:
31
  print(f"{subindent}{f}")
32
- # # --------- SETUP CODE: Download models if not found ---------
33
- # FVSM_PATH = "./ckpt/FVSM/FloVD_FVSM_Controlnet.pt"
34
- # OMSM_PATH = "./ckpt/OMSM"
35
- # POSE_DIR = "./assets/manual_poses"
36
- # EXAMPLE_POSE = os.path.join(POSE_DIR, "example.txt")
37
 
38
- # def download_if_missing():
39
- # os.makedirs("ckpt/FVSM", exist_ok=True)
40
- # os.makedirs("ckpt/OMSM", exist_ok=True)
41
- # os.makedirs("assets/manual_poses", exist_ok=True)
42
- # os.makedirs("output/generated_videos", exist_ok=True)
43
-
44
- # # Download FVSM model
45
- # if not os.path.exists(FVSM_PATH):
46
- # print("Downloading FVSM model...")
47
- # url = "https://huggingface.co/datasets/mutqa/FloVD-HF-Assets/resolve/main/FloVD_FVSM_Controlnet.pt"
48
- # r = requests.get(url, stream=True)
49
- # with open(FVSM_PATH, 'wb') as f:
50
- # shutil.copyfileobj(r.raw, f)
51
-
52
- # # Download OMSM weights (as folder with .safetensors inside)
53
- # if not os.listdir(OMSM_PATH):
54
- # print("Cloning OMSM weights...")
55
- # os.system("git clone https://huggingface.co/datasets/mutqa/FloVD-HF-OMSM ckpt/OMSM")
56
-
57
- # # Download example camera pose
58
- # if not os.path.exists(EXAMPLE_POSE):
59
- # print("Downloading example pose...")
60
- # url = "https://huggingface.co/datasets/mutqa/FloVD-HF-Assets/resolve/main/example.txt"
61
- # r = requests.get(url)
62
- # with open(EXAMPLE_POSE, "w") as f:
63
- # f.write(r.text)
64
-
65
- # # --------- UI Function ---------
66
- # def run_flovd(prompt, image, cam_pose_name):
67
- # download_if_missing()
68
- # image_path = "./temp_input.png"
69
- # image.save(image_path)
70
-
71
- # generate_video(
72
- # prompt=prompt,
73
- # fvsm_path=FVSM_PATH,
74
- # omsm_path=OMSM_PATH,
75
- # image_path=image_path,
76
- # cam_pose_name=cam_pose_name,
77
- # output_path="./output/",
78
- # dtype=torch.float16,
79
- # )
80
- # return "./output/generated_videos/your_video.mp4"
81
-
82
- # # --------- Launch Gradio ---------
83
- # iface = gr.Interface(
84
- # fn=run_flovd,
85
- # inputs=[
86
- # gr.Textbox(label="Prompt"),
87
- # gr.Image(type="pil", label="Input Image"),
88
- # gr.Textbox(label="Camera Pose File Name", value="example.txt"),
89
- # ],
90
- # outputs=gr.Video(label="Generated Video"),
91
- # title="FloVD - Optical Flow Video Diffusion with Camera Motion",
92
- # )
93
- # iface.launch(server_name="0.0.0.0", server_port=7860)
 
29
  subindent = " " * 4 * (level + 1)
30
  for f in files:
31
  print(f"{subindent}{f}")
 
 
 
 
 
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
+
39
+ generate_video(
40
+ prompt=prompt,
41
+ fvsm_path=FVSM_PATH,
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(
52
+ fn=run_flovd,
53
+ inputs=[
54
+ gr.Textbox(label="Prompt"),
55
+ gr.Image(type="pil", label="Input Image"),
56
+ gr.Textbox(label="Camera Pose File Name", value="example.txt"),
57
+ ],
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)