Spaces:
Runtime error
Runtime error
File size: 2,439 Bytes
f7aaf13 d5e9784 f7aaf13 f85ee74 cde30f5 f85ee74 2906703 f85ee74 2906703 f85ee74 f7aaf13 b9d582e 6f0fdf8 ff8ba73 b9d582e a03f1b8 b9d582e 6f0fdf8 b9d582e ff8ba73 6f0fdf8 |
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 50 51 52 |
import gradio as gr
dictionary = {
"a playful man": "A young man in his mid-20s to early 30s, Has a playful and energetic demeanor, with a big smile always on his face, Has a lean and athletic build, Has messy, yet stylish hair that is always styled in a way that makes it look like he just got out of bed, Has a playful twinkle in his eye, and a hint of mischief in his expression, Wears casual, comfortable clothing that is both stylish and practical,Often seen with a bag or backpack, as if he's always ready for an adventure",
"a calm woman": "A reserved and collected woman with a soft spoken voice and gentle demeanor. She carries herself with grace and poise, always appearing calm and in control, even in stressful situations. Her appearance is polished and put together, with a preference for understated elegance. She is kind and empathetic, and her presence brings a sense of peace to those around her.",
"a boy who is bullied": "todo"
}
def chatgpt(query):
try:
output = dictionary[query]
except:
output = "Please try: https://chat.openai.com"
return output
def generateimage1(query):
try:
output = dictionary[query]
except:
output = "Please try: https://chat.openai.com"
return output
def generateimage2(query):
try:
output = dictionary[query]
except:
output = "Please try: https://chat.openai.com"
return output
with gr.Blocks() as demo:
gr.Markdown("Ask **ChatGPT** to generate detailed descriptbions.")
gr.Markdown("Example: Act as a professional character designer. Please generate prompts include detail appearance descriptions that related to the personality. Here's your first question: 'a gentle man':")
with gr.Row():
inpprompt = gr.Dropdown(list(dictionary.keys()))
outprompt = gr.Textbox()
btn = gr.Button("Generate mode detailed description.")
btn.click(fn=chatgpt, inputs=inpprompt, outputs=outprompt)
gr.Markdown("Ask **Stable Diffusion** to generate images.")
with gr.Row():
out1image = gr.Image()
out2image = gr.Image()
with gr.Row():
btn1 = gr.Button("Generate image with origial prompt.")
btn2 = gr.Button("Generate image with ChatGPT's prompt.")
btn1.click(fn=generateimage1, inputs=inpprompt, outputs=out1image)
btn2.click(fn=generateimage2, inputs=outprompt, outputs=out2image)
demo.launch() |