Update app.py
Browse files
app.py
CHANGED
@@ -36,32 +36,39 @@ import os
|
|
36 |
from inference.flovd_demo import generate_video
|
37 |
|
38 |
def run_inference(prompt, image, pose_type, speed, use_flow_integration, cam_pose_name):
|
39 |
-
|
40 |
-
|
41 |
-
|
|
|
42 |
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
with gr.Blocks() as demo:
|
67 |
gr.Markdown("## 🎥 FloVD: Optical Flow + CogVideoX Video Generation")
|
|
|
36 |
from inference.flovd_demo import generate_video
|
37 |
|
38 |
def run_inference(prompt, image, pose_type, speed, use_flow_integration, cam_pose_name):
|
39 |
+
try:
|
40 |
+
os.makedirs("input_images", exist_ok=True)
|
41 |
+
image_path = "input_images/input_image.png"
|
42 |
+
image.save(image_path)
|
43 |
|
44 |
+
generate_video(
|
45 |
+
prompt=prompt,
|
46 |
+
image_path=image_path,
|
47 |
+
fvsm_path="./ckpt/FVSM/FloVD_FVSM_Controlnet.pt",
|
48 |
+
omsm_path="./ckpt/OMSM",
|
49 |
+
output_path="./outputs",
|
50 |
+
num_frames=49,
|
51 |
+
fps=16,
|
52 |
+
width=None,
|
53 |
+
height=None,
|
54 |
+
seed=42,
|
55 |
+
guidance_scale=6.0,
|
56 |
+
dtype=torch.float16,
|
57 |
+
controlnet_guidance_end=0.4,
|
58 |
+
use_dynamic_cfg=False,
|
59 |
+
pose_type=pose_type,
|
60 |
+
speed=float(speed),
|
61 |
+
use_flow_integration=use_flow_integration,
|
62 |
+
cam_pose_name=cam_pose_name,
|
63 |
+
depth_ckpt_path="./ckpt/others/depth_anything_v2_metric_hypersim_vitb.pth"
|
64 |
+
)
|
65 |
+
return f"./outputs/generated_videos/{prompt[:30].strip().replace(' ', '_')}_{cam_pose_name or 'default'}.mp4"
|
66 |
+
|
67 |
+
except Exception as e:
|
68 |
+
print("🔥 Inference failed:")
|
69 |
+
import traceback
|
70 |
+
traceback.print_exc()
|
71 |
+
return f"⚠️ Error during inference: {e}"
|
72 |
|
73 |
with gr.Blocks() as demo:
|
74 |
gr.Markdown("## 🎥 FloVD: Optical Flow + CogVideoX Video Generation")
|