Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -4,51 +4,53 @@ from gradio_client import Client, handle_file
|
|
4 |
def generate_video(input_image, prompt, negative_prompt, diffusion_step, height, width, scfg_scale, use_dctinit, dct_coefficients, noise_level, motion_bucket_id, seed):
|
5 |
client = Client("maxin-cn/Cinemo")
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
return
|
|
|
|
|
28 |
|
29 |
-
#
|
30 |
with gr.Blocks() as demo:
|
31 |
with gr.Row():
|
32 |
input_image = gr.Image(label="Input Image", type="filepath")
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
generate_btn = gr.Button("Generate Video")
|
48 |
-
|
49 |
-
output_video = gr.Video(label="Generated Video")
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
demo.launch(show_error=True)
|
|
|
4 |
def generate_video(input_image, prompt, negative_prompt, diffusion_step, height, width, scfg_scale, use_dctinit, dct_coefficients, noise_level, motion_bucket_id, seed):
|
5 |
client = Client("maxin-cn/Cinemo")
|
6 |
|
7 |
+
result = client.predict(
|
8 |
+
input_image=handle_file(input_image),
|
9 |
+
prompt=prompt,
|
10 |
+
negative_prompt=negative_prompt,
|
11 |
+
diffusion_step=diffusion_step,
|
12 |
+
height=height,
|
13 |
+
width=width,
|
14 |
+
scfg_scale=scfg_scale,
|
15 |
+
use_dctinit=use_dctinit,
|
16 |
+
dct_coefficients=dct_coefficients,
|
17 |
+
noise_level=noise_level,
|
18 |
+
motion_bucket_id=motion_bucket_id,
|
19 |
+
seed=seed,
|
20 |
+
api_name="/gen_video"
|
21 |
+
)
|
22 |
+
print("API response" , result)
|
23 |
+
|
24 |
+
video_path = result.get('video') # Extract the video file path from the API response
|
25 |
+
|
26 |
+
if video_path is None:
|
27 |
+
return "The API did not return a valid video. Please try again."
|
28 |
+
|
29 |
+
return video_path # Return the path to the video file
|
30 |
|
31 |
+
# Gradio Interface
|
32 |
with gr.Blocks() as demo:
|
33 |
with gr.Row():
|
34 |
input_image = gr.Image(label="Input Image", type="filepath")
|
35 |
+
with gr.Row():
|
36 |
+
prompt = gr.Textbox(label="Prompt")
|
37 |
+
negative_prompt = gr.Textbox(label="Negative Prompt")
|
38 |
+
with gr.Row():
|
39 |
+
diffusion_step = gr.Slider(label="Sampling steps", minimum=1, maximum=100, value=50)
|
40 |
+
height = gr.Slider(label="Height", minimum=64, maximum=1024, value=320)
|
41 |
+
width = gr.Slider(label="Width", minimum=64, maximum=1024, value=512)
|
42 |
+
scfg_scale = gr.Slider(label="CFG Scale", minimum=1, maximum=20, value=7.5)
|
43 |
+
with gr.Row():
|
44 |
+
use_dctinit = gr.Checkbox(label="Enable DCTInit", value=True)
|
45 |
+
dct_coefficients = gr.Slider(label="DCT Coefficients", minimum=0.0, maximum=1.0, value=0.23)
|
46 |
+
noise_level = gr.Slider(label="Noise Level", minimum=0, maximum=1000, value=985)
|
47 |
+
motion_bucket_id = gr.Slider(label="Motion Intensity", minimum=0, maximum=20, value=10)
|
48 |
+
seed = gr.Number(label="Seed", value=100)
|
|
|
|
|
|
|
49 |
|
50 |
+
video_output = gr.Video(label="Generated Video")
|
51 |
+
|
52 |
+
generate_button = gr.Button("Generate Video")
|
53 |
+
|
54 |
+
generate_button.click(generate_video, inputs=[input_image, prompt, negative_prompt, diffusion_step, height, width, scfg_scale, use_dctinit, dct_coefficients, noise_level, motion_bucket_id, seed], outputs=video_output)
|
55 |
|
56 |
+
demo.launch()
|
|