Skip to content

Commit

Permalink
fix: face align beauty(#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyi-Lin authored Sep 18, 2024
1 parent 473b8bf commit 15d9f4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions demo/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,29 @@ def create_ui(
with gr.Tab(
LOCALES["key_param"][DEFAULT_LANG]["label"]
) as key_parameter_tab:
# 尺寸模式
with gr.Row():
mode_options = gr.Radio(
choices=LOCALES["size_mode"][DEFAULT_LANG]["choices"],
label=LOCALES["size_mode"][DEFAULT_LANG]["label"],
value=LOCALES["size_mode"][DEFAULT_LANG]["choices"][0],
min_width=520,
)
# 人脸对齐
face_alignment_options = gr.CheckboxGroup(
label=LOCALES["face_alignment"][DEFAULT_LANG]["label"],
choices=LOCALES["face_alignment"][DEFAULT_LANG]["choices"],
interactive=True,
)
# 尺寸列表
with gr.Row(visible=True) as size_list_row:
size_list_options = gr.Dropdown(
choices=LOCALES["size_list"][DEFAULT_LANG]["choices"],
label=LOCALES["size_list"][DEFAULT_LANG]["label"],
value=LOCALES["size_list"][DEFAULT_LANG]["choices"][0],
elem_id="size_list",
)
# 自定义尺寸px
with gr.Row(visible=False) as custom_size_px:
custom_size_height_px = gr.Number(
value=413,
Expand All @@ -103,6 +107,7 @@ def create_ui(
label=LOCALES["custom_size_px"][DEFAULT_LANG]["width"],
interactive=True,
)
# 自定义尺寸mm
with gr.Row(visible=False) as custom_size_mm:
custom_size_height_mm = gr.Number(
value=35,
Expand All @@ -115,6 +120,7 @@ def create_ui(
interactive=True,
)

# 背景颜色
color_options = gr.Radio(
choices=LOCALES["bg_color"][DEFAULT_LANG]["choices"],
label=LOCALES["bg_color"][DEFAULT_LANG]["label"],
Expand All @@ -131,6 +137,7 @@ def create_ui(
with gr.Row(visible=False) as custom_color_hex:
custom_color_hex_value = gr.Text(value="000000", label="Hex", interactive=True)

# 渲染模式
render_options = gr.Radio(
choices=LOCALES["render_mode"][DEFAULT_LANG]["choices"],
label=LOCALES["render_mode"][DEFAULT_LANG]["label"],
Expand Down
5 changes: 3 additions & 2 deletions hivision/creator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ def __call__(
print("执行人脸对齐")
print("旋转角度:", ctx.face["roll_angle"])
# 根据角度旋转原图和抠图
b, g, r, a = cv2.split(ctx.matting_image)
ctx.origin_image, ctx.matting_image, _, _, _, _ = rotate_bound_4channels(
ctx.origin_image,
cv2.split(ctx.matting_image)[-1],
cv2.merge((b, g, r)),
a,
-1 * ctx.face["roll_angle"],
)

Expand Down

0 comments on commit 15d9f4f

Please sign in to comment.