Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,12 +8,19 @@ pipe = DiffusionPipeline.from_pretrained("cerspense/zeroscope_v2_576w", torch_dt
|
|
8 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
9 |
pipe.enable_model_cpu_offload()
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
video_frames = pipe(prompt, num_inference_steps=40, height=320, width=576, num_frames=24).frames
|
14 |
video_path = export_to_video(video_frames)
|
15 |
print(video_path)
|
16 |
-
return video_path, gr.Group.update(visible=True)
|
17 |
|
18 |
css = """
|
19 |
#col-container {max-width: 510px; margin-left: auto; margin-right: auto;}
|
@@ -84,19 +91,21 @@ with gr.Blocks(css=css) as demo:
|
|
84 |
with gr.Column(elem_id="col-container"):
|
85 |
gr.Markdown(
|
86 |
"""
|
87 |
-
<h1 style="text-align: center;">Zeroscope
|
88 |
<p style="text-align: center;">
|
89 |
A watermark-free Modelscope-based video model optimized for producing high-quality 16:9 compositions and a smooth video output. <br />
|
|
|
90 |
</p>
|
91 |
|
92 |
-
[![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm.svg#center)](https://huggingface.co/spaces/fffiloni/zeroscope?duplicate=true)
|
93 |
|
94 |
"""
|
95 |
)
|
96 |
|
97 |
-
|
98 |
#inference_steps = gr.Slider(label="Inference Steps", minimum=10, maximum=100, step=1, value=40, interactive=False)
|
99 |
submit_btn = gr.Button("Submit")
|
|
|
100 |
video_result = gr.Video(label="Video Output", elem_id="video-output")
|
101 |
|
102 |
with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
|
@@ -105,8 +114,8 @@ with gr.Blocks(css=css) as demo:
|
|
105 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
106 |
|
107 |
submit_btn.click(fn=infer,
|
108 |
-
inputs=[
|
109 |
-
outputs=[video_result, share_group])
|
110 |
|
111 |
share_button.click(None, [], [], _js=share_js)
|
112 |
|
|
|
8 |
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
|
9 |
pipe.enable_model_cpu_offload()
|
10 |
|
11 |
+
caption = gr.load(name="spaces/fffiloni/CoCa-clone")
|
12 |
+
|
13 |
+
def create_image_caption(image_init):
|
14 |
+
cap = caption(image_init, "Beam search", 1.2, 0.5, 5, 20, fn_index=0)
|
15 |
+
print("cap: " + cap)
|
16 |
+
return cap
|
17 |
+
|
18 |
+
def infer(image_init):
|
19 |
+
prompt = create_image_caption(image_init)
|
20 |
video_frames = pipe(prompt, num_inference_steps=40, height=320, width=576, num_frames=24).frames
|
21 |
video_path = export_to_video(video_frames)
|
22 |
print(video_path)
|
23 |
+
return prompt, video_path, gr.Group.update(visible=True)
|
24 |
|
25 |
css = """
|
26 |
#col-container {max-width: 510px; margin-left: auto; margin-right: auto;}
|
|
|
91 |
with gr.Column(elem_id="col-container"):
|
92 |
gr.Markdown(
|
93 |
"""
|
94 |
+
<h1 style="text-align: center;">Zeroscope Image-to-Video</h1>
|
95 |
<p style="text-align: center;">
|
96 |
A watermark-free Modelscope-based video model optimized for producing high-quality 16:9 compositions and a smooth video output. <br />
|
97 |
+
This demo is a variation that lets you upload an image as reference for video generation.
|
98 |
</p>
|
99 |
|
100 |
+
[![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/raw/main/duplicate-this-space-sm.svg#center)](https://huggingface.co/spaces/fffiloni/zeroscope-img-to-video?duplicate=true)
|
101 |
|
102 |
"""
|
103 |
)
|
104 |
|
105 |
+
image_init = gr.Image(label="Image Init",type="filepath", source="upload", elem_id="image-init")
|
106 |
#inference_steps = gr.Slider(label="Inference Steps", minimum=10, maximum=100, step=1, value=40, interactive=False)
|
107 |
submit_btn = gr.Button("Submit")
|
108 |
+
coca_cap = gr.Textbox(label="Caption", placeholder="CoCa Caption will be displayed here", elem_id="coca-cap-in")
|
109 |
video_result = gr.Video(label="Video Output", elem_id="video-output")
|
110 |
|
111 |
with gr.Group(elem_id="share-btn-container", visible=False) as share_group:
|
|
|
114 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
115 |
|
116 |
submit_btn.click(fn=infer,
|
117 |
+
inputs=[image_init],
|
118 |
+
outputs=[coca_cap, video_result, share_group])
|
119 |
|
120 |
share_button.click(None, [], [], _js=share_js)
|
121 |
|