Spaces:
Runtime error
Runtime error
Commit
Β·
b65cd60
1
Parent(s):
e4df1d3
Update app.py
Browse filesLimited input range and added automatic height limiter along with new explanatory text
app.py
CHANGED
@@ -120,6 +120,9 @@ for model in model_tags:
|
|
120 |
# def image_prompt(prompt, dropdown, guidance, steps, seed, height, width):
|
121 |
def image_prompt(prompt, guidance, steps, seed, height, width):
|
122 |
# prompt = prompt + DROPDOWNS[dropdown]
|
|
|
|
|
|
|
123 |
generator = torch.Generator(device="cuda").manual_seed(int(seed))
|
124 |
return (
|
125 |
pipe(prompt=prompt, guidance_scale=guidance, num_inference_steps=steps, generator=generator, height=int((height // 8) * 8), width=int((width // 8) * 8)).images[0],
|
@@ -163,11 +166,12 @@ with gr.Blocks(css=".gradio-container {max-width: 650px}") as dropdown_tab:
|
|
163 |
steps = gr.Slider(1, 100, label="inference steps", dtype=int, value=default_steps, step=1, interactive=True)
|
164 |
with gr.Row():
|
165 |
with gr.Column():
|
166 |
-
|
167 |
with gr.Column():
|
168 |
-
|
169 |
-
gr.Markdown("<u>heads-up</u>: Height multiplied by width should not exceed about 645,000 or an error
|
170 |
-
|
|
|
171 |
output = gr.Image(elem_id="output-image")
|
172 |
output_text = gr.Text(elem_id="output-text")
|
173 |
# go_button.click(fn=image_prompt, inputs=[prompt, dropdown, guidance, steps, seed, height, width], outputs=[output, output_text])
|
|
|
120 |
# def image_prompt(prompt, dropdown, guidance, steps, seed, height, width):
|
121 |
def image_prompt(prompt, guidance, steps, seed, height, width):
|
122 |
# prompt = prompt + DROPDOWNS[dropdown]
|
123 |
+
square_pixels = height * width
|
124 |
+
if square_pixels > 640000:
|
125 |
+
height = 640000 // width
|
126 |
generator = torch.Generator(device="cuda").manual_seed(int(seed))
|
127 |
return (
|
128 |
pipe(prompt=prompt, guidance_scale=guidance, num_inference_steps=steps, generator=generator, height=int((height // 8) * 8), width=int((width // 8) * 8)).images[0],
|
|
|
166 |
steps = gr.Slider(1, 100, label="inference steps", dtype=int, value=default_steps, step=1, interactive=True)
|
167 |
with gr.Row():
|
168 |
with gr.Column():
|
169 |
+
width = gr.Slider(144, 4200, label="width", dtype=int, value=default_pixel, step=8, interactive=True)
|
170 |
with gr.Column():
|
171 |
+
height = gr.Slider(144, 4200, label="height", dtype=int, value=default_pixel, step=8, interactive=True)
|
172 |
+
gr.Markdown("<u>heads-up</u>: Height multiplied by width should not exceed about 645,000 or an error may occur. If an error occours refresh your browser tab or errors will continue. If you exceed this range the app will attempt to avoid an error by lowering your input height. We are actively seeking out ways to handle higher resolutions!")
|
173 |
+
|
174 |
+
go_button = gr.Button("generate image", elem_id="go-button")
|
175 |
output = gr.Image(elem_id="output-image")
|
176 |
output_text = gr.Text(elem_id="output-text")
|
177 |
# go_button.click(fn=image_prompt, inputs=[prompt, dropdown, guidance, steps, seed, height, width], outputs=[output, output_text])
|