File size: 1,041 Bytes
b33ef04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68cd5f5
b33ef04
 
 
 
 
 
 
 
2fa7462
b33ef04
 
 
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
import random
import yaml
import gradio as gr

def generate_text():
    input_data = get_options('data.yaml')
    command = input_data['command']
    for key in input_data.keys():
        if key != 'command':
            command = command.replace(f'[{key}]', input_data[key][random.randint(0, len(input_data[key]) - 1)])
    return command

def get_options(file_path):
    with open(file_path, 'r') as file:
        options = yaml.load(file, Loader=yaml.FullLoader)
    return options

iface = gr.Interface(
    fn=generate_text,
    inputs=None,
    outputs=gr.outputs.Textbox(label="Generated Text"),
    title="Beautiful Fantastic  AI Prompts Generator",
    description="Generates a random Prompts for Fantasy Stunning Images for Stable Diffusion Model",
    allow_flagging=False,
    theme="compact",
    examples=[
        ["Generate"],
        ["Generate"],
        ["Generate"]
    ],
    # Add image to the interface
    image="https://iraqprogrammer.files.wordpress.com/2023/03/00045-3227812873.png?w=512&h=512"
)

iface.launch()