Spaces:
Running
on
Zero
Running
on
Zero
alfredplpl
commited on
Commit
•
24b4440
1
Parent(s):
e4dd967
Update app.py
Browse files
app.py
CHANGED
@@ -37,11 +37,11 @@ def error_str(error, title="Error"):
|
|
37 |
{error}""" if error else ""
|
38 |
|
39 |
|
40 |
-
def inference(prompt, guidance, steps, image_size="Square", seed=0, img=None, strength=0.5, neg_prompt="",
|
41 |
|
42 |
generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
|
43 |
|
44 |
-
prompt,neg_prompt=auto_prompt_correction(prompt,neg_prompt,
|
45 |
|
46 |
if(image_size=="Portrait"):
|
47 |
height=1024
|
@@ -67,8 +67,6 @@ def inference(prompt, guidance, steps, image_size="Square", seed=0, img=None, st
|
|
67 |
return None, error_str(e)
|
68 |
def auto_prompt_correction(prompt_ui,neg_prompt_ui,disable_auto_prompt_correction):
|
69 |
# auto prompt correction
|
70 |
-
|
71 |
-
|
72 |
prompt=str(prompt_ui)
|
73 |
neg_prompt=str(neg_prompt_ui)
|
74 |
prompt=prompt.lower()
|
@@ -85,13 +83,13 @@ def auto_prompt_correction(prompt_ui,neg_prompt_ui,disable_auto_prompt_correctio
|
|
85 |
splited_prompt=prompt.replace(","," ").replace("_"," ").split(" ")
|
86 |
for word in human_words:
|
87 |
if( word in splited_prompt):
|
88 |
-
prompt=f"
|
89 |
neg_prompt=f"(((deformed))), blurry, ((((bad anatomy)))), {neg_prompt}, bad pupil, disfigured, poorly drawn face, mutation, mutated, (extra limb), (ugly), (poorly drawn hands), bad hands, fused fingers, messy drawing, broken legs censor, low quality, (mutated hands and fingers:1.5), (long body :1.3), (mutation, poorly drawn :1.2), ((bad eyes)), ui, error, missing fingers, fused fingers, one hand with more than 5 fingers, one hand with less than 5 fingers, one hand with more than 5 digit, one hand with less than 5 digit, extra digit, fewer digits, fused digit, missing digit, bad digit, liquid digit, long body, uncoordinated body, unnatural body, lowres, jpeg artifacts, 3d, cg, text"
|
90 |
|
91 |
animal_words=["cat","dog","bird"]
|
92 |
for word in animal_words:
|
93 |
if( word in splited_prompt):
|
94 |
-
prompt=f"
|
95 |
neg_prompt=f"(((deformed))), blurry, ((((bad anatomy)))), {neg_prompt}, bad pupil, disfigured, poorly drawn face, mutation, mutated, (extra limb), (ugly), (poorly drawn hands), bad hands, fused fingers, messy drawing, broken legs censor, low quality, (mutated hands and fingers:1.5), (long body :1.3), (mutation, poorly drawn :1.2), ((bad eyes)), ui, error, missing fingers, fused fingers, one hand with more than 5 fingers, one hand with less than 5 fingers, one hand with more than 5 digit, one hand with less than 5 digit, extra digit, fewer digits, fused digit, missing digit, bad digit, liquid digit, long body, uncoordinated body, unnatural body, lowres, jpeg artifacts, 3d, cg, text"
|
96 |
|
97 |
background_words=["mount fuji","mt. fuji","building", "buildings", "tokyo", "kyoto", "nara", "shibuya", "shinjuku"]
|
@@ -143,7 +141,7 @@ with gr.Blocks(css=css) as demo:
|
|
143 |
Demo for <a href="https://huggingface.co/aipicasso/picasso-diffusion-1-0">Picasso Diffusion 1.0</a> .<br>
|
144 |
</p>
|
145 |
<p>
|
146 |
-
サンプル: そのままGenerate
|
147 |
sample : Click "Generate" button without any prompts.
|
148 |
</p>
|
149 |
<p>
|
@@ -153,7 +151,7 @@ with gr.Blocks(css=css) as demo:
|
|
153 |
sample prompt2 : boy, school uniform
|
154 |
</p>
|
155 |
Running on {"<b>GPU 🔥</b>" if torch.cuda.is_available() else f"<b>CPU 🥶</b>. For faster inference it is recommended to <b>upgrade to GPU in <a href='https://huggingface.co/spaces/akhaliq/cool-japan-diffusion-2-1-0/settings'>Settings</a></b>"} <br>
|
156 |
-
<a style="display:inline-block" href="https://huggingface.co/spaces/aipicasso/
|
157 |
</div>
|
158 |
"""
|
159 |
)
|
@@ -161,11 +159,6 @@ with gr.Blocks(css=css) as demo:
|
|
161 |
|
162 |
with gr.Column(scale=55):
|
163 |
with gr.Group():
|
164 |
-
with gr.Row():
|
165 |
-
cool_japan_type=gr.Radio(["Anime", "Manga", "Game"])
|
166 |
-
cool_japan_type.show_label=False
|
167 |
-
cool_japan_type.value="Anime"
|
168 |
-
|
169 |
with gr.Row():
|
170 |
prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2,placeholder="[your prompt]").style(container=False)
|
171 |
generate = gr.Button(value="Generate").style(rounded=(False, True, True, False))
|
@@ -194,7 +187,7 @@ with gr.Blocks(css=css) as demo:
|
|
194 |
image = gr.Image(label="Image", height=256, tool="editor", type="pil")
|
195 |
strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
|
196 |
|
197 |
-
inputs = [prompt, guidance, steps, image_size, seed, image, strength, neg_prompt,
|
198 |
|
199 |
outputs = [image_out, error_output]
|
200 |
prompt.submit(inference, inputs=inputs, outputs=outputs)
|
|
|
37 |
{error}""" if error else ""
|
38 |
|
39 |
|
40 |
+
def inference(prompt, guidance, steps, image_size="Square", seed=0, img=None, strength=0.5, neg_prompt="", disable_auto_prompt_correction=False):
|
41 |
|
42 |
generator = torch.Generator('cuda').manual_seed(seed) if seed != 0 else None
|
43 |
|
44 |
+
prompt,neg_prompt=auto_prompt_correction(prompt,neg_prompt,disable_auto_prompt_correction)
|
45 |
|
46 |
if(image_size=="Portrait"):
|
47 |
height=1024
|
|
|
67 |
return None, error_str(e)
|
68 |
def auto_prompt_correction(prompt_ui,neg_prompt_ui,disable_auto_prompt_correction):
|
69 |
# auto prompt correction
|
|
|
|
|
70 |
prompt=str(prompt_ui)
|
71 |
neg_prompt=str(neg_prompt_ui)
|
72 |
prompt=prompt.lower()
|
|
|
83 |
splited_prompt=prompt.replace(","," ").replace("_"," ").split(" ")
|
84 |
for word in human_words:
|
85 |
if( word in splited_prompt):
|
86 |
+
prompt=f"anime, masterpiece, {prompt}, good pupil, 4k, detailed"
|
87 |
neg_prompt=f"(((deformed))), blurry, ((((bad anatomy)))), {neg_prompt}, bad pupil, disfigured, poorly drawn face, mutation, mutated, (extra limb), (ugly), (poorly drawn hands), bad hands, fused fingers, messy drawing, broken legs censor, low quality, (mutated hands and fingers:1.5), (long body :1.3), (mutation, poorly drawn :1.2), ((bad eyes)), ui, error, missing fingers, fused fingers, one hand with more than 5 fingers, one hand with less than 5 fingers, one hand with more than 5 digit, one hand with less than 5 digit, extra digit, fewer digits, fused digit, missing digit, bad digit, liquid digit, long body, uncoordinated body, unnatural body, lowres, jpeg artifacts, 3d, cg, text"
|
88 |
|
89 |
animal_words=["cat","dog","bird"]
|
90 |
for word in animal_words:
|
91 |
if( word in splited_prompt):
|
92 |
+
prompt=f"anime, a {word}, 4k, detailed"
|
93 |
neg_prompt=f"(((deformed))), blurry, ((((bad anatomy)))), {neg_prompt}, bad pupil, disfigured, poorly drawn face, mutation, mutated, (extra limb), (ugly), (poorly drawn hands), bad hands, fused fingers, messy drawing, broken legs censor, low quality, (mutated hands and fingers:1.5), (long body :1.3), (mutation, poorly drawn :1.2), ((bad eyes)), ui, error, missing fingers, fused fingers, one hand with more than 5 fingers, one hand with less than 5 fingers, one hand with more than 5 digit, one hand with less than 5 digit, extra digit, fewer digits, fused digit, missing digit, bad digit, liquid digit, long body, uncoordinated body, unnatural body, lowres, jpeg artifacts, 3d, cg, text"
|
94 |
|
95 |
background_words=["mount fuji","mt. fuji","building", "buildings", "tokyo", "kyoto", "nara", "shibuya", "shinjuku"]
|
|
|
141 |
Demo for <a href="https://huggingface.co/aipicasso/picasso-diffusion-1-0">Picasso Diffusion 1.0</a> .<br>
|
142 |
</p>
|
143 |
<p>
|
144 |
+
サンプル: そのままGenerateボタンを押してください。<br>
|
145 |
sample : Click "Generate" button without any prompts.
|
146 |
</p>
|
147 |
<p>
|
|
|
151 |
sample prompt2 : boy, school uniform
|
152 |
</p>
|
153 |
Running on {"<b>GPU 🔥</b>" if torch.cuda.is_available() else f"<b>CPU 🥶</b>. For faster inference it is recommended to <b>upgrade to GPU in <a href='https://huggingface.co/spaces/akhaliq/cool-japan-diffusion-2-1-0/settings'>Settings</a></b>"} <br>
|
154 |
+
<a style="display:inline-block" href="https://huggingface.co/spaces/aipicasso/picasso-diffusion-latest-demo?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a> to say goodbye from waiting for the generating.
|
155 |
</div>
|
156 |
"""
|
157 |
)
|
|
|
159 |
|
160 |
with gr.Column(scale=55):
|
161 |
with gr.Group():
|
|
|
|
|
|
|
|
|
|
|
162 |
with gr.Row():
|
163 |
prompt = gr.Textbox(label="Prompt", show_label=False, max_lines=2,placeholder="[your prompt]").style(container=False)
|
164 |
generate = gr.Button(value="Generate").style(rounded=(False, True, True, False))
|
|
|
187 |
image = gr.Image(label="Image", height=256, tool="editor", type="pil")
|
188 |
strength = gr.Slider(label="Transformation strength", minimum=0, maximum=1, step=0.01, value=0.5)
|
189 |
|
190 |
+
inputs = [prompt, guidance, steps, image_size, seed, image, strength, neg_prompt, disable_auto_prompt_correction]
|
191 |
|
192 |
outputs = [image_out, error_output]
|
193 |
prompt.submit(inference, inputs=inputs, outputs=outputs)
|