3v324v23 commited on
Commit
1ca95fd
·
1 Parent(s): bb0c99e

Add application file

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import gradio as gr
3
+ from datasets import load_dataset
4
+
5
+ def generate_random_data():
6
+ # Load the dataset with the `large_random_1k` subset
7
+ dataset = load_dataset('poloclub/diffusiondb', 'large_random_1k')
8
+ # All data are stored in the `train` split
9
+ my_1k_data = dataset['train']
10
+
11
+ random_i = np.random.choice(range(my_1k_data.num_rows))
12
+
13
+ prompt = my_1k_data['prompt'][random_i]
14
+ image = my_1k_data['image'][random_i]
15
+ # user_name = my_1k_data['user_name'][random_i]
16
+ # nsfw = my_1k_data['image_nsfw'][random_i]
17
+ seed= my_1k_data['seed'][random_i]
18
+ step=my_1k_data['step'][random_i]
19
+ cfg= my_1k_data['cfg'][random_i]
20
+ sampler= my_1k_data['sampler'][random_i]
21
+
22
+ return prompt, image, seed,step,cfg,sampler
23
+
24
+ def random_data():
25
+ prompt, image, seed,step,cfg,sampler = generate_random_data()
26
+
27
+ return prompt, image, seed,step,cfg,sampler
28
+
29
+ iface = gr.Interface(fn=random_data, inputs=None, outputs=[
30
+ gr.outputs.Textbox(label="Prompt"),
31
+ gr.outputs.Image(label="Image",type="pil"),
32
+ # gr.outputs.Textbox(label="User Name"),
33
+ # gr.outputs.Textbox(label="NSFW")
34
+ gr.outputs.Textbox(label="seed"),
35
+ gr.outputs.Textbox(label="step"),
36
+ gr.outputs.Textbox(label="cfg"),
37
+ gr.outputs.Textbox(label="sampler")
38
+
39
+
40
+ ])
41
+ iface.launch(debug=True)