Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,14 @@ pix2pix = gr.Blocks.load(name="spaces/fffiloni/instruct-pix2pix-clone", api_key=
|
|
9 |
|
10 |
def get_frames(video_in):
|
11 |
frames = []
|
12 |
-
#
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
15 |
i=0
|
16 |
while(cap.isOpened()):
|
@@ -53,12 +59,43 @@ def infer(prompt,video_in, seed_in, trim_value):
|
|
53 |
|
54 |
return final_vid
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
with gr.Blocks(css='style.css') as demo:
|
58 |
with gr.Column(elem_id="col-container"):
|
|
|
59 |
with gr.Row():
|
60 |
with gr.Column():
|
61 |
-
prompt = gr.Textbox(placeholder="enter prompt", show_label=False)
|
62 |
video_inp = gr.Video(label="Video source", source="upload", type="filepath")
|
63 |
|
64 |
with gr.Column():
|
@@ -67,7 +104,7 @@ with gr.Blocks(css='style.css') as demo:
|
|
67 |
trim_in = gr.Slider(label="Cut video at (s)", minimun=2, maximum=10, step=1, value=2)
|
68 |
video_out = gr.Video(label="Pix2pix video result")
|
69 |
submit_btn = gr.Button("Generate Pix2Pix video")
|
70 |
-
|
71 |
inputs = [prompt,video_inp,seed_inp, trim_in]
|
72 |
outputs = [video_out]
|
73 |
|
|
|
9 |
|
10 |
def get_frames(video_in):
|
11 |
frames = []
|
12 |
+
#resize the video
|
13 |
+
clip = mp.VideoFileClip(video_in)
|
14 |
+
clip_resized = clip.resize(height=512)
|
15 |
+
clip_resized.write_videofile("video_resized.mp4")
|
16 |
+
|
17 |
+
# Opens the Video file with CV2
|
18 |
+
cap= cv2.VideoCapture("video_resized.mp4")
|
19 |
+
|
20 |
fps = cap.get(cv2.CAP_PROP_FPS)
|
21 |
i=0
|
22 |
while(cap.isOpened()):
|
|
|
59 |
|
60 |
return final_vid
|
61 |
|
62 |
+
title = """
|
63 |
+
<div style="text-align: center; max-width: 700px; margin: 0 auto;">
|
64 |
+
<div
|
65 |
+
style="
|
66 |
+
display: inline-flex;
|
67 |
+
align-items: center;
|
68 |
+
gap: 0.8rem;
|
69 |
+
font-size: 1.75rem;
|
70 |
+
"
|
71 |
+
>
|
72 |
+
<h1 style="font-weight: 900; margin-bottom: 7px; margin-top: 5px;">
|
73 |
+
Pix2Pix Video
|
74 |
+
</h1>
|
75 |
+
</div>
|
76 |
+
<p style="margin-bottom: 10px; font-size: 94%">
|
77 |
+
Apply Instruct Pix2Pix Diffusion to a video
|
78 |
+
</p>
|
79 |
+
</div>
|
80 |
+
"""
|
81 |
+
|
82 |
+
article = """
|
83 |
+
|
84 |
+
<div class="footer">
|
85 |
+
<p>
|
86 |
+
|
87 |
+
Follow <a href="https://twitter.com/fffiloni" target="_blank">Sylvain Filoni</a> for future updates 🤗
|
88 |
+
</p>
|
89 |
+
</div>
|
90 |
+
|
91 |
+
"""
|
92 |
|
93 |
with gr.Blocks(css='style.css') as demo:
|
94 |
with gr.Column(elem_id="col-container"):
|
95 |
+
gr.HTML(title)
|
96 |
with gr.Row():
|
97 |
with gr.Column():
|
98 |
+
prompt = gr.Textbox(label="Prompt", placeholder="enter prompt", show_label=False)
|
99 |
video_inp = gr.Video(label="Video source", source="upload", type="filepath")
|
100 |
|
101 |
with gr.Column():
|
|
|
104 |
trim_in = gr.Slider(label="Cut video at (s)", minimun=2, maximum=10, step=1, value=2)
|
105 |
video_out = gr.Video(label="Pix2pix video result")
|
106 |
submit_btn = gr.Button("Generate Pix2Pix video")
|
107 |
+
gr.HTML(article)
|
108 |
inputs = [prompt,video_inp,seed_inp, trim_in]
|
109 |
outputs = [video_out]
|
110 |
|