File size: 4,213 Bytes
f7aaf13
 
 
2a1796e
d5e9784
2a1796e
f7aaf13
f85ee74
cde30f5
a914ec3
f7aaf13
b9d582e
f78dae6
b9d582e
a914ec3
7870e4d
b9d582e
93012d4
f3df312
 
78bb796
aa7c559
f3df312
 
 
b46a61b
dfe811e
0c53059
 
b4b82c5
5659e81
b4b82c5
 
0cfb934
f3df312
b4b82c5
0cfb934
 
a80fa65
 
 
aa7c559
 
 
0cfb934
 
11832ea
6f0fdf8
f3df312
 
0cfb934
78bb796
a80fa65
11832ea
0cfb934
b9d582e
3877f46
b9d582e
 
 
 
 
ca8adc9
588563e
ca8adc9
 
5626622
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import gradio as gr

dictionary = {
    "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.",
    "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"
    }

def chatgpt(query):
    return dictionary[query]

def generateimage1(query):
    return query.replace(' ', '-') + '.png'

def generateimage2(query):
    return query.replace(' ', '-') + '-chatgpt.png'

title = "# ChatPrompt: Unleash the power of Stable Diffusion with ChatGPT 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. 
(Work by [@shogi880](https://github.com/shogi880),[@CR-Gjx](https://github.com/CR-Gjx))
"""

example = """
### Note: we don't implement the ChatGPT and Stable Diffusion pipeline.
### To get ChatPrompt with following prompts ([ChatGPT](https://chat.openai.com)):
- `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:` 

### Then try ChatPrompt 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)
- Anime Character Design with SD [(AI Mage)](https://aimage.xyz)
"""

co_create_magicprompt = """
### Co-create with ChatPrompt and MagicPrompt.
Compare with [Magicprompt](https://huggingface.co/spaces/Gustavosta/MagicPrompt-Stable-Diffusion), we augment detail content prompts instead of visual prompts."""

i_spy_a_metaphor = """
### Compare with [I Spy a Metaphor: Large Language Models and Diffusion Models Co-Create Visual Metaphors](https://openreview.net/forum?id=_2SBqIkiDW).
We aim to utilize ChatGPT in zero-shot setting.
We recently became aware of this concurrent work and find it interesting (Feb 5 2023).
"""

concept_image = "![The concept of co-creative ChatPrompt and MagicPrompt](https://huggingface.co/spaces/shogi880/ChatGPT-StableDiffusion-CharacterDesign/resolve/main/co-create-magic.png)"
with gr.Blocks() as demo:
    gr.Markdown(title)
    gr.Markdown(description)
    gr.Markdown(co_create_magicprompt)
    gr.Markdown(concept_image)
    gr.Markdown(i_spy_a_metaphor)
    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()