Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,12 @@ from PIL import ImageFont
|
|
7 |
import gradio as gr
|
8 |
from datasets import load_dataset
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
titles = []
|
11 |
stories = []
|
12 |
|
@@ -25,6 +31,11 @@ def gallery_select(gallery, evt: gr.SelectData):
|
|
25 |
print(evt.index)
|
26 |
print(evt.target)
|
27 |
|
|
|
|
|
|
|
|
|
|
|
28 |
def get_gallery():
|
29 |
global titles, stories
|
30 |
|
@@ -45,13 +56,17 @@ def get_gallery():
|
|
45 |
print(titles)
|
46 |
return images
|
47 |
|
48 |
-
with gr.Blocks() as demo:
|
49 |
gallery = gr.Gallery(get_gallery, every=3600, columns=10, height=500, container=False)
|
50 |
|
|
|
|
|
|
|
|
|
51 |
gallery.select(
|
52 |
fn=gallery_select,
|
53 |
inputs=[gallery],
|
54 |
-
outputs=
|
55 |
)
|
56 |
|
57 |
demo.launch()
|
|
|
7 |
import gradio as gr
|
8 |
from datasets import load_dataset
|
9 |
|
10 |
+
STYLES = """
|
11 |
+
.center {
|
12 |
+
text-align: center;
|
13 |
+
}
|
14 |
+
"""
|
15 |
+
|
16 |
titles = []
|
17 |
stories = []
|
18 |
|
|
|
31 |
print(evt.index)
|
32 |
print(evt.target)
|
33 |
|
34 |
+
return [
|
35 |
+
gr.update(value=titles[evt.index], visible=True),
|
36 |
+
gr.update(value=stories[evt.index], visible=True),
|
37 |
+
]
|
38 |
+
|
39 |
def get_gallery():
|
40 |
global titles, stories
|
41 |
|
|
|
56 |
print(titles)
|
57 |
return images
|
58 |
|
59 |
+
with gr.Blocks(css=STYLES) as demo:
|
60 |
gallery = gr.Gallery(get_gallery, every=3600, columns=10, height=500, container=False)
|
61 |
|
62 |
+
with gr.Column():
|
63 |
+
title = gr.Markdown("title", visible=False, elem_classes=['center'])
|
64 |
+
story = gr.Markdown("stories goes here...", visible=False)
|
65 |
+
|
66 |
gallery.select(
|
67 |
fn=gallery_select,
|
68 |
inputs=[gallery],
|
69 |
+
outputs=[title, story]
|
70 |
)
|
71 |
|
72 |
demo.launch()
|