Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -177,38 +177,27 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
177 |
outputs=[input_text, input_image]
|
178 |
)
|
179 |
|
|
|
|
|
180 |
with gr.Tab("Gallery"):
|
181 |
-
|
182 |
-
label="Generated Videos",
|
183 |
-
show_label=False,
|
184 |
-
elem_id="gallery",
|
185 |
-
columns=5,
|
186 |
-
rows=3,
|
187 |
-
object_fit="contain",
|
188 |
-
height="auto",
|
189 |
-
preview=True
|
190 |
-
)
|
191 |
selected_video = gr.Video(label="Selected Video")
|
192 |
refresh_btn = gr.Button("Refresh Gallery")
|
193 |
|
194 |
-
|
195 |
-
|
196 |
def update_gallery():
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
def show_video(evt: gr.SelectData):
|
200 |
-
|
201 |
-
return evt.value['image']['path']
|
202 |
-
elif isinstance(evt.value, str):
|
203 |
-
return evt.value
|
204 |
-
else:
|
205 |
-
logging.error(f"Unexpected evt.value structure: {evt.value}")
|
206 |
-
return None
|
207 |
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
gallery.select(show_video, None, selected_video)
|
212 |
|
213 |
input_text.submit(
|
214 |
fn=respond,
|
@@ -217,11 +206,9 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
217 |
).then(
|
218 |
fn=update_gallery,
|
219 |
inputs=None,
|
220 |
-
outputs=
|
221 |
)
|
222 |
|
223 |
if __name__ == "__main__":
|
224 |
demo.launch()
|
225 |
-
|
226 |
-
|
227 |
-
|
|
|
177 |
outputs=[input_text, input_image]
|
178 |
)
|
179 |
|
180 |
+
|
181 |
+
|
182 |
with gr.Tab("Gallery"):
|
183 |
+
gallery_html = gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
selected_video = gr.Video(label="Selected Video")
|
185 |
refresh_btn = gr.Button("Refresh Gallery")
|
186 |
|
|
|
|
|
187 |
def update_gallery():
|
188 |
+
gallery_items = load_gallery()
|
189 |
+
html = "<div style='display: flex; flex-wrap: wrap;'>"
|
190 |
+
for item in gallery_items:
|
191 |
+
html += f"<div style='margin: 10px;'><video width='200' height='200' controls><source src='{item['image']}' type='video/mp4'></video><p>{item['caption']}</p></div>"
|
192 |
+
html += "</div>"
|
193 |
+
return html
|
194 |
|
195 |
def show_video(evt: gr.SelectData):
|
196 |
+
return evt.target.src
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
|
198 |
+
refresh_btn.click(fn=update_gallery, inputs=None, outputs=gallery_html)
|
199 |
+
demo.load(fn=update_gallery, inputs=None, outputs=gallery_html)
|
200 |
+
gallery_html.click(show_video, None, selected_video)
|
|
|
201 |
|
202 |
input_text.submit(
|
203 |
fn=respond,
|
|
|
206 |
).then(
|
207 |
fn=update_gallery,
|
208 |
inputs=None,
|
209 |
+
outputs=gallery_html
|
210 |
)
|
211 |
|
212 |
if __name__ == "__main__":
|
213 |
demo.launch()
|
214 |
+
|
|
|
|