shogi880's picture
Update app.py
4611135
raw
history blame
No virus
3.44 kB
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",
"an easygoing man": "A man in his late 20s to early 40s, Has an easygoing and relaxed demeanor, with a friendly smile and a laid-back attitude, Has an average build, not overly muscular nor skinny, Has well-groomed hair, styled in a way that makes him look approachable and friendly, Has a calm and content expression, with a hint of serenity in his eyes, Wears clothing that is comfortable and practical, with a preference for casual styles and earthy colors, Often seen with a guitar or a backpack, as if he's always ready for an impromptu adventure or a jam session",
"a boy who is bullied": "Young boy, around the age of 12, with a small frame, wearing worn and untidy clothes, with a slouching posture, sitting alone in a corner, with a sad and defeated expression on his face."
}
def chatgpt(query):
return dictionary[query]
def generateimage1(query):
return query.replace(' ', '-') + '.png'
def generateimage2(query):
return query.replace(' ', '-') + '-chatgpt.png'
title = "# Unleash the power of Stable Diffusion with [ChatGPT](https://chat.openai.com) and conquer abstract prompts!"
description = """
Stable Diffusion struggles with unclear and vague prompts, but by harnessing the advanced reasoning capabilities of ChatGPT. We can generate detailed and descriptive prompts for improved and unparalleled generation results.
"""
example = """
[ChatGPT](https://chat.openai.com) Prompt Examples:
- `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':`
- `Please generate detailed prompts from abstract prompts. "a gentle man". Let's think step by step:`
- `Please generate prompt for character design. Let's think step by step: First, check the basic information. Then, generate prompt includes detail descriptions that related to the personality. Finally, summery the prompt in 30 words. Here's your first question: "a man who is the INFP of MBTI personality test":`
Try on free SD spaces:
- [Stabilityai/Stable-Diffusion-2.1](https://huggingface.co/spaces/stabilityai/stable-diffusion)
- [runwayml/Stable-Diffusion-v1-5](https://huggingface.co/spaces/pujianto17/runwayml-stable-diffusion-v1-5)
- [AI Mage](https://aimage.xyz)
"""
with gr.Blocks() as demo:
gr.Markdown(title)
gr.Markdown(description)
gr.Markdown(example)
with gr.Row():
inpprompt = gr.Dropdown(list(dictionary.keys()), value=list(dictionary.keys())[0])
outprompt = gr.Textbox()
with gr.Row():
out1image = gr.Image()
out2image = gr.Image()
btn = gr.Button("Show me the result!")
btn.click(fn=chatgpt, inputs=inpprompt, outputs=outprompt)
btn.click(fn=generateimage1, inputs=inpprompt, outputs=out1image)
btn.click(fn=generateimage2, inputs=inpprompt, outputs=out2image)
demo.launch()