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):
|
47 |
|
48 |
promptPrev = prompt
|
49 |
prompt = prompt_prefixes[current_model] + prompt
|
50 |
-
results = pipe(prompt, num_inference_steps=int(steps), guidance_scale=guidance, width=
|
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):
|
55 |
|
56 |
prompt = prompt_prefixes[current_model] + prompt
|
57 |
-
results = pipe(prompt, num_inference_steps=int(steps), guidance_scale=guidance, width=
|
58 |
image = results.images[0] if not results.nsfw_content_detected[0] else Image.open("nsfw_placeholder.jpg")
|
59 |
return image
|
60 |
|
@@ -131,6 +131,8 @@ with gr.Blocks(css=css) as demo:
|
|
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 |
run = gr.Button(value="Run")
|
135 |
gr.Markdown(f"Running on: {device}")
|
136 |
with gr.Column():
|
@@ -143,16 +145,16 @@ with gr.Blocks(css=css) as demo:
|
|
143 |
share_button = gr.Button("Share to community", elem_id="share-btn", visible=False)
|
144 |
|
145 |
model.change(on_model_change, inputs=model, outputs=[])
|
146 |
-
run.click(inference, inputs=[prompt, guidance, steps], outputs=[image_out, share_button, community_icon, loading_icon, prompt])
|
147 |
|
148 |
share_button.click(None, [], [], _js=share_js)
|
149 |
|
150 |
gr.Examples([
|
151 |
-
["portrait of a beautiful fancy gorgeous anime girl, intricate details", 7, 20],
|
152 |
-
["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],
|
153 |
-
["city landscape with fancy car, racing on the road, gopro, intricate details, 4k, cyberpunk", 7, 20],
|
154 |
-
["portrait of liu yifei girl, soldier working in a cyberpunk city, cleavage, intricate, 8k, highly detailed, digital painting, intense, sharp focus", 7, 20],
|
155 |
-
["portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", 7, 20],
|
156 |
], [prompt, guidance, steps], image_out, inference_example, cache_examples=torch.cuda.is_available())
|
157 |
gr.Markdown('''
|
158 |
Models and Space by [@DGSpitzer](https://www.youtube.com/channel/UCzzsYBF4qwtMwJaPJZ5SuPg)❤️ [@大谷的游戏创作小屋](https://space.bilibili.com/176003)
|
|
|
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 |
|
|
|
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=512, maximum=960, minimum=360)
|
135 |
+
height_input = gr.Slider(label="Height", value=512, maximum=960, minimum=360)
|
136 |
run = gr.Button(value="Run")
|
137 |
gr.Markdown(f"Running on: {device}")
|
138 |
with gr.Column():
|
|
|
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 |
+
["portrait of a beautiful fancy gorgeous anime girl, intricate details", 7, 20, 704, 704],
|
154 |
+
["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],
|
155 |
+
["city landscape with fancy car, racing on the road, gopro, intricate details, 4k, cyberpunk", 7, 20, 704, 704],
|
156 |
+
["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],
|
157 |
+
["portrait of a muscular beard male in dgs illustration style, half-body, holding robot arms, strong chest", 7, 20, 704, 704],
|
158 |
], [prompt, guidance, steps], image_out, inference_example, cache_examples=torch.cuda.is_available())
|
159 |
gr.Markdown('''
|
160 |
Models and Space by [@DGSpitzer](https://www.youtube.com/channel/UCzzsYBF4qwtMwJaPJZ5SuPg)❤️ [@大谷的游戏创作小屋](https://space.bilibili.com/176003)
|