File size: 776 Bytes
3f15bce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json 
import gradio as gr

with open('all_styles.json', encoding='utf-8') as file:
    styles = json.load(file)

all_styles = list(styles.keys())


def apply_style(prompt, style):
    style_prompt, neg_prompt = styles.get(style, (None, None))

    if style_prompt:
        prompt = style_prompt.replace('{prompt}', prompt)
        return prompt, neg_prompt
    else:    
        return prompt, ''


demo = gr.Interface(
    fn=apply_style,
    inputs=[gr.Text(value='', placeholder='your prompt'), gr.Dropdown(label="Style", choices=all_styles, value=all_styles[0])],
    outputs=[gr.Textbox(label='Prompt', show_copy_button=True), gr.Textbox(label='Negative Prompt', show_copy_button=True)],
    title='Stylize your prompt',
    allow_flagging='never'
)

demo.launch()