Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -161,19 +161,19 @@ def infer(cond_in, image_in, prompt, inference_steps, guidance_scale, control_mo
|
|
| 161 |
if cond_in is None:
|
| 162 |
if image_in is not None:
|
| 163 |
image_in = resize_img(load_image(image_in))
|
| 164 |
-
if control_mode == "
|
| 165 |
control_image = extract_canny(image_in)
|
| 166 |
-
elif control_mode == "
|
| 167 |
control_image = extract_depth(image_in)
|
| 168 |
-
elif control_mode == "
|
| 169 |
control_image = extract_openpose(image_in)
|
| 170 |
-
elif control_mode == "
|
| 171 |
control_image = apply_gaussian_blur(image_in)
|
| 172 |
-
elif control_mode == "
|
| 173 |
control_image = add_gaussian_noise(image_in)
|
| 174 |
-
elif control_mode == "
|
| 175 |
control_image = convert_to_grayscale(image_in)
|
| 176 |
-
elif control_mode == "
|
| 177 |
control_image = tile(image_in)
|
| 178 |
else:
|
| 179 |
control_image = resize_img(load_image(cond_in))
|
|
@@ -212,19 +212,21 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
| 212 |
with gr.Column():
|
| 213 |
|
| 214 |
with gr.Row(equal_height=True):
|
| 215 |
-
cond_in = gr.Image(label="
|
| 216 |
-
image_in = gr.Image(label="
|
| 217 |
|
| 218 |
-
prompt = gr.Textbox(label="
|
| 219 |
|
| 220 |
-
with gr.Accordion("
|
| 221 |
control_mode = gr.Radio(
|
| 222 |
-
["
|
| 223 |
-
|
|
|
|
|
|
|
| 224 |
)
|
| 225 |
|
| 226 |
control_strength = gr.Slider(
|
| 227 |
-
label="
|
| 228 |
minimum=0,
|
| 229 |
maximum=1.0,
|
| 230 |
step=0.05,
|
|
@@ -232,25 +234,25 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
|
|
| 232 |
)
|
| 233 |
|
| 234 |
seed = gr.Slider(
|
| 235 |
-
label="
|
| 236 |
minimum=0,
|
| 237 |
maximum=MAX_SEED,
|
| 238 |
step=1,
|
| 239 |
value=42,
|
| 240 |
)
|
| 241 |
-
randomize_seed = gr.Checkbox(label="
|
| 242 |
|
| 243 |
-
with gr.Accordion("
|
| 244 |
with gr.Column():
|
| 245 |
with gr.Row():
|
| 246 |
-
inference_steps = gr.Slider(label="
|
| 247 |
-
guidance_scale = gr.Slider(label="
|
| 248 |
|
| 249 |
-
submit_btn = gr.Button("
|
| 250 |
|
| 251 |
with gr.Column():
|
| 252 |
-
result = gr.Image(label="
|
| 253 |
-
processed_cond = gr.Image(label="
|
| 254 |
|
| 255 |
submit_btn.click(
|
| 256 |
fn=randomize_seed_fn,
|
|
|
|
| 161 |
if cond_in is None:
|
| 162 |
if image_in is not None:
|
| 163 |
image_in = resize_img(load_image(image_in))
|
| 164 |
+
if control_mode == "Canny":
|
| 165 |
control_image = extract_canny(image_in)
|
| 166 |
+
elif control_mode == "Depth":
|
| 167 |
control_image = extract_depth(image_in)
|
| 168 |
+
elif control_mode == "OpenPose":
|
| 169 |
control_image = extract_openpose(image_in)
|
| 170 |
+
elif control_mode == "Blur":
|
| 171 |
control_image = apply_gaussian_blur(image_in)
|
| 172 |
+
elif control_mode == "LowQuality":
|
| 173 |
control_image = add_gaussian_noise(image_in)
|
| 174 |
+
elif control_mode == "Grayscale":
|
| 175 |
control_image = convert_to_grayscale(image_in)
|
| 176 |
+
elif control_mode == "Tile":
|
| 177 |
control_image = tile(image_in)
|
| 178 |
else:
|
| 179 |
control_image = resize_img(load_image(cond_in))
|
|
|
|
| 212 |
with gr.Column():
|
| 213 |
|
| 214 |
with gr.Row(equal_height=True):
|
| 215 |
+
cond_in = gr.Image(label="Upload Processed Control Image", sources=["upload"], type="filepath")
|
| 216 |
+
image_in = gr.Image(label="Extract Condition from Reference Image (Optional)", sources=["upload"], type="filepath")
|
| 217 |
|
| 218 |
+
prompt = gr.Textbox(label="Prompt", value="Highest Quality")
|
| 219 |
|
| 220 |
+
with gr.Accordion("ControlNet"):
|
| 221 |
control_mode = gr.Radio(
|
| 222 |
+
["Canny", "Depth", "OpenPose", "Grayscale", "Blur", "Tile", "LowQuality"],
|
| 223 |
+
label="Mode",
|
| 224 |
+
value="Grayscale",
|
| 225 |
+
info="Select control mode, applies to all images"
|
| 226 |
)
|
| 227 |
|
| 228 |
control_strength = gr.Slider(
|
| 229 |
+
label="Control Strength",
|
| 230 |
minimum=0,
|
| 231 |
maximum=1.0,
|
| 232 |
step=0.05,
|
|
|
|
| 234 |
)
|
| 235 |
|
| 236 |
seed = gr.Slider(
|
| 237 |
+
label="Seed",
|
| 238 |
minimum=0,
|
| 239 |
maximum=MAX_SEED,
|
| 240 |
step=1,
|
| 241 |
value=42,
|
| 242 |
)
|
| 243 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
|
| 244 |
|
| 245 |
+
with gr.Accordion("Advanced Settings", open=False):
|
| 246 |
with gr.Column():
|
| 247 |
with gr.Row():
|
| 248 |
+
inference_steps = gr.Slider(label="Inference Steps", minimum=1, maximum=50, step=1, value=24)
|
| 249 |
+
guidance_scale = gr.Slider(label="Guidance Scale", minimum=1.0, maximum=10.0, step=0.1, value=3.5)
|
| 250 |
|
| 251 |
+
submit_btn = gr.Button("Submit")
|
| 252 |
|
| 253 |
with gr.Column():
|
| 254 |
+
result = gr.Image(label="Result")
|
| 255 |
+
processed_cond = gr.Image(label="Preprocessed Condition")
|
| 256 |
|
| 257 |
submit_btn.click(
|
| 258 |
fn=randomize_seed_fn,
|