Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -137,7 +137,71 @@ examples = [
|
|
137 |
def use_prompt_and_image(prompt, image):
|
138 |
return prompt, image
|
139 |
|
140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
|
143 |
|
|
|
137 |
def use_prompt_and_image(prompt, image):
|
138 |
return prompt, image
|
139 |
|
140 |
+
with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
141 |
+
with gr.Tab("Generate"):
|
142 |
+
with gr.Row():
|
143 |
+
input_image = gr.Image(label="Upload an image", type="filepath")
|
144 |
+
input_text = gr.Textbox(label="Enter your prompt for video generation")
|
145 |
+
output_video = gr.Video(label="Generated Video")
|
146 |
+
|
147 |
+
with gr.Row():
|
148 |
+
steps = gr.Slider(minimum=1, maximum=100, step=1, label="Steps", value=30)
|
149 |
+
cfg_scale = gr.Slider(minimum=1, maximum=15, step=0.1, label="CFG Scale", value=3.5)
|
150 |
+
eta = gr.Slider(minimum=0, maximum=1, step=0.1, label="ETA", value=1)
|
151 |
+
fs = gr.Slider(minimum=1, maximum=30, step=1, label="FPS", value=8)
|
152 |
+
seed = gr.Slider(minimum=0, maximum=1000000, step=1, label="Seed", value=123)
|
153 |
+
video_length = gr.Slider(minimum=1, maximum=10, step=1, label="Video Length (seconds)", value=2)
|
154 |
+
|
155 |
+
with gr.Row():
|
156 |
+
for prompt, image_file in examples:
|
157 |
+
with gr.Column():
|
158 |
+
gr.Image(image_file, label=prompt[:50] + "...")
|
159 |
+
gr.Button("Use this example").click(
|
160 |
+
fn=use_prompt_and_image,
|
161 |
+
inputs=[],
|
162 |
+
outputs=[input_text, input_image],
|
163 |
+
api_name=False
|
164 |
+
).then(
|
165 |
+
lambda p=prompt, i=image_file: (p, i),
|
166 |
+
inputs=[],
|
167 |
+
outputs=[input_text, input_image]
|
168 |
+
)
|
169 |
+
|
170 |
+
with gr.Tab("Gallery"):
|
171 |
+
gallery = gr.Gallery(
|
172 |
+
label="Generated Videos",
|
173 |
+
show_label=False,
|
174 |
+
elem_id="gallery",
|
175 |
+
columns=[5],
|
176 |
+
rows=[3],
|
177 |
+
object_fit="contain",
|
178 |
+
height="auto"
|
179 |
+
)
|
180 |
+
selected_video = gr.Video(label="Selected Video")
|
181 |
+
refresh_btn = gr.Button("Refresh Gallery")
|
182 |
+
|
183 |
+
def update_gallery():
|
184 |
+
return load_gallery()
|
185 |
+
|
186 |
+
def show_video(evt: gr.SelectData):
|
187 |
+
return evt.value[2] # ์ ํ๋ ์ธ๋ค์ผ์ ํด๋นํ๋ ๋น๋์ค ๊ฒฝ๋ก ๋ฐํ
|
188 |
+
|
189 |
+
refresh_btn.click(fn=update_gallery, inputs=None, outputs=gallery)
|
190 |
+
demo.load(fn=update_gallery, inputs=None, outputs=gallery)
|
191 |
+
gallery.select(show_video, None, selected_video)
|
192 |
+
|
193 |
+
input_text.submit(
|
194 |
+
fn=respond,
|
195 |
+
inputs=[input_image, input_text, steps, cfg_scale, eta, fs, seed, video_length],
|
196 |
+
outputs=output_video
|
197 |
+
).then(
|
198 |
+
fn=update_gallery,
|
199 |
+
inputs=None,
|
200 |
+
outputs=gallery
|
201 |
+
)
|
202 |
+
|
203 |
+
if __name__ == "__main__":
|
204 |
+
demo.launch()
|
205 |
|
206 |
|
207 |
|