Skip to content

Commit

Permalink
docs: community add wechat miniprogram
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeyi-Lin committed Sep 14, 2024
1 parent f96ebf8 commit 10c2703
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ HivisionIDPhoto 旨在开发一种实用、系统性的证件照智能制作算
[![](assets/comfyui.png)](https://github.com/AIFSH/HivisionIDPhotos-ComfyUI)

- [HivisionIDPhotos-NAS](https://github.com/ONG-Leo/HivisionIDPhotos-NAS): 群晖NAS部署中文教程,由 [ONG-Leo](https://github.com/ONG-Leo) 贡献
- [zjzWx](https://github.com/no1xuan/zjzWx): 精美的开源证件照微信小程序项目,后台基于HivisionIDphotos算法,由 [no1xuan](https://github.com/no1xuan) 贡献
- [HivisionIDPhotos-wechat-weapp](https://github.com/no1xuan/HivisionIDPhotos-wechat-weapp): 微信证件照小程序,基于HivisionIDphotos算法驱动,由 [no1xuan](https://github.com/no1xuan) 贡献

<br>

Expand Down
2 changes: 1 addition & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ We have shared some interesting applications and extensions of HivisionIDPhotos

[![](assets/comfyui.png)](https://github.com/AIFSH/HivisionIDPhotos-ComfyUI)

- [zjzWx](https://github.com/no1xuan/zjzWx): Exquisite open source ID photo WeChat mini program project, contributed by [no1xuan](https://github.com/no1xuan)
- [HivisionIDPhotos-wechat-weapp](https://github.com/no1xuan/HivisionIDPhotos-wechat-weapp): WeChat ID photo mini program, powered by the HivisionIDphotos algorithm, contributed by [no1xuan](https://github.com/no1xuan)

<br>

Expand Down
2 changes: 2 additions & 0 deletions README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ HivisionIDPhotoがあなたに役立つ場合は、このリポジトリをス

[![](assets/comfyui.png)](https://github.com/AIFSH/HivisionIDPhotos-ComfyUI)

- [HivisionIDPhotos-wechat-weapp](https://github.com/no1xuan/HivisionIDPhotos-wechat-weapp): WeChat ID写真ミニプログラムで、HivisionIDphotosアルゴリズムに基づいており、[no1xuan](https://github.com/no1xuan)が貢献しました。

<br>

# 🔧 準備作業
Expand Down
2 changes: 2 additions & 0 deletions README_KO.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ HivisionIDPhoto가 여러분에게 도움이 된다면, 이 리포지토리를

[![](assets/comfyui.png)](https://github.com/AIFSH/HivisionIDPhotos-ComfyUI)

- [HivisionIDPhotos-wechat-weapp](https://github.com/no1xuan/HivisionIDPhotos-wechat-weapp): WeChat ID 사진 미니 프로그램, HivisionIDphotos 알고리즘을 기반으로 하며, [no1xuan](https://github.com/no1xuan)이 기여하였습니다.

<br>

# 🔧 준비 작업
Expand Down
104 changes: 88 additions & 16 deletions hivision/plugin/beauty/grind_skin.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
"""
@author: cuny
@file: GrindSkin.py
@time: 2022/7/2 14:44
@description:
磨皮算法
"""

# Required Libraries
import cv2
import numpy as np
import gradio as gr


def annotate_image(image, grind_degree, detail_degree, strength):
"""Annotates the image with parameters in the lower-left corner."""
font = cv2.FONT_HERSHEY_SIMPLEX
font_scale = 0.5
color = (0, 0, 255)
thickness = 1
line_type = cv2.LINE_AA

# Text positions
y_offset = 20
x_offset = 10
y_base = image.shape[0] - 10

# Define each line of the annotation
lines = [
f"Grind Degree: {grind_degree}",
f"Detail Degree: {detail_degree}",
f"Strength: {strength}",
]

# Draw the text lines on the image
for i, line in enumerate(lines):
y_position = y_base - (i * y_offset)
cv2.putText(
image,
line,
(x_offset, y_position),
font,
font_scale,
color,
thickness,
line_type,
)

return image


def grindSkin(src, grindDegree: int = 3, detailDegree: int = 1, strength: int = 9):
"""
Dest =(Src * (100 - Opacity) + (Src + 2 * GaussBlur(EPFFilter(Src) - Src)) * Opacity) /100
人像磨皮方案,后续会考虑使用一些皮肤区域检测算法来实现仅皮肤区域磨皮,增加算法的精细程度——或者使用人脸关键点
https://www.cnblogs.com/Imageshop/p/4709710.html
Dest =(Src * (100 - Opacity) + (Src + 2 * GaussBlur(EPFFilter(Src) - Src)) * Opacity) / 100
人像磨皮方案
Args:
src: 原图
grindDegree: 磨皮程度调节参数
Expand All @@ -28,8 +58,8 @@ def grindSkin(src, grindDegree: int = 3, detailDegree: int = 1, strength: int =
return src
dst = src.copy()
opacity = min(10.0, strength) / 10.0
dx = grindDegree * 5 # 双边滤波参数之一
fc = grindDegree * 12.5 # 双边滤波参数之一
dx = grindDegree * 5
fc = grindDegree * 12.5
temp1 = cv2.bilateralFilter(src[:, :, :3], dx, fc, fc)
temp2 = cv2.subtract(temp1, src[:, :, :3])
temp3 = cv2.GaussianBlur(temp2, (2 * detailDegree - 1, 2 * detailDegree - 1), 0)
Expand All @@ -38,7 +68,49 @@ def grindSkin(src, grindDegree: int = 3, detailDegree: int = 1, strength: int =
return dst


def process_image(input_img, grind_degree, detail_degree, strength):
# Reading the image using OpenCV
img = cv2.cvtColor(input_img, cv2.COLOR_RGB2BGR)
# Processing the image
output_img = grindSkin(img, grind_degree, detail_degree, strength)
# Annotating the processed image with parameters
output_img_annotated = annotate_image(
output_img.copy(), grind_degree, detail_degree, strength
)
# Horizontal stacking of input and processed images
combined_img = cv2.hconcat([img, output_img_annotated])
# Convert the combined image back to RGB for display
combined_img_rgb = cv2.cvtColor(combined_img, cv2.COLOR_BGR2RGB)
return combined_img_rgb


with gr.Blocks(title="Skin Grinding") as iface:
gr.Markdown("## Skin Grinding Application")

with gr.Row():
image_input = gr.Image(type="numpy", label="Input Image")
image_output = gr.Image(label="Output Image")

grind_degree_slider = gr.Slider(
minimum=1, maximum=10, value=3, step=1, label="Grind Degree"
)
detail_degree_slider = gr.Slider(
minimum=1, maximum=10, value=1, step=1, label="Detail Degree"
)
strength_slider = gr.Slider(
minimum=0, maximum=10, value=9, step=1, label="Strength"
)

gr.Button("Process Image").click(
fn=process_image,
inputs=[
image_input,
grind_degree_slider,
detail_degree_slider,
strength_slider,
],
outputs=image_output,
)

if __name__ == "__main__":
input_image = cv2.imread("test_image/7.jpg")
output_image = grindSkin(src=input_image)
cv2.imwrite("grindSkinCompare.png", np.hstack((input_image, output_image)))
iface.launch()

0 comments on commit 10c2703

Please sign in to comment.