diff --git a/demo/locals.py b/demo/locals.py index 400c7532..aa268489 100644 --- a/demo/locals.py +++ b/demo/locals.py @@ -252,12 +252,20 @@ "label": "高清照", }, }, + "standard_photo_png": { + "en": { + "label": "Matting Standard photo", + }, + "zh": { + "label": "透明标准照", + }, + }, "hd_photo_png": { "en": { - "label": "Matting photo", + "label": "Matting HD photo", }, "zh": { - "label": "透明图", + "label": "透明高清照", }, }, "layout_photo": { @@ -276,4 +284,12 @@ "label": "下载调整 KB 大小后的照片", }, }, + "matting_image": { + "en": { + "label": "Matting image", + }, + "zh": { + "label": "抠图图像", + }, + }, } diff --git a/demo/processor.py b/demo/processor.py index 85fea304..eaa1f725 100644 --- a/demo/processor.py +++ b/demo/processor.py @@ -148,7 +148,10 @@ def process( else: (result_image_standard, result_image_hd, _, _) = result + + result_image_standard_png = np.uint8(result_image_standard) result_image_hd_png = np.uint8(result_image_hd) + if ( idphoto_json["render_mode"] == LOCALES["render_mode"][language]["choices"][0] @@ -274,6 +277,7 @@ def process( return [ result_image_standard, # img_output_standard result_image_hd, # img_output_standard_hd + result_image_standard_png, # img_output_standard_hd_png result_image_hd_png, # img_output_standard_hd_png result_layout_image, # img_output_layout gr.update(visible=False), # notification @@ -283,6 +287,7 @@ def process( return [ result_image_standard, # img_output_standard result_image_hd, # img_output_standard_hd + result_image_standard_png, # img_output_standard_hd_png result_image_hd_png, # img_output_standard_hd_png result_layout_image, # img_output_layout gr.update(visible=False), # notification diff --git a/demo/ui.py b/demo/ui.py index 49d6af54..872ea97c 100644 --- a/demo/ui.py +++ b/demo/ui.py @@ -247,22 +247,34 @@ def update_watermark_text_visibility(choice, language): height=350, format="jpeg", ) - img_output_standard_hd_png = gr.Image( - label=LOCALES["hd_photo_png"][DEFAULT_LANG]["label"], - height=350, - format="png", - elem_id="hd_photo_png", - ) img_output_layout = gr.Image( label=LOCALES["layout_photo"][DEFAULT_LANG]["label"], height=350, format="jpeg", ) + file_download = gr.File( label=LOCALES["download"][DEFAULT_LANG]["label"], visible=False ) + with gr.Accordion( + LOCALES["matting_image"][DEFAULT_LANG]["label"], open=False + ) as matting_image_accordion: + with gr.Row(): + img_output_standard_png = gr.Image( + label=LOCALES["standard_photo_png"][DEFAULT_LANG]["label"], + height=350, + format="png", + elem_id="standard_photo_png", + ) + img_output_standard_hd_png = gr.Image( + label=LOCALES["hd_photo_png"][DEFAULT_LANG]["label"], + height=350, + format="png", + elem_id="hd_photo_png", + ) + # ---------------- 设置隐藏/显示组件 ---------------- def change_language(language): return { @@ -310,6 +322,9 @@ def change_language(language): img_output_standard_hd: gr.update( label=LOCALES["hd_photo"][language]["label"] ), + img_output_standard_png: gr.update( + label=LOCALES["standard_photo_png"][language]["label"] + ), img_output_standard_hd_png: gr.update( label=LOCALES["hd_photo_png"][language]["label"] ), @@ -358,6 +373,9 @@ def change_language(language): choices=LOCALES["watermark_switch"][language]["choices"], value=LOCALES["watermark_switch"][language]["choices"][0], ), + matting_image_accordion: gr.update( + label=LOCALES["matting_image"][language]["label"] + ), } def change_color(colors): @@ -412,6 +430,7 @@ def change_image_kb(image_kb_option): notification, img_output_standard, img_output_standard_hd, + img_output_standard_png, img_output_standard_hd_png, img_output_layout, file_download, @@ -427,6 +446,7 @@ def change_image_kb(image_kb_option): watermark_text_angle, watermark_text_space, watermark_options, + matting_image_accordion, ], ) @@ -475,6 +495,7 @@ def change_image_kb(image_kb_option): outputs=[ img_output_standard, img_output_standard_hd, + img_output_standard_png, img_output_standard_hd_png, img_output_layout, notification,