Spaces:
Sleeping
Sleeping
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() |