Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -43,18 +43,18 @@ def on_model_change(model):
|
|
43 |
if torch.cuda.is_available():
|
44 |
pipe = pipe.to("cuda")
|
45 |
|
46 |
-
def inference(prompt, guidance, steps, width_input, height_input):
|
47 |
|
48 |
promptPrev = prompt
|
49 |
prompt = prompt_prefixes[current_model] + prompt
|
50 |
-
results = pipe(prompt, num_inference_steps=int(steps), guidance_scale=guidance, width=width_input, height=height_input)
|
51 |
image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
|
52 |
return image, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(placeholder=promptPrev)
|
53 |
|
54 |
-
def inference_example(prompt, guidance, steps, width_input, height_input):
|
55 |
|
56 |
prompt = prompt_prefixes[current_model] + prompt
|
57 |
-
results = pipe(prompt, num_inference_steps=int(steps), guidance_scale=guidance, width=width_input, height=height_input)
|
58 |
image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
|
59 |
return image
|
60 |
|
@@ -129,6 +129,7 @@ with gr.Blocks(css=css) as demo:
|
|
129 |
with gr.Column():
|
130 |
model = gr.Dropdown(label="Model", choices=models, value=models[0])
|
131 |
prompt = gr.Textbox(label="Prompt", placeholder="{} is added automatically".format(prompt_prefixes[current_model]), elem_id="input-prompt")
|
|
|
132 |
guidance = gr.Slider(label="Guidance scale", value=7, maximum=8)
|
133 |
steps = gr.Slider(label="Steps", value=20, maximum=30, minimum=2)
|
134 |
width_input = gr.Slider(label="Width", value=576, maximum=768, minimum=384, step=64)
|
@@ -145,18 +146,18 @@ with gr.Blocks(css=css) as demo:
|
|
145 |
share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
|
146 |
|
147 |
model.change(on_model_change, inputs=model, outputs=[])
|
148 |
-
run.click(inference, inputs=[prompt, guidance, steps, width_input, height_input], outputs=[image_out, share_button, community_icon, loading_icon, prompt])
|
149 |
|
150 |
share_button.click(None, [], [], _js=share_js)
|
151 |
|
152 |
gr.Examples([
|
153 |
-
["perfect face portrait of beautiful smile girl, clean face, wears hoody, half body, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", 7, 20, 512, 704],
|
154 |
-
["portrait of a beautiful fancy gorgeous anime girl, intricate details", 7, 20, 448, 640],
|
155 |
-
["a beautiful perfect face girl, Anime fine details portrait of school girl in front of modern tokyo city landscape on the background deep bokeh, anime masterpiece by studio ghibli, 8k, sharp high quality anime, artstation", 7, 20, 704, 704],
|
156 |
-
["city landscape with fancy car, racing on the road, gopro, intricate details, 4k, cyberpunk", 7, 20, 704, 704],
|
157 |
-
["portrait of liu yifei girl, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", 7, 20, 704, 704],
|
158 |
-
["portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", 7, 20, 512, 640],
|
159 |
-
], [prompt, guidance, steps, width_input, height_input], image_out, inference_example, cache_examples=torch.cuda.is_available())
|
160 |
gr.Markdown('''
|
161 |
Models and Space by [@DGSpitzer](https://www.youtube.com/channel/UCzzsYBF4qwtMwJaPJZ5SuPg)❤️ [@大谷的游戏创作小屋](https://space.bilibili.com/176003)
|
162 |
[](https://twitter.com/DGSpitzer)
|
|
|
43 |
if torch.cuda.is_available():
|
44 |
pipe = pipe.to("cuda")
|
45 |
|
46 |
+
def inference(prompt, negPrompt, guidance, steps, width_input, height_input):
|
47 |
|
48 |
promptPrev = prompt
|
49 |
prompt = prompt_prefixes[current_model] + prompt
|
50 |
+
results = pipe(prompt, negative_prompt = negPrompt, num_inference_steps=int(steps), guidance_scale=guidance, width=width_input, height=height_input)
|
51 |
image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
|
52 |
return image, gr.update(visible=True), gr.update(visible=True), gr.update(visible=True), gr.update(placeholder=promptPrev)
|
53 |
|
54 |
+
def inference_example(prompt, negPrompt, guidance, steps, width_input, height_input):
|
55 |
|
56 |
prompt = prompt_prefixes[current_model] + prompt
|
57 |
+
results = pipe(prompt, negative_prompt, num_inference_steps=int(steps), guidance_scale=guidance, width=width_input, height=height_input)
|
58 |
image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
|
59 |
return image
|
60 |
|
|
|
129 |
with gr.Column():
|
130 |
model = gr.Dropdown(label="Model", choices=models, value=models[0])
|
131 |
prompt = gr.Textbox(label="Prompt", placeholder="{} is added automatically".format(prompt_prefixes[current_model]), elem_id="input-prompt")
|
132 |
+
negPrompt = gr.Textbox(label="Negative Prompt", placeholder="Enter what you don't want to generate", elem_id="input-negPrompt")
|
133 |
guidance = gr.Slider(label="Guidance scale", value=7, maximum=8)
|
134 |
steps = gr.Slider(label="Steps", value=20, maximum=30, minimum=2)
|
135 |
width_input = gr.Slider(label="Width", value=576, maximum=768, minimum=384, step=64)
|
|
|
146 |
share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
|
147 |
|
148 |
model.change(on_model_change, inputs=model, outputs=[])
|
149 |
+
run.click(inference, inputs=[prompt, negPrompt, guidance, steps, width_input, height_input], outputs=[image_out, share_button, community_icon, loading_icon, prompt])
|
150 |
|
151 |
share_button.click(None, [], [], _js=share_js)
|
152 |
|
153 |
gr.Examples([
|
154 |
+
["perfect face portrait of beautiful smile girl, clean face, wears hoody, half body, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 512, 704],
|
155 |
+
["portrait of a beautiful fancy gorgeous anime girl, intricate details", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 448, 640],
|
156 |
+
["a beautiful perfect face girl, Anime fine details portrait of school girl in front of modern tokyo city landscape on the background deep bokeh, anime masterpiece by studio ghibli, 8k, sharp high quality anime, artstation", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
|
157 |
+
["city landscape with fancy car, racing on the road, gopro, intricate details, 4k, cyberpunk", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
|
158 |
+
["portrait of liu yifei girl, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 704, 704],
|
159 |
+
["portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", "out of focus, scary, creepy, evil, disfigured, missing limbs, ugly, gross, missing fingers", 7, 20, 512, 640],
|
160 |
+
], [prompt, negPrompt, guidance, steps, width_input, height_input], image_out, inference_example, cache_examples=torch.cuda.is_available())
|
161 |
gr.Markdown('''
|
162 |
Models and Space by [@DGSpitzer](https://www.youtube.com/channel/UCzzsYBF4qwtMwJaPJZ5SuPg)❤️ [@大谷的游戏创作小屋](https://space.bilibili.com/176003)
|
163 |
[](https://twitter.com/DGSpitzer)
|