Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -96,7 +96,8 @@ MAX_SEED = np.iinfo(np.int32).max
|
|
96 |
TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
|
97 |
os.makedirs(TMP_DIR, exist_ok=True)
|
98 |
|
99 |
-
|
|
|
100 |
|
101 |
def apply_style(style_name: str, positive: str, negative: str = "") -> tuple[str, str]:
|
102 |
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
@@ -132,7 +133,6 @@ def preprocess_image(image: Image.Image,
|
|
132 |
"""
|
133 |
|
134 |
width, height = image['composite'].size
|
135 |
-
image["background"] = Image.new("RGB", (width, height), (255, 255, 255))
|
136 |
ratio = np.sqrt(1024. * 1024. / (width * height))
|
137 |
new_width, new_height = int(width * ratio), int(height * ratio)
|
138 |
image = image['composite'].resize((new_width, new_height))
|
@@ -500,6 +500,10 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
500 |
lambda: tuple([True, gr.Row.update(visible=False), gr.Row.update(visible=True)]),
|
501 |
outputs=[is_multiimage, single_image_example, multiimage_example]
|
502 |
)
|
|
|
|
|
|
|
|
|
503 |
|
504 |
# image_prompt.upload(
|
505 |
# preprocess_image,
|
|
|
96 |
TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
|
97 |
os.makedirs(TMP_DIR, exist_ok=True)
|
98 |
|
99 |
+
def reset_canvas():
|
100 |
+
return gr.update({"background":Image.new("RGB", (512, 512), (255, 255, 255)), "layers":[Image.new("RGB", (512, 512), (255, 255, 255))], "composite":Image.new("RGB", (512, 512), (255, 255, 255))})
|
101 |
|
102 |
def apply_style(style_name: str, positive: str, negative: str = "") -> tuple[str, str]:
|
103 |
p, n = styles.get(style_name, styles[DEFAULT_STYLE_NAME])
|
|
|
133 |
"""
|
134 |
|
135 |
width, height = image['composite'].size
|
|
|
136 |
ratio = np.sqrt(1024. * 1024. / (width * height))
|
137 |
new_width, new_height = int(width * ratio), int(height * ratio)
|
138 |
image = image['composite'].resize((new_width, new_height))
|
|
|
500 |
lambda: tuple([True, gr.Row.update(visible=False), gr.Row.update(visible=True)]),
|
501 |
outputs=[is_multiimage, single_image_example, multiimage_example]
|
502 |
)
|
503 |
+
image_prompt.clear(
|
504 |
+
fn=reset_canvas,
|
505 |
+
outputs = [image_prompt]
|
506 |
+
)
|
507 |
|
508 |
# image_prompt.upload(
|
509 |
# preprocess_image,
|