Spaces:
Running
on
Zero
Running
on
Zero
Make width and height customizable
Browse filesidk how to modify the file without making a pull request so here's a pull request
app.py
CHANGED
|
@@ -73,8 +73,10 @@ def inference(
|
|
| 73 |
seed: int = -1,
|
| 74 |
init_image: Image.Image | None = None,
|
| 75 |
qrcode_image: Image.Image | None = None,
|
| 76 |
-
use_qr_code_as_init_image
|
| 77 |
-
sampler
|
|
|
|
|
|
|
| 78 |
):
|
| 79 |
if prompt is None or prompt == "":
|
| 80 |
raise gr.Error("Prompt is required")
|
|
@@ -111,8 +113,8 @@ def inference(
|
|
| 111 |
negative_prompt=negative_prompt,
|
| 112 |
image=qrcode_image,
|
| 113 |
control_image=qrcode_image, # type: ignore
|
| 114 |
-
width=
|
| 115 |
-
height=
|
| 116 |
guidance_scale=float(guidance_scale),
|
| 117 |
controlnet_conditioning_scale=float(controlnet_conditioning_scale), # type: ignore
|
| 118 |
generator=generator,
|
|
@@ -166,6 +168,7 @@ model: https://huggingface.co/DionTimmer/controlnet_qrcode-control_v1p_sd15
|
|
| 166 |
)
|
| 167 |
use_qr_code_as_init_image = gr.Checkbox(label="Use QR code as init image", value=True, interactive=False, info="Whether init image should be QR code. Unclick to pass init image or generate init image with Stable Diffusion 2.1")
|
| 168 |
|
|
|
|
| 169 |
with gr.Accordion(label="Init Images (Optional)", open=False, visible=False) as init_image_acc:
|
| 170 |
init_image = gr.Image(label="Init Image (Optional). Leave blank to generate image with SD 2.1", type="pil")
|
| 171 |
|
|
@@ -174,6 +177,21 @@ model: https://huggingface.co/DionTimmer/controlnet_qrcode-control_v1p_sd15
|
|
| 174 |
label="Params: The generated QR Code functionality is largely influenced by the parameters detailed below",
|
| 175 |
open=True,
|
| 176 |
):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
controlnet_conditioning_scale = gr.Slider(
|
| 178 |
minimum=0.0,
|
| 179 |
maximum=5.0,
|
|
@@ -218,6 +236,8 @@ model: https://huggingface.co/DionTimmer/controlnet_qrcode-control_v1p_sd15
|
|
| 218 |
qr_code_image,
|
| 219 |
use_qr_code_as_init_image,
|
| 220 |
sampler,
|
|
|
|
|
|
|
| 221 |
],
|
| 222 |
outputs=[result_image],
|
| 223 |
concurrency_limit=1
|
|
|
|
| 73 |
seed: int = -1,
|
| 74 |
init_image: Image.Image | None = None,
|
| 75 |
qrcode_image: Image.Image | None = None,
|
| 76 |
+
use_qr_code_as_init_image=True,
|
| 77 |
+
sampler="DPM++ Karras SDE",
|
| 78 |
+
width: int = 768,
|
| 79 |
+
height: int = 768,
|
| 80 |
):
|
| 81 |
if prompt is None or prompt == "":
|
| 82 |
raise gr.Error("Prompt is required")
|
|
|
|
| 113 |
negative_prompt=negative_prompt,
|
| 114 |
image=qrcode_image,
|
| 115 |
control_image=qrcode_image, # type: ignore
|
| 116 |
+
width=width, # dynamic width
|
| 117 |
+
height=height, # dynamic height
|
| 118 |
guidance_scale=float(guidance_scale),
|
| 119 |
controlnet_conditioning_scale=float(controlnet_conditioning_scale), # type: ignore
|
| 120 |
generator=generator,
|
|
|
|
| 168 |
)
|
| 169 |
use_qr_code_as_init_image = gr.Checkbox(label="Use QR code as init image", value=True, interactive=False, info="Whether init image should be QR code. Unclick to pass init image or generate init image with Stable Diffusion 2.1")
|
| 170 |
|
| 171 |
+
|
| 172 |
with gr.Accordion(label="Init Images (Optional)", open=False, visible=False) as init_image_acc:
|
| 173 |
init_image = gr.Image(label="Init Image (Optional). Leave blank to generate image with SD 2.1", type="pil")
|
| 174 |
|
|
|
|
| 177 |
label="Params: The generated QR Code functionality is largely influenced by the parameters detailed below",
|
| 178 |
open=True,
|
| 179 |
):
|
| 180 |
+
width = gr.Slider(
|
| 181 |
+
minimum=64,
|
| 182 |
+
maximum=2048,
|
| 183 |
+
step=64,
|
| 184 |
+
value=768,
|
| 185 |
+
label="Width",
|
| 186 |
+
)
|
| 187 |
+
height = gr.Slider(
|
| 188 |
+
minimum=64,
|
| 189 |
+
maximum=2048,
|
| 190 |
+
step=64,
|
| 191 |
+
value=768,
|
| 192 |
+
label="Height",
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
controlnet_conditioning_scale = gr.Slider(
|
| 196 |
minimum=0.0,
|
| 197 |
maximum=5.0,
|
|
|
|
| 236 |
qr_code_image,
|
| 237 |
use_qr_code_as_init_image,
|
| 238 |
sampler,
|
| 239 |
+
width, # add width input
|
| 240 |
+
height, # add height input
|
| 241 |
],
|
| 242 |
outputs=[result_image],
|
| 243 |
concurrency_limit=1
|