File size: 1,510 Bytes
1ca95fd
 
 
 
 
 
 
 
 
 
 
 
 
 
83a8070
 
 
 
1ca95fd
83a8070
1ca95fd
 
83a8070
1ca95fd
83a8070
 
 
 
 
 
 
 
 
 
 
 
 
1ca95fd
 
 
a1e747c
83a8070
 
 
 
a1e747c
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import numpy as np
import gradio as gr
from datasets import load_dataset

def generate_random_data():
    # Load the dataset with the `large_random_1k` subset
    dataset = load_dataset('poloclub/diffusiondb', 'large_random_1k')
    # All data are stored in the `train` split
    my_1k_data = dataset['train']
    
    random_i = np.random.choice(range(my_1k_data.num_rows))
    
    prompt = my_1k_data['prompt'][random_i]
    image = my_1k_data['image'][random_i]
    seed = my_1k_data['seed'][random_i]
    step = my_1k_data['step'][random_i]
    cfg = my_1k_data['cfg'][random_i]
    sampler = my_1k_data['sampler'][random_i]
    
    return prompt, image, seed, step, cfg, sampler

def random_data():
    prompt, image, seed, step, cfg, sampler = generate_random_data()
    
    data = {
        'Prompt': prompt,
        'Seed': seed,
        'Step': step,
        'CFG': cfg,
        'Sampler': sampler
    }
    
    with open("random_data.txt", "w") as file:
        for key, value in data.items():
            file.write(f"{key}: {value}\n")
    
    return prompt, image, seed, step, cfg, sampler

iface = gr.Interface(fn=random_data, inputs=None, outputs=[
    gr.outputs.Textbox(label="Prompt"),
    gr.outputs.Image(label="Image", type="pil"),
    gr.outputs.Textbox(label="Seed"),
    gr.outputs.Textbox(label="Step"),
    gr.outputs.Textbox(label="CFG"),
    gr.outputs.Textbox(label="Sampler")
], title="Stable Diffusion DB", description="By Falah.G.S AI Developer")

iface.launch(debug=True)