Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -17,9 +17,9 @@ snapshot_download(
|
|
17 |
allow_patterns="ckpt/**",
|
18 |
token=hf_token,
|
19 |
)
|
20 |
-
print("ckpt dir files:", os.listdir("./ckpt"))
|
21 |
|
22 |
-
print("
|
|
|
23 |
for root, dirs, files in os.walk("./ckpt"):
|
24 |
level = root.replace("./ckpt", "").count(os.sep)
|
25 |
indent = " " * 4 * level
|
@@ -28,7 +28,6 @@ for root, dirs, files in os.walk("./ckpt"):
|
|
28 |
for f in files:
|
29 |
print(f"{subindent}{f}")
|
30 |
|
31 |
-
|
32 |
# -----------------------------------
|
33 |
# Step 2: Define inference function
|
34 |
# -----------------------------------
|
@@ -47,35 +46,48 @@ INFER_STEPS = 50
|
|
47 |
os.makedirs(os.path.join(OUTPUT_PATH, "generated_videos"), exist_ok=True)
|
48 |
|
49 |
def run_flovd(prompt, image, cam_pose_name):
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
-
|
55 |
-
prompt=prompt,
|
56 |
-
fvsm_path=FVSM_PATH,
|
57 |
-
omsm_path=OMSM_PATH,
|
58 |
-
image_path=image_path,
|
59 |
-
cam_pose_name=cam_pose_name,
|
60 |
-
output_path=OUTPUT_PATH,
|
61 |
-
controlnet_guidance_end=CONTROLNET_GUIDANCE_END,
|
62 |
-
pose_type=POSE_TYPE,
|
63 |
-
speed=SPEED,
|
64 |
-
use_flow_integration=True,
|
65 |
-
depth_ckpt_path=DEPTH_CKPT_PATH,
|
66 |
-
dtype=torch.float16,
|
67 |
-
num_frames=NUM_FRAMES,
|
68 |
-
fps=FPS,
|
69 |
-
num_inference_steps=INFER_STEPS,
|
70 |
-
)
|
71 |
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
return "Video generation failed or file not found."
|
79 |
|
80 |
# -----------------------------------
|
81 |
# Step 3: Launch Gradio UI
|
@@ -88,9 +100,9 @@ iface = gr.Interface(
|
|
88 |
gr.Image(type="pil", label="Input Image"),
|
89 |
gr.Textbox(label="Camera Pose File Name (e.g., 1593596b99e2dde9.txt)"),
|
90 |
],
|
91 |
-
outputs=gr.Video(label="Generated Video"),
|
92 |
title="π₯ FloVD + CogVideoX - Camera Motion Guided Video Generation",
|
93 |
-
description="Upload an image, enter a
|
94 |
)
|
95 |
|
96 |
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
17 |
allow_patterns="ckpt/**",
|
18 |
token=hf_token,
|
19 |
)
|
|
|
20 |
|
21 |
+
print("β
Download complete.")
|
22 |
+
print("π Contents of ./ckpt directory:")
|
23 |
for root, dirs, files in os.walk("./ckpt"):
|
24 |
level = root.replace("./ckpt", "").count(os.sep)
|
25 |
indent = " " * 4 * level
|
|
|
28 |
for f in files:
|
29 |
print(f"{subindent}{f}")
|
30 |
|
|
|
31 |
# -----------------------------------
|
32 |
# Step 2: Define inference function
|
33 |
# -----------------------------------
|
|
|
46 |
os.makedirs(os.path.join(OUTPUT_PATH, "generated_videos"), exist_ok=True)
|
47 |
|
48 |
def run_flovd(prompt, image, cam_pose_name):
|
49 |
+
try:
|
50 |
+
# Save input image
|
51 |
+
image_path = "./temp_input.png"
|
52 |
+
image.save(image_path)
|
53 |
+
print(f"πΈ Image saved at {image_path}")
|
54 |
+
|
55 |
+
# Run video generation
|
56 |
+
generate_video(
|
57 |
+
prompt=prompt,
|
58 |
+
fvsm_path=FVSM_PATH,
|
59 |
+
omsm_path=OMSM_PATH,
|
60 |
+
image_path=image_path,
|
61 |
+
cam_pose_name=cam_pose_name,
|
62 |
+
output_path=OUTPUT_PATH,
|
63 |
+
controlnet_guidance_end=CONTROLNET_GUIDANCE_END,
|
64 |
+
pose_type=POSE_TYPE,
|
65 |
+
speed=SPEED,
|
66 |
+
use_flow_integration=True,
|
67 |
+
depth_ckpt_path=DEPTH_CKPT_PATH,
|
68 |
+
dtype=torch.float16,
|
69 |
+
num_frames=NUM_FRAMES,
|
70 |
+
fps=FPS,
|
71 |
+
num_inference_steps=INFER_STEPS,
|
72 |
+
)
|
73 |
+
|
74 |
+
# Construct video path
|
75 |
+
prompt_short = prompt[:30].strip().replace(" ", "_").replace(".", "").replace(",", "")
|
76 |
+
video_filename = f"{prompt_short}_{cam_pose_name}.mp4"
|
77 |
+
video_path = os.path.join(OUTPUT_PATH, "generated_videos", video_filename)
|
78 |
|
79 |
+
print(f"π Looking for generated video at: {video_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
+
if os.path.exists(video_path):
|
82 |
+
print("β
Video generation successful.")
|
83 |
+
return video_path
|
84 |
+
else:
|
85 |
+
print("β Video generation failed or file not found.")
|
86 |
+
return f"Video generation failed. Expected output file not found at: {video_path}"
|
87 |
|
88 |
+
except Exception as e:
|
89 |
+
print(f"π₯ Exception occurred: {str(e)}")
|
90 |
+
return f"An error occurred during generation: {str(e)}"
|
|
|
91 |
|
92 |
# -----------------------------------
|
93 |
# Step 3: Launch Gradio UI
|
|
|
100 |
gr.Image(type="pil", label="Input Image"),
|
101 |
gr.Textbox(label="Camera Pose File Name (e.g., 1593596b99e2dde9.txt)"),
|
102 |
],
|
103 |
+
outputs=gr.Video(label="Generated Video or Error Message"),
|
104 |
title="π₯ FloVD + CogVideoX - Camera Motion Guided Video Generation",
|
105 |
+
description="Upload an image, enter a prompt, and provide a camera pose filename to generate a video."
|
106 |
)
|
107 |
|
108 |
iface.launch(server_name="0.0.0.0", server_port=7860)
|