Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import gradio as
|
2 |
import os
|
3 |
import cv2
|
4 |
import numpy as np
|
@@ -98,13 +98,13 @@ def create_video(frames, fps):
|
|
98 |
return 'movie.mp4'
|
99 |
|
100 |
|
101 |
-
def infer(prompt,video_in, seed_in, trim_value):
|
102 |
print(prompt)
|
103 |
break_vid = get_frames(video_in)
|
104 |
|
105 |
-
frames_list= break_vid[0]
|
106 |
fps = break_vid[1]
|
107 |
-
n_frame = int(trim_value*fps)
|
108 |
|
109 |
if n_frame >= len(frames_list):
|
110 |
print("video is shorter than the cut value")
|
@@ -117,11 +117,6 @@ def infer(prompt,video_in, seed_in, trim_value):
|
|
117 |
pil_i = Image.open(i).convert("RGB")
|
118 |
|
119 |
pix2pix_img = pix2pix(pil_i, prompt, 50, seed_in, 7.5, 1.5)
|
120 |
-
#print(pix2pix_img)
|
121 |
-
#image = Image.open(pix2pix_img)
|
122 |
-
#rgb_im = image.convert("RGB")
|
123 |
-
|
124 |
-
# exporting the image
|
125 |
pix2pix_img.save(f"result_img-{i}.jpg")
|
126 |
result_frames.append(f"result_img-{i}.jpg")
|
127 |
print("frame " + i + "/" + str(n_frame) + ": done;")
|
@@ -184,7 +179,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
184 |
prompt = gr.Textbox(label="Prompt", placeholder="enter prompt", show_label=False, elem_id="prompt-in")
|
185 |
with gr.Row():
|
186 |
seed_inp = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, value=123456)
|
187 |
-
trim_in = gr.Slider(label="Cut video at (s)",
|
188 |
with gr.Column():
|
189 |
video_out = gr.Video(label="Pix2pix video result", elem_id="video-output")
|
190 |
gr.HTML("""
|
@@ -198,25 +193,12 @@ with gr.Blocks(css='style.css') as demo:
|
|
198 |
loading_icon = gr.HTML(loading_icon_html)
|
199 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
200 |
|
201 |
-
inputs = [prompt,video_inp,seed_inp, trim_in]
|
202 |
outputs = [video_out, share_group]
|
203 |
|
204 |
-
#ex = gr.Examples(
|
205 |
-
# [
|
206 |
-
# ["Make it a marble sculpture", "./examples/pexels-jill-burrow-7665249_512x512.mp4", 422112651, 4],
|
207 |
-
# ["Make it molten lava", "./examples/Ocean_Pexels_ 8953474_512x512.mp4", 43571876, 4]
|
208 |
-
# ],
|
209 |
-
# inputs=inputs,
|
210 |
-
# outputs=outputs,
|
211 |
-
# fn=infer,
|
212 |
-
# cache_examples=True,
|
213 |
-
#)
|
214 |
-
|
215 |
gr.HTML(article)
|
216 |
|
217 |
submit_btn.click(infer, inputs, outputs)
|
218 |
share_button.click(None, [], [], _js=share_js)
|
219 |
-
|
220 |
-
|
221 |
|
222 |
demo.queue(max_size=12).launch()
|
|
|
1 |
+
import gradio as
|
2 |
import os
|
3 |
import cv2
|
4 |
import numpy as np
|
|
|
98 |
return 'movie.mp4'
|
99 |
|
100 |
|
101 |
+
def infer(prompt, video_in, seed_in, trim_value):
|
102 |
print(prompt)
|
103 |
break_vid = get_frames(video_in)
|
104 |
|
105 |
+
frames_list = break_vid[0]
|
106 |
fps = break_vid[1]
|
107 |
+
n_frame = int(trim_value * fps)
|
108 |
|
109 |
if n_frame >= len(frames_list):
|
110 |
print("video is shorter than the cut value")
|
|
|
117 |
pil_i = Image.open(i).convert("RGB")
|
118 |
|
119 |
pix2pix_img = pix2pix(pil_i, prompt, 50, seed_in, 7.5, 1.5)
|
|
|
|
|
|
|
|
|
|
|
120 |
pix2pix_img.save(f"result_img-{i}.jpg")
|
121 |
result_frames.append(f"result_img-{i}.jpg")
|
122 |
print("frame " + i + "/" + str(n_frame) + ": done;")
|
|
|
179 |
prompt = gr.Textbox(label="Prompt", placeholder="enter prompt", show_label=False, elem_id="prompt-in")
|
180 |
with gr.Row():
|
181 |
seed_inp = gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, value=123456)
|
182 |
+
trim_in = gr.Slider(label="Cut video at (s)", minimum=1, maximum=50, step=1, value=5) # Updated here
|
183 |
with gr.Column():
|
184 |
video_out = gr.Video(label="Pix2pix video result", elem_id="video-output")
|
185 |
gr.HTML("""
|
|
|
193 |
loading_icon = gr.HTML(loading_icon_html)
|
194 |
share_button = gr.Button("Share to community", elem_id="share-btn")
|
195 |
|
196 |
+
inputs = [prompt, video_inp, seed_inp, trim_in]
|
197 |
outputs = [video_out, share_group]
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
gr.HTML(article)
|
200 |
|
201 |
submit_btn.click(infer, inputs, outputs)
|
202 |
share_button.click(None, [], [], _js=share_js)
|
|
|
|
|
203 |
|
204 |
demo.queue(max_size=12).launch()
|