mirror of
https://github.com/Zeyi-Lin/HivisionIDPhotos.git
synced 2025-09-15 14:58:34 +08:00
feat: api idphoto hd (#107)
* idphoto hd * Update deploy_api.py * Update api_CN.md
This commit is contained in:
parent
7ca017c3f9
commit
fd90bb9431
22
.github/workflows/sync-to-gitee.yml
vendored
22
.github/workflows/sync-to-gitee.yml
vendored
@ -1,22 +0,0 @@
|
||||
name: Sync to Gitee
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master # 或者你想要同步的其他分支
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
environment: gitee
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Push to Gitee
|
||||
run: |
|
||||
git config --global user.name ${{ vars.GITEE_USERNAME }}
|
||||
git config --global user.email ${{ vars.GITEE_EMAIL }}
|
||||
git remote add gitee https://${{ vars.GITEE_USERNAME }}:${{ secrets.GITEE_TOKEN }}@gitee.com/${{ vars.GITEE_USERNAME }}/HivisionIDPhotos.git
|
||||
git push -f gitee master:master
|
||||
@ -32,14 +32,15 @@ def numpy_2_base64(img: np.ndarray):
|
||||
@app.post("/idphoto")
|
||||
async def idphoto_inference(
|
||||
input_image: UploadFile,
|
||||
height: str = Form(...),
|
||||
width: str = Form(...),
|
||||
height: int = Form(413),
|
||||
width: int = Form(295),
|
||||
human_matting_model: str = Form("hivision_modnet"),
|
||||
face_detect_model: str = Form("mtcnn"),
|
||||
head_measure_ratio=0.2,
|
||||
head_height_ratio=0.45,
|
||||
top_distance_max=0.12,
|
||||
top_distance_min=0.10,
|
||||
hd: bool = Form(True),
|
||||
head_measure_ratio: float = 0.2,
|
||||
head_height_ratio: float = 0.45,
|
||||
top_distance_max: float = 0.12,
|
||||
top_distance_min: float = 0.10,
|
||||
):
|
||||
|
||||
image_bytes = await input_image.read()
|
||||
@ -66,15 +67,18 @@ async def idphoto_inference(
|
||||
result_message = {
|
||||
"status": True,
|
||||
"image_base64_standard": numpy_2_base64(result.standard),
|
||||
"image_base64_hd": numpy_2_base64(result.hd),
|
||||
}
|
||||
|
||||
# 如果hd为True, 则增加高清照结果(png 4通道图像)
|
||||
if hd:
|
||||
result_message["image_base64_hd"] = numpy_2_base64(result.hd)
|
||||
|
||||
return result_message
|
||||
|
||||
|
||||
# 人像抠图接口
|
||||
@app.post("/human_matting")
|
||||
async def idphoto_inference(
|
||||
async def human_matting_inference(
|
||||
input_image: UploadFile,
|
||||
human_matting_model: str = Form("hivision_modnet"),
|
||||
):
|
||||
@ -105,8 +109,8 @@ async def idphoto_inference(
|
||||
@app.post("/add_background")
|
||||
async def photo_add_background(
|
||||
input_image: UploadFile,
|
||||
color: str = Form(...),
|
||||
kb: str = Form(None),
|
||||
color: str = Form("000000"),
|
||||
kb: int = Form(50),
|
||||
render: int = Form(0),
|
||||
):
|
||||
render_choice = ["pure_color", "updown_gradient", "center_gradient"]
|
||||
@ -150,9 +154,9 @@ async def photo_add_background(
|
||||
@app.post("/generate_layout_photos")
|
||||
async def generate_layout_photos(
|
||||
input_image: UploadFile,
|
||||
height: str = Form(...),
|
||||
width: str = Form(...),
|
||||
kb: str = Form(None),
|
||||
height: int = Form(413),
|
||||
width: int = Form(295),
|
||||
kb: int = Form(50),
|
||||
):
|
||||
# try:
|
||||
image_bytes = await input_image.read()
|
||||
|
||||
@ -83,7 +83,8 @@ curl -X POST "http://127.0.0.1:8080/idphoto" \
|
||||
-F "height=413" \
|
||||
-F "width=295" \
|
||||
-F "human_matting_model=hivision_modnet" \
|
||||
-F "face_detect_model=mtcnn"
|
||||
-F "face_detect_model=mtcnn" \
|
||||
-F "hd=true"
|
||||
```
|
||||
|
||||
### 2. 添加背景色
|
||||
@ -148,7 +149,7 @@ url = "http://127.0.0.1:8080/idphoto"
|
||||
input_image_path = "demo/images/test0.jpg"
|
||||
|
||||
files = {"input_image": open(input_image_path, "rb")}
|
||||
data = {"height": 413, "width": 295, "human_matting_model": "hivision_modnet", "face_detect_model": "mtcnn"}
|
||||
data = {"height": 413, "width": 295, "human_matting_model": "hivision_modnet", "face_detect_model": "mtcnn", "hd": True}
|
||||
|
||||
response = requests.post(url, files=files, data=data).json()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user