zhiweili
commited on
Commit
·
ec80eac
1
Parent(s):
3ab17e6
always save as png
Browse files- app_base.py +4 -4
- segment_utils.py +4 -4
app_base.py
CHANGED
@@ -95,13 +95,13 @@ def create_demo() -> gr.Blocks:
|
|
95 |
with gr.Column():
|
96 |
input_image = gr.Image(label="Input Image", type="pil")
|
97 |
with gr.Column():
|
98 |
-
restored_image = gr.Image(label="Restored Image", format="
|
99 |
download_path = gr.File(label="Download the output image", interactive=False)
|
100 |
with gr.Column():
|
101 |
-
origin_area_image = gr.Image(label="Origin Area Image", format="
|
102 |
-
enhanced_image = gr.Image(label="Enhanced Image", format="
|
103 |
generated_cost = gr.Textbox(label="Time cost by step (ms):", visible=True, interactive=False)
|
104 |
-
generated_image = gr.Image(label="Generated Image", format="
|
105 |
|
106 |
g_btn.click(
|
107 |
fn=segment_image,
|
|
|
95 |
with gr.Column():
|
96 |
input_image = gr.Image(label="Input Image", type="pil")
|
97 |
with gr.Column():
|
98 |
+
restored_image = gr.Image(label="Restored Image", format="png", type="pil", interactive=False)
|
99 |
download_path = gr.File(label="Download the output image", interactive=False)
|
100 |
with gr.Column():
|
101 |
+
origin_area_image = gr.Image(label="Origin Area Image", format="png", type="pil", interactive=False)
|
102 |
+
enhanced_image = gr.Image(label="Enhanced Image", format="png", type="pil", interactive=False)
|
103 |
generated_cost = gr.Textbox(label="Time cost by step (ms):", visible=True, interactive=False)
|
104 |
+
generated_image = gr.Image(label="Generated Image", format="png", type="pil", interactive=False)
|
105 |
|
106 |
g_btn.click(
|
107 |
fn=segment_image,
|
segment_utils.py
CHANGED
@@ -24,10 +24,10 @@ def restore_result(croper, category, generated_image):
|
|
24 |
restored_image.paste(cropped_generated_image, (croper.origin_start_x, croper.origin_start_y), cropped_square_mask_image)
|
25 |
|
26 |
extension = 'png'
|
27 |
-
if restored_image.mode == 'RGBA':
|
28 |
-
|
29 |
-
else:
|
30 |
-
|
31 |
|
32 |
path = f"output/{uuid.uuid4()}.{extension}"
|
33 |
restored_image.save(path, quality=100)
|
|
|
24 |
restored_image.paste(cropped_generated_image, (croper.origin_start_x, croper.origin_start_y), cropped_square_mask_image)
|
25 |
|
26 |
extension = 'png'
|
27 |
+
# if restored_image.mode == 'RGBA':
|
28 |
+
# extension = 'png'
|
29 |
+
# else:
|
30 |
+
# extension = 'jpg'
|
31 |
|
32 |
path = f"output/{uuid.uuid4()}.{extension}"
|
33 |
restored_image.save(path, quality=100)
|