Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -148,26 +148,25 @@ def resize_img(control_image):
|
|
| 148 |
return resized_image
|
| 149 |
|
| 150 |
@spaces.GPU(duration=180)
|
| 151 |
-
def infer(
|
| 152 |
control_mode_num = mode_mapping[control_mode]
|
| 153 |
|
| 154 |
-
if
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
control_image = resize_img(load_image(cond_in))
|
| 171 |
|
| 172 |
width, height = control_image.size
|
| 173 |
|
|
@@ -257,7 +256,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 257 |
api_name=False
|
| 258 |
).then(
|
| 259 |
fn = infer,
|
| 260 |
-
inputs = [
|
| 261 |
outputs = [result, processed_cond],
|
| 262 |
show_api=False
|
| 263 |
)
|
|
|
|
| 148 |
return resized_image
|
| 149 |
|
| 150 |
@spaces.GPU(duration=180)
|
| 151 |
+
def infer(image_in, prompt, inference_steps, guidance_scale, control_mode, control_strength, seed, progress=gr.Progress(track_tqdm=True)):
|
| 152 |
control_mode_num = mode_mapping[control_mode]
|
| 153 |
|
| 154 |
+
if image_in is not None:
|
| 155 |
+
image_in = resize_img(load_image(image_in))
|
| 156 |
+
if control_mode == "canny":
|
| 157 |
+
control_image = extract_canny(image_in)
|
| 158 |
+
elif control_mode == "depth":
|
| 159 |
+
control_image = extract_depth(image_in)
|
| 160 |
+
elif control_mode == "pose":
|
| 161 |
+
control_image = extract_openpose(image_in)
|
| 162 |
+
elif control_mode == "colorgrid":
|
| 163 |
+
control_image = tile(64, image_in)
|
| 164 |
+
elif control_mode == "recolor":
|
| 165 |
+
control_image = convert_to_grayscale(image_in)
|
| 166 |
+
elif control_mode == "tile":
|
| 167 |
+
control_image = tile(16, image_in)
|
| 168 |
+
|
| 169 |
+
control_image = resize_img(control_image)
|
|
|
|
| 170 |
|
| 171 |
width, height = control_image.size
|
| 172 |
|
|
|
|
| 256 |
api_name=False
|
| 257 |
).then(
|
| 258 |
fn = infer,
|
| 259 |
+
inputs = [image_in, prompt, inference_steps, guidance_scale, control_mode, control_strength, seed],
|
| 260 |
outputs = [result, processed_cond],
|
| 261 |
show_api=False
|
| 262 |
)
|