Korakoe commited on
Commit
75313d8
1 Parent(s): fc98e97

add viewer

Browse files
Files changed (2) hide show
  1. app.py +44 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datasets import load_dataset
3
+
4
+ dataset = load_dataset("ShoukanLabs/OpenNiji-Dataset")
5
+
6
+
7
+ startimg = 0
8
+
9
+ def get_dataset_forward():
10
+ global startimg
11
+ final = []
12
+ for idx in range(startimg, startimg + 50):
13
+ url = dataset["train"]["url"][idx]
14
+ prompt = dataset["train"]["prompt"][idx]
15
+ style = dataset["train"]["style"][idx]
16
+ final.append((url, f"{prompt}\n\n Style: {style}"))
17
+ startimg += 50
18
+ return final
19
+
20
+ def get_dataset_back():
21
+ global startimg
22
+ final = []
23
+ startimg -= 50
24
+ for idx in range(startimg, startimg + 50):
25
+ url = dataset["train"]["url"][idx]
26
+ prompt = dataset["train"]["prompt"][idx]
27
+ style = dataset["train"]["style"][idx]
28
+ final.append((url, f"{prompt}\n\n Style: {style}"))
29
+ return final
30
+
31
+ with gr.Blocks() as demo:
32
+ with gr.Column():
33
+ with gr.Row():
34
+ back = gr.Button("<").style()
35
+ forward = gr.Button(">").style()
36
+ gallery = gr.Gallery(
37
+ label="Showing 50 images", show_label=True, elem_id="gallery"
38
+ ).style(object_fit="contain", columns=[10], height="auto")
39
+
40
+ back.click(get_dataset_back, None, gallery)
41
+ forward.click(get_dataset_forward, None, gallery)
42
+
43
+ if __name__ == "__main__":
44
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ datasets