From f96ebf8510777c5462d7bedcc205d378a555a856 Mon Sep 17 00:00:00 2001 From: Ze-Yi LIN <58305964+Zeyi-Lin@users.noreply.github.com> Date: Sat, 14 Sep 2024 01:03:31 +0800 Subject: [PATCH] docs: thanks for support (#117) * update readme * license * TOC * sync multi language * snyc * modelscope * demo add modelscope --- README.md | 20 +++++++++++-- README_EN.md | 58 +++++++++++++++++++++++++----------- README_JP.md | 61 ++++++++++++++++++++++++++------------ README_KO.md | 55 ++++++++++++++++++++++++---------- deploy_api.py | 82 ++++++++++++++++++++++++++------------------------- 5 files changed, 182 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 9ae046d8..62addb5c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ [![][wechat-shield]][wechat-link] [![][spaces-shield]][spaces-link] [![][swanhub-demo-shield]][swanhub-demo-link] +[![][modelscope-shield]][modelscope-link] [![][trendshift-shield]][trendshift-link] [![][hellogithub-shield]][hellogithub-link] @@ -45,12 +46,14 @@ - [联系我们](#-联系我们) - [Q&A](#qa) - [贡献者](#贡献者) +- [感谢支持](#感谢支持) +- [License](#lincese)
# 🤩 最近更新 -- 在线体验: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos) +- 在线体验: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos)、[![][modelscope-shield]][modelscope-link] - 2024.09.12: Gradio Demo增加**美白**功能 | API接口增加**加水印**、**设置照片KB值大小**、**证件照裁切** - 2024.09.11: Gradio Demo增加**透明图显示与下载**功能 @@ -376,10 +379,20 @@ docker run -d -p 7860:7860 \
-# StarHistory +# 感谢支持 + +[![Stargazers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/stars/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/stargazers) + +[![Forkers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/forks/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/network/members) [![Star History Chart](https://api.star-history.com/svg?repos=Zeyi-Lin/HivisionIDPhotos&type=Date)](https://star-history.com/#Zeyi-Lin/HivisionIDPhotos&Date) +
+ +# Lincese + +This repository is licensed under the [Apache-2.0 License](LICENSE). + [github-stars-shield]: https://img.shields.io/github/stars/zeyi-lin/hivisionidphotos?color=ffcb47&labelColor=black&style=flat-square [github-stars-link]: https://github.com/zeyi-lin/hivisionidphotos/stargazers @@ -417,3 +430,6 @@ docker run -d -p 7860:7860 \ [github-forks-shield]: https://img.shields.io/github/forks/zeyi-lin/hivisionidphotos?color=8ae8ff&labelColor=black&style=flat-square [github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members + +[modelscope-shield]: https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBhdGggaWQ9InN2Z18xNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTAsODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTUiIGZpbGw9IiM2MjRhZmYiIGQ9Im05OS4xNCwxMTUuNDlsMjUuNjUsMGwwLDI1LjY1bC0yNS42NSwwbDAsLTI1LjY1eiIvPgogIDxw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LDBsMCwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white +[modelscope-link]: https://modelscope.cn/studios/SwanLab/HivisionIDPhotos \ No newline at end of file diff --git a/README_EN.md b/README_EN.md index def53c95..d41b19ee 100644 --- a/README_EN.md +++ b/README_EN.md @@ -15,6 +15,7 @@ English / [中文](README.md) / [日本語](README_JP.md) / [한국어](README_K [![][wechat-shield]][wechat-link] [![][spaces-shield]][spaces-link] [![][swanhub-demo-shield]][swanhub-demo-link] +[![][modelscope-shield]][modelscope-link] [![][trendshift-shield]][trendshift-link] [![][hellogithub-shield]][hellogithub-link] @@ -43,13 +44,16 @@ English / [中文](README.md) / [日本語](README_JP.md) / [한국어](README_K - [Docker Deployment](#-docker-deployment) - [Contact Us](#-contact-us) - [Contributors](#contributors) +- [Thanks for support](#thanks-for-support) +- [License](#lincese)
# 🤩 Recent Updates -- Online Experience: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos) +- Online Experience: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos)、[![][modelscope-shield]][modelscope-link] +- 2024.09.12: Gradio Demo adds **Whitening** feature | API interface adds **Watermark**, **Set Photo KB Size**, **ID Photo Cropping** - 2024.09.11: Added **transparent image display and download** feature to Gradio Demo. - 2024.09.10: Added a new **face detection model** Retinaface-resnet50, which offers higher detection accuracy at a slightly slower speed compared to mtcnn. Recommended for use. - 2024.09.09: Added a new **Background Removal Model** [BiRefNet-v1-lite](https://github.com/ZhengPeng7/BiRefNet) | Gradio added **Advanced Parameter Settings** and **Watermark** tabs @@ -57,7 +61,6 @@ English / [中文](README.md) / [日本語](README_JP.md) / [한국어](README_K - 2024.09.07: Added **Face Detection API Option** [Face++](docs/face++_EN.md), achieving higher precision in face detection - 2024.09.06: Added new matting model [modnet_photographic_portrait_matting.onnx](https://github.com/ZHKKKe/MODNet) - 2024.09.05: Updated [Restful API Documentation](docs/api_EN.md) -- 2024.09.02: Updated **Adjust Photo KB Size**, [DockerHub](https://hub.docker.com/r/linzeyi/hivision_idphotos/tags)
@@ -176,41 +179,51 @@ Running the program will generate a local web page where you can perform operati Core parameters: - `-i`: Input image path -- `-o`: Save image path -- `-t`: Inference type, options include idphoto, human_matting, add_background, generate_layout_photos -- `--matting_model`: Selection of portrait matting model weights -- `--face_detect_model`: Selection of face detection model +- `-o`: Output image path +- `-t`: Inference type, options are idphoto, human_matting, add_background, generate_layout_photos +- `--matting_model`: Portrait matting model weight selection +- `--face_detect_model`: Face detection model selection More parameters can be viewed by running `python inference.py --help` -## 1. ID Photo Production +## 1. ID Photo Creation -Input 1 photo to obtain 1 standard ID photo and 1 high-definition ID photo in 4-channel transparent png +Input 1 photo to obtain 1 standard ID photo and 1 high-definition ID photo in 4-channel transparent PNG. ```python -python inference.py -i demo/images/test.jpg -o ./idphoto.png --height 413 --width 295 +python inference.py -i demo/images/test0.jpg -o ./idphoto.png --height 413 --width 295 ``` ## 2. Portrait Matting +Input 1 photo to obtain 1 4-channel transparent PNG. + ```python -python inference.py -t human_matting -i demo/images/test.jpg -o ./idphoto_matting.png --matting_model hivision_modnet +python inference.py -t human_matting -i demo/images/test0.jpg -o ./idphoto_matting.png --matting_model hivision_modnet ``` ## 3. Add Background Color to Transparent Image -Input 1 4-channel transparent png to obtain 1 image with added background color +Input 1 4-channel transparent PNG to obtain 1 3-channel image with added background color. + +```python +python inference.py -t add_background -i ./idphoto.png -o ./idphoto_ab.jpg -c 4f83ce -k 30 -r 1 +``` + +## 4. Generate Six-Inch Layout Photo + +Input 1 3-channel photo to obtain 1 six-inch layout photo. ```python -python inference.py -t add_background -i ./idphoto.png -o ./idphoto_ab.jpg -c 4f83ce -k 30 -r 1 +python inference.py -t generate_layout_photos -i ./idphoto_ab.jpg -o ./idphoto_layout.jpg --height 413 --width 295 -k 200 ``` -## 4. Obtain Six-Inch Layout Photo +## 5. ID Photo Cropping -Input 1 3-channel photo to obtain 1 six-inch layout photo +Input 1 4-channel photo (the image after matting) to obtain 1 standard ID photo and 1 high-definition ID photo in 4-channel transparent PNG. ```python -python inference.py -t generate_layout_photos -i ./idphoto_ab.jpg -o ./idphoto_layout.jpg --height 413 --width 295 -k 200 +python inference.py -t idphoto_crop -i ./idphoto_matting.png -o ./idphoto_crop.png --height 413 --width 295 ```
@@ -360,10 +373,18 @@ If you have any questions, please email zeyi.lin@swanhub.co
-# StarHistory +# Thanks for support + +[![Stargazers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/stars/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/stargazers) + +[![Forkers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/forks/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/network/members) [![Star History Chart](https://api.star-history.com/svg?repos=Zeyi-Lin/HivisionIDPhotos&type=Date)](https://star-history.com/#Zeyi-Lin/HivisionIDPhotos&Date) +# Lincese + +This repository is licensed under the [Apache-2.0 License](LICENSE). + [github-stars-shield]: https://img.shields.io/github/stars/zeyi-lin/hivisionidphotos?color=ffcb47&labelColor=black&style=flat-square [github-stars-link]: https://github.com/zeyi-lin/hivisionidphotos/stargazers @@ -400,4 +421,7 @@ If you have any questions, please email zeyi.lin@swanhub.co [github-contributors-link]: https://github.com/zeyi-lin/hivisionidphotos/graphs/contributors [github-forks-shield]: https://img.shields.io/github/forks/zeyi-lin/hivisionidphotos?color=8ae8ff&labelColor=black&style=flat-square -[github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members \ No newline at end of file +[github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members + +[modelscope-shield]: https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBhdGggaWQ9InN2Z18xNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTAsODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTUiIGZpbGw9IiM2MjRhZmYiIGQ9Im05OS4xNCwxMTUuNDlsMjUuNjUsMGwwLDI1LjY1bC0yNS42NSwwbDAsLTI1LjY1eiIvPgogIDxwYXRoIGlkPSJzdmdfMTYiIGZpbGw9IiM2MjRhZmYiIGQ9Im0xNzYuMDksMTQxLjE0bC0yNS42NDk5OSwwbDAsMjIuMTlsNDcuODQsMGwwLC00Ny44NGwtMjIuMTksMGwwLDI1LjY1eiIvPgogIDxwYXRoIGlkPSJzdmdfMTciIGZpbGw9IiMzNmNmZDEiIGQ9Im0xMjQuNzksODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTgiIGZpbGw9IiMzNmNmZDEiIGQ9Im0wLDY0LjE5bDI1LjY1LDBsMCwyNS42NWwtMjUuNjUsMGwwLC0yNS42NXoiLz4KICA8cGF0aCBpZD0ic3ZnXzE5IiBmaWxsPSIjNjI0YWZmIiBkPSJtMTk4LjI4LDg5Ljg0bDI1LjY0OTk5LDBsMCwyNS42NDk5OWwtMjUuNjQ5OTksMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIwIiBmaWxsPSIjMzZjZmQxIiBkPSJtMTk4LjI4LDY0LjE5bDI1LjY0OTk5LDBsMCwyNS42NWwtMjUuNjQ5OTksMGwwLC0yNS42NXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIxIiBmaWxsPSIjNjI0YWZmIiBkPSJtMTUwLjQ0LDQybDAsMjIuMTlsMjUuNjQ5OTksMGwwLDI1LjY1bDIyLjE5LDBsMCwtNDcuODRsLTQ3Ljg0LDB6Ii8+CiAgPHBhdGggaWQ9InN2Z18yMiIgZmlsbD0iIzM2Y2ZkMSIgZD0ibTczLjQ5LDg5Ljg0bDI1LjY1LDBsMCwyNS42NDk5OWwtMjUuNjUsMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIzIiBmaWxsPSIjNjI0YWZmIiBkPSJtNDcuODQsNjQuMTlsMjUuNjUsMGwwLC0yMi4xOWwtNDcuODQsMGwwLDQ3Ljg0bDIyLjE5LDBsMCwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white +[modelscope-link]: https://modelscope.cn/studios/SwanLab/HivisionIDPhotos \ No newline at end of file diff --git a/README_JP.md b/README_JP.md index 83c0857f..a521dcc0 100644 --- a/README_JP.md +++ b/README_JP.md @@ -15,6 +15,7 @@ [![][wechat-shield]][wechat-link] [![][spaces-shield]][spaces-link] [![][swanhub-demo-shield]][swanhub-demo-link] +[![][modelscope-shield]][modelscope-link] [![][trendshift-shield]][trendshift-link] [![][hellogithub-shield]][hellogithub-link] @@ -48,16 +49,15 @@ # 🤩 最近の更新 -- オンライン体験: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos) +- オンライン体験: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos)、[![][modelscope-shield]][modelscope-link] +- 2024.09.12: Gradioデモに**ホワイトニング**機能を追加 | APIインターフェースに**ウォーターマーク追加**、**写真のKBサイズ設定**、**証明写真のトリミング**を追加 - 2024.09.11: Gradioデモに**透過画像表示とダウンロード**機能を追加しました。 - 2024.09.09: 新しい**背景除去モデル** [BiRefNet-v1-lite](https://github.com/ZhengPeng7/BiRefNet) を追加 | Gradioに**高度なパラメータ設定**および**ウォーターマーク**タブを追加 - 2024.09.08: 新しい**切り抜きモデル** [RMBG-1.4](https://huggingface.co/briaai/RMBG-1.4) を追加 | **ComfyUIワークフロー** - [HivisionIDPhotos-ComfyUI](https://github.com/AIFSH/HivisionIDPhotos-ComfyUI) AIFSHによる貢献 - 2024.09.07: **顔検出APIオプション** [Face++](docs/face++_EN.md) を追加し、より高精度な顔検出を実現 - 2024.09.06: 新しい切り抜きモデル [modnet_photographic_portrait_matting.onnx](https://github.com/ZHKKKe/MODNet) を追加 - 2024.09.05: [Restful API ドキュメント](docs/api_EN.md) を更新 -- 2024.09.02: **写真のKBサイズを調整**を更新、[DockerHub](https://hub.docker.com/r/linzeyi/hivision_idphotos/tags) -- 2023.12.01: **APIデプロイ(fastapiベース)**を更新
@@ -170,44 +170,54 @@ python app.py # 🚀 Python推論 -コアパラメータ: +核心パラメータ: -- `-i`: 入力画像パス -- `-o`: 保存画像パス +- `-i`: 入力画像のパス +- `-o`: 保存画像のパス - `-t`: 推論タイプ、idphoto、human_matting、add_background、generate_layout_photosから選択可能 -- `--matting_model`: 人物切り抜きモデル重みの選択 +- `--matting_model`: 人物切り抜きモデルの重み選択 - `--face_detect_model`: 顔検出モデルの選択 -詳しいパラメータは、`python inference.py --help`で確認できます。 +詳細なパラメータは`python inference.py --help`で確認できます。 -## 1. 証明写真の制作 +## 1. 証明写真の作成 -1枚の写真を入力し、1枚の標準証明写真と1枚の高解像度証明写真の4チャンネル透明PNGを得る。 +1枚の写真を入力し、1枚の標準証明写真と1枚の高解像度証明写真の4チャンネル透明PNGを取得します。 ```python -python inference.py -i demo/images/test.jpg -o ./idphoto.png --height 413 --width 295 +python inference.py -i demo/images/test0.jpg -o ./idphoto.png --height 413 --width 295 ``` ## 2. 人物切り抜き +1枚の写真を入力し、1枚の4チャンネル透明PNGを取得します。 + ```python -python inference.py -t human_matting -i demo/images/test.jpg -o ./idphoto_matting.png --matting_model hivision_modnet +python inference.py -t human_matting -i demo/images/test0.jpg -o ./idphoto_matting.png --matting_model hivision_modnet ``` ## 3. 透明画像に背景色を追加 -1枚の4チャンネル透明PNGを入力し、背景色を追加した画像を得る。 +1枚の4チャンネル透明PNGを入力し、背景色を追加した3チャンネル画像を取得します。 ```python -python inference.py -t add_background -i ./idphoto.png -o ./idphoto_ab.jpg -c 4f83ce -k 30 -r 1 +python inference.py -t add_background -i ./idphoto.png -o ./idphoto_ab.jpg -c 4f83ce -k 30 -r 1 ``` -## 4. 六寸レイアウト写真を得る +## 4. 六寸レイアウト写真の取得 -1枚の3チャンネル写真を入力し、1枚の六寸レイアウト写真を得る。 +1枚の3チャンネル写真を入力し、1枚の六寸レイアウト写真を取得します。 ```python -python inference.py -t generate_layout_photos -i ./idphoto_ab.jpg -o ./idphoto_layout.jpg --height 413 --width 295 -k 200 +python inference.py -t generate_layout_photos -i ./idphoto_ab.jpg -o ./idphoto_layout.jpg --height 413 --width 295 -k 200 +``` + +## 5. 証明写真のトリミング + +1枚の4チャンネル写真(切り抜き済みの画像)を入力し、1枚の標準証明写真と1枚の高解像度証明写真の4チャンネル透明PNGを取得します。 + +```python +python inference.py -t idphoto_crop -i ./idphoto_matting.png -o ./idphoto_crop.png --height 413 --width 295 ```
@@ -357,10 +367,20 @@ docker run -d -p 7860:7860 \
-# StarHistory +# Thanks for support + +[![Stargazers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/stars/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/stargazers) + +[![Forkers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/forks/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/network/members) [![Star History Chart](https://api.star-history.com/svg?repos=Zeyi-Lin/HivisionIDPhotos&type=Date)](https://star-history.com/#Zeyi-Lin/HivisionIDPhotos&Date) +
+ +# Lincese + +This repository is licensed under the [Apache-2.0 License](LICENSE). + [github-stars-shield]: https://img.shields.io/github/stars/zeyi-lin/hivisionidphotos?color=ffcb47&labelColor=black&style=flat-square [github-stars-link]: https://github.com/zeyi-lin/hivisionidphotos/stargazers @@ -397,4 +417,7 @@ docker run -d -p 7860:7860 \ [github-contributors-link]: https://github.com/zeyi-lin/hivisionidphotos/graphs/contributors [github-forks-shield]: https://img.shields.io/github/forks/zeyi-lin/hivisionidphotos?color=8ae8ff&labelColor=black&style=flat-square -[github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members \ No newline at end of file +[github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members + +[modelscope-shield]: https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3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GwwLDI1LjY1bDIyLjE5LDBsMCwtNDcuODRsLTQ3Ljg0LDB6Ii8+CiAgPHBhdGggaWQ9InN2Z18yMiIgZmlsbD0iIzM2Y2ZkMSIgZD0ibTczLjQ5LDg5Ljg0bDI1LjY1LDBsMCwyNS42NDk5OWwtMjUuNjUsMGwwLC0yNS42NDk5OXoiLz4KICA8cGF0aCBpZD0ic3ZnXzIzIiBmaWxsPSIjNjI0YWZmIiBkPSJtNDcuODQsNjQuMTlsMjUuNjUsMGwwLC0yMi4xOWwtNDcuODQsMGwwLDQ3Ljg0bDIyLjE5LDBsMCwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white +[modelscope-link]: https://modelscope.cn/studios/SwanLab/HivisionIDPhotos \ No newline at end of file diff --git a/README_KO.md b/README_KO.md index 0fb8e64e..79c8537b 100644 --- a/README_KO.md +++ b/README_KO.md @@ -15,6 +15,7 @@ [![][wechat-shield]][wechat-link] [![][spaces-shield]][spaces-link] [![][swanhub-demo-shield]][swanhub-demo-link] +[![][modelscope-shield]][modelscope-link] [![][trendshift-shield]][trendshift-link] [![][hellogithub-shield]][hellogithub-link] @@ -48,17 +49,16 @@ # 🤩 최근 업데이트 -- 온라인 체험: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos) +- 온라인 체험: [![SwanHub Demo](https://img.shields.io/static/v1?label=Demo&message=SwanHub%20Demo&color=blue)](https://swanhub.co/ZeYiLin/HivisionIDPhotos/demo)、[![Spaces](https://img.shields.io/badge/🤗-Open%20in%20Spaces-blue)](https://huggingface.co/spaces/TheEeeeLin/HivisionIDPhotos)、[![][modelscope-shield]][modelscope-link] +- 2024.09.12: Gradio 데모에 **미백** 기능 추가 | API 인터페이스에 **워터마크 추가**, **사진 KB 크기 설정**, **증명사진 자르기** 추가 - 2024.09.11: Gradio Demo에 **투명 이미지 표시 및 다운로드** 기능 추가 - 2024.09.09: 새로운 **배경 제거 모델** [BiRefNet-v1-lite](https://github.com/ZhengPeng7/BiRefNet) 추가 | Gradio에 **고급 매개변수 설정** 및 **워터마크** 탭 추가 - 2024.09.08: 새로운 **컷아웃 모델** [RMBG-1.4](https://huggingface.co/briaai/RMBG-1.4) 추가 | **ComfyUI 워크플로우** - [HivisionIDPhotos-ComfyUI](https://github.com/AIFSH/HivisionIDPhotos-ComfyUI) AIFSH의 기여 - 2024.09.07: **얼굴 검출 API 옵션** [Face++](docs/face++_EN.md) 추가 및 보다 높은 정확도의 얼굴 검출 구현 - 2024.09.06: 새로운 컷아웃 모델 [modnet_photographic_portrait_matting.onnx](https://github.com/ZHKKKe/MODNet) 추가 - 2024.09.05: [Restful API 문서](docs/api_EN.md) 업데이트 -- 2024.09.02: **사진의 KB 크기 조정** 업데이트, [DockerHub](https://hub.docker.com/r/linzeyi/hivision_idphotos/tags) -- 2023.12.01: **API 배포(fastapi 기반)** 업데이트
@@ -175,42 +175,52 @@ python app.py - `-i`: 입력 이미지 경로 - `-o`: 저장 이미지 경로 -- `-t`: 추론 유형, idphoto, human_matting, add_background, generate_layout_photos 중 선택 가능 -- `--matting_model`: 인물 컷아웃 모델 가중치 선택 -- `--face_detect_model`: 얼굴 검출 모델 선택 +- `-t`: 추론 유형, idphoto, human_matting, add_background, generate_layout_photos 중 선택 +- `--matting_model`: 인물 마스크 모델 가중치 선택 +- `--face_detect_model`: 얼굴 감지 모델 선택 -자세한 매개변수는 `python inference.py --help`에서 확인할 수 있습니다. +더 많은 매개변수는 `python inference.py --help`를 통해 확인할 수 있습니다. ## 1. 증명사진 제작 -1장의 사진을 입력하여 1장의 표준 증명사진과 1장의 고해상도 증명사진의 4채널 투명 PNG를 얻습니다. +1장의 사진을 입력하여 1장의 표준 증명사진과 1장의 고화질 증명사진의 4채널 투명 PNG를 얻습니다. ```python -python inference.py -i demo/images/test.jpg -o ./idphoto.png --height 413 --width 295 +python inference.py -i demo/images/test0.jpg -o ./idphoto.png --height 413 --width 295 ``` -## 2. 인물 컷아웃 +## 2. 인물 마스크 + +1장의 사진을 입력하여 1장의 4채널 투명 PNG를 얻습니다. ```python -python inference.py -t human_matting -i demo/images/test.jpg -o ./idphoto_matting.png --matting_model hivision_modnet +python inference.py -t human_matting -i demo/images/test0.jpg -o ./idphoto_matting.png --matting_model hivision_modnet ``` ## 3. 투명 이미지에 배경색 추가 -1장의 4채널 투명 PNG를 입력하여 배경색이 추가된 이미지를 얻습니다. +1장의 4채널 투명 PNG를 입력하여 1장의 배경색이 추가된 3채널 이미지를 얻습니다. ```python python inference.py -t add_background -i ./idphoto.png -o ./idphoto_ab.jpg -c 4f83ce -k 30 -r 1 ``` -## 4. 육寸 레이아웃 사진 얻기 +## 4. 6인치 배치 사진 생성 -1장의 3채널 사진을 입력하여 1장의 육寸 레이아웃 사진을 얻습니다. +1장의 3채널 사진을 입력하여 1장의 6인치 배치 사진을 얻습니다. ```python python inference.py -t generate_layout_photos -i ./idphoto_ab.jpg -o ./idphoto_layout.jpg --height 413 --width 295 -k 200 ``` +## 5. 증명사진 자르기 + +1장의 4채널 사진(마스크 처리된 이미지)을 입력하여 1장의 표준 증명사진과 1장의 고화질 증명사진의 4채널 투명 PNG를 얻습니다. + +```python +python inference.py -t idphoto_crop -i ./idphoto_matting.png -o ./idphoto_crop.png --height 413 --width 295 +``` +
# ⚡️ API 서비스 배포 @@ -358,10 +368,20 @@ docker run -d -p 7860:7860 \
-# StarHistory +# Thanks for support + +[![Stargazers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/stars/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/stargazers) + +[![Forkers repo roster for @Zeyi-Lin/HivisionIDPhotos](https://reporoster.com/forks/Zeyi-Lin/HivisionIDPhotos)](https://github.com/Zeyi-Lin/HivisionIDPhotos/network/members) [![Star History Chart](https://api.star-history.com/svg?repos=Zeyi-Lin/HivisionIDPhotos&type=Date)](https://star-history.com/#Zeyi-Lin/HivisionIDPhotos&Date) +
+ +# Lincese + +This repository is licensed under the [Apache-2.0 License](LICENSE). + [github-stars-shield]: https://img.shields.io/github/stars/zeyi-lin/hivisionidphotos?color=ffcb47&labelColor=black&style=flat-square [github-stars-link]: https://github.com/zeyi-lin/hivisionidphotos/stargazers @@ -398,4 +418,7 @@ docker run -d -p 7860:7860 \ [github-contributors-link]: https://github.com/zeyi-lin/hivisionidphotos/graphs/contributors [github-forks-shield]: https://img.shields.io/github/forks/zeyi-lin/hivisionidphotos?color=8ae8ff&labelColor=black&style=flat-square -[github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members \ No newline at end of file +[github-forks-link]: https://github.com/zeyi-lin/hivisionidphotos/network/members + +[modelscope-shield]: https://img.shields.io/badge/Demo_on_ModelScope-purple?logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIzIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KCiA8Zz4KICA8dGl0bGU+TGF5ZXIgMTwvdGl0bGU+CiAgPHBhdGggaWQ9InN2Z18xNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTAsODkuODRsMjUuNjUsMGwwLDI1LjY0OTk5bC0yNS42NSwwbDAsLTI1LjY0OTk5eiIvPgogIDxwYXRoIGlkPSJzdmdfMTUiIGZpbGw9IiM2MjRhZmYiIGQ9Im05OS4xNCwxMTUuNDlsMjUuNjUsMGwwLDI1LjY1bC0yNS42NSwwbDAsLTI1LjY1eiIvPgogIDxwYXRoI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CwtMjUuNjV6Ii8+CiAgPHBhdGggaWQ9InN2Z18yNCIgZmlsbD0iIzYyNGFmZiIgZD0ibTQ3Ljg0LDExNS40OWwtMjIuMTksMGwwLDQ3Ljg0bDQ3Ljg0LDBsMCwtMjIuMTlsLTI1LjY1LDBsMCwtMjUuNjV6Ii8+CiA8L2c+Cjwvc3ZnPg==&labelColor=white +[modelscope-link]: https://modelscope.cn/studios/SwanLab/HivisionIDPhotos \ No newline at end of file diff --git a/deploy_api.py b/deploy_api.py index 67b83504..c2a0b9c9 100644 --- a/deploy_api.py +++ b/deploy_api.py @@ -25,7 +25,9 @@ CORSMiddleware, allow_origins=["*"], # 允许的请求来源 allow_credentials=True, # 允许携带 Cookie - allow_methods=["*"], # 允许的请求方法,例如:GET, POST 等,也可以指定 ["GET", "POST"] + allow_methods=[ + "*" + ], # 允许的请求方法,例如:GET, POST 等,也可以指定 ["GET", "POST"] allow_headers=["*"], # 允许的请求头,也可以指定具体的头部 ) @@ -35,22 +37,22 @@ def numpy_2_base64(img: np.ndarray): retval, buffer = cv2.imencode(".png", img) base64_image = base64.b64encode(buffer).decode("utf-8") - return base64_image + return "data:image/png;base64," + base64_image # 证件照智能制作接口 @app.post("/idphoto") async def idphoto_inference( - input_image: UploadFile, - height: int = Form(413), - width: int = Form(295), - human_matting_model: str = Form("hivision_modnet"), - face_detect_model: str = Form("mtcnn"), - 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, + input_image: UploadFile, + height: int = Form(413), + width: int = Form(295), + human_matting_model: str = Form("hivision_modnet"), + face_detect_model: str = Form("mtcnn"), + 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() nparr = np.frombuffer(image_bytes, np.uint8) @@ -88,8 +90,8 @@ async def idphoto_inference( # 人像抠图接口 @app.post("/human_matting") async def human_matting_inference( - input_image: UploadFile, - human_matting_model: str = Form("hivision_modnet"), + input_image: UploadFile, + human_matting_model: str = Form("hivision_modnet"), ): image_bytes = await input_image.read() nparr = np.frombuffer(image_bytes, np.uint8) @@ -117,10 +119,10 @@ async def human_matting_inference( # 透明图像添加纯色背景接口 @app.post("/add_background") async def photo_add_background( - input_image: UploadFile, - color: str = Form("000000"), - kb: int = Form(50), - render: int = Form(0), + input_image: UploadFile, + color: str = Form("000000"), + kb: int = Form(50), + render: int = Form(0), ): render_choice = ["pure_color", "updown_gradient", "center_gradient"] @@ -162,10 +164,10 @@ async def photo_add_background( # 六寸排版照生成接口 @app.post("/generate_layout_photos") async def generate_layout_photos( - input_image: UploadFile, - height: int = Form(413), - width: int = Form(295), - kb: int = Form(50), + input_image: UploadFile, + height: int = Form(413), + width: int = Form(295), + kb: int = Form(50), ): # try: image_bytes = await input_image.read() @@ -206,13 +208,13 @@ async def generate_layout_photos( # 透明图像添加纯色背景接口 @app.post("/watermark") async def watermark( - input_image: UploadFile, - text: str = Form("Hello"), - size: int = 20, - opacity: float = 0.5, - angle: int = 30, - color: str = "#000000", - space: int = 25, + input_image: UploadFile, + text: str = Form("Hello"), + size: int = 20, + opacity: float = 0.5, + angle: int = 30, + color: str = "#000000", + space: int = 25, ): image_bytes = await input_image.read() nparr = np.frombuffer(image_bytes, np.uint8) @@ -237,8 +239,8 @@ async def watermark( # 设置照片KB值接口(RGB图) @app.post("/set_kb") async def set_kb( - input_image: UploadFile, - kb: int = Form(50), + input_image: UploadFile, + kb: int = Form(50), ): image_bytes = await input_image.read() nparr = np.frombuffer(image_bytes, np.uint8) @@ -264,15 +266,15 @@ async def set_kb( # 证件照智能裁剪接口 @app.post("/idphoto_crop") async def idphoto_crop_inference( - input_image: UploadFile, - height: int = Form(413), - width: int = Form(295), - face_detect_model: str = Form("mtcnn"), - 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, + input_image: UploadFile, + height: int = Form(413), + width: int = Form(295), + face_detect_model: str = Form("mtcnn"), + 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() nparr = np.frombuffer(image_bytes, np.uint8)