{"id":14038312,"url":"https://github.com/aoguai/LiYing","last_synced_at":"2025-07-27T07:33:18.087Z","repository":{"id":251463236,"uuid":"837479775","full_name":"aoguai/LiYing","owner":"aoguai","description":"A program for automating the post-processing of photographs in general photo studios. | 一套适用于自动化完成一般照相馆后期流程的照片自动处理的程序。","archived":false,"fork":false,"pushed_at":"2024-08-09T08:39:15.000Z","size":6666,"stargazers_count":224,"open_issues_count":1,"forks_count":31,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-13T04:04:13.969Z","etag":null,"topics":["background-replacement","image-compression","image-cropping","photo-layout","photo-processing","portrait-recognition"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aoguai.png","metadata":{"files":{"readme":"docs/README-EN.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-03T05:24:35.000Z","updated_at":"2024-08-13T02:07:05.000Z","dependencies_parsed_at":"2024-08-06T09:57:36.497Z","dependency_job_id":null,"html_url":"https://github.com/aoguai/LiYing","commit_stats":null,"previous_names":["aoguai/liying"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aoguai%2FLiYing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aoguai%2FLiYing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aoguai%2FLiYing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aoguai%2FLiYing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aoguai","download_url":"https://codeload.github.com/aoguai/LiYing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227780690,"owners_count":17818981,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["background-replacement","image-compression","image-cropping","photo-layout","photo-processing","portrait-recognition"],"created_at":"2024-08-12T04:01:19.805Z","updated_at":"2025-07-27T07:33:18.081Z","avatar_url":"https://github.com/aoguai.png","language":"Python","funding_links":[],"categories":["Python","App","B站"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003ch1\u003eLiYing\u003c/h1\u003e\n\n[简体中文](./README.md) | English\n\n[![GitHub release](https://img.shields.io/github/v/release/aoguai/LiYing?color=369eff\u0026labelColor=black\u0026logo=github\u0026style=flat-square)](https://github.com/aoguai/LiYing/releases/latest)\n[![GitHub stars](https://img.shields.io/github/stars/aoguai/LiYing?color=ffcb47\u0026labelColor=black\u0026style=flat-square)](https://github.com/aoguai/LiYing/stargazers)\n[![GitHub issues](https://img.shields.io/github/issues/aoguai/LiYing?color=ff80eb\u0026labelColor=black\u0026style=flat-square)](https://github.com/aoguai/LiYing/issues)\n[![GitHub contributors](https://img.shields.io/github/contributors/aoguai/LiYing?color=c4f042\u0026labelColor=black\u0026style=flat-square)](https://github.com/aoguai/LiYing/graphs/contributors)\n[![GitHub forks](https://img.shields.io/github/forks/aoguai/LiYing?color=8ae8ff\u0026labelColor=black\u0026style=flat-square)](https://github.com/aoguai/LiYing/network/members)\n[![License](https://img.shields.io/badge/license-AGPL--3.0-white?labelColor=black\u0026style=flat-square)](../LICENSE)\n\n\u003cp\u003eLiYing is an automated photo processing program designed for automating the post-processing workflow of ID photos in general photo studios.\u003c/p\u003e\n\n\u003c/div\u003e\n\n\u003cbr\u003e\n\n## Project Introduction\n\nLiYing can automatically identify human bodies and faces, correct angles, change background colors, crop passport photos to any size, and automatically arrange them.\n\nLiYing can run completely offline. All image processing operations are performed locally.\n\n### Workflow\n\n![workflows](../images/workflows.png)\n\n### Showcase\n\n| ![test1](../images/test1.jpg) | ![test2](../images/test2.jpg) | ![test3](../images/test3.jpg) |\n| ----------------------------- | ---------------------------- | ---------------------------- |\n| ![test1_output_sheet](../images/test1_output_sheet.jpg)(1-inch on 5-inch photo paper - 3x3) | ![test2_output_sheet](../images/test2_output_sheet.jpg)(2-inch on 5-inch photo paper - 2x2) | ![test3_output_sheet](../images/test3_output_sheet.jpg)(1-inch on 6-inch photo paper - 4x2) |\n\n**Note: This project is specifically for processing passport photos and may not work perfectly on any arbitrary image. The input images should be standard single-person portrait photos.**\n\n**It is normal for unexpected results to occur if you use complex images to create passport photos.**\n\n\u003cbr\u003e\n\n## Getting Started\n\n### Bundled Package\n\nIf you are a Windows user and do not need to review the code, you can [download the bundled package](https://github.com/aoguai/LiYing/releases/latest) (tested on Windows 7 SP1 \u0026 Windows 10).\n\nThe bundled package does not include any models. You can refer to the [Downloading the Required Models](#downloading-the-required-models) section for instructions on downloading the models and placing them in the correct directory.\n\nIf you encounter issues while running the program, please first check the [Prerequisites](#prerequisites) section to ensure your environment is properly set up. If everything is fine, you can ignore this step.\n\n#### Running the bundled package\n\nRun the BAT script:\n```shell\ncd LiYing\nrun.bat ./images/test1.jpg\n```\n\nRun the WebUI interface:\n```shell\n# Run WebUI\ncd LiYing\nrun_webui.bat\n# Open your browser and visit 127.0.0.1:7860\n```\n\n### Prerequisites\n\n1. **Dependencies**\n   - LiYing depends on AGPicCompress\n   - AGPicCompress requires `mozjpeg` and `pngquant`\n   - You may need to manually install `pngquant`, refer to the [pngquant official documentation](https://pngquant.org/)\n\n2. **pngquant Configuration Location**\n   - Environment variables (recommended)\n   - LiYing/src directory\n   - `ext` directory under LiYing/src\n\n3. **System Requirements**\n   - Windows users need to install the latest [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist).\n   - If you are using Windows, your minimum version should be Windows 7 SP1 or higher.\n\n### Building from Source\n\n1. Clone the project:\n\n```shell\ngit clone https://github.com/aoguai/LiYing\ncd LiYing ## Enter the LiYing directory\npip install -r requirements.txt # Install Python helpers' dependencies\n```\n\n**Note: If you are using Windows 7, ensure you have at least Windows 7 SP1 and `onnxruntime==1.14.0, orjson==3.10.7, gradio==4.44.1`.**\n\n### Downloading the Required Models\n\nDownload the models used by the project and place them in `LiYing/src/model`, or specify the model paths in the command line.\n\n| Purpose                   | Model Name        | Download Link                                                                                                                                           | Source                                                     |\n|---------------------------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------|\n| Face Recognition          | Yunnet            | [Download Link](https://github.com/opencv/opencv_zoo/blob/main/models/face_detection_yunet/face_detection_yunet_2023mar.onnx)                           | [Yunnet](https://github.com/ShiqiYu/libfacedetection)      |\n| Subject Recognition and Background Replacement | RMBG-1.4/2.0 | [1.4 Download Link](https://huggingface.co/briaai/RMBG-1.4/blob/main/onnx/model.onnx)/[2.0 Download Link](https://huggingface.co/briaai/RMBG-2.0/tree/main/onnx) | [BRIA AI](https://huggingface.co/briaai)         |\n| Body Recognition          | yolov8n-pose      | [Download Link](https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n-pose.pt)                                                         | [ultralytics](https://github.com/ultralytics/ultralytics) |\n\n**Note: For the yolov8n-pose model, you need to export it to an ONNX model. Refer to the [official documentation](https://docs.ultralytics.com/integrations/onnx/) for instructions.**\n\nWe also provide pre-converted ONNX models that you can download and use directly:\n\n| Download Method  | Link  |\n|-----------------|--------------------------------------------------------------------------------|\n| Google Drive   | [Download Link](https://drive.google.com/file/d/1F8EQfwkeq4s-P2W4xQjD28c4rxPuX1R3/view) |\n| Baidu Netdisk  | [Download Link (Extraction Code: ahr9)](https://pan.baidu.com/s/1QhzW53vCbhkIzvrncRqJow?pwd=ahr9) |\n| GitHub Releases | [Download Link](https://github.com/aoguai/LiYing/releases/latest) |\n\n### Running\n\nView CIL help:\n```shell\ncd LiYing/src\npython main.py --help\n```\n\nFor Windows users, the project provides a batch script for convenience:\n\n```shell\n# Run BAT script\ncd LiYing\nrun.bat ./images/test1.jpg\n```\n\nRun WebUI:\n```shell\ncd LiYing/src/webui\npython app.py\n```\n\n### CLI Parameters and Help\n\n```shell\npython main.py --help\nUsage: main.py [OPTIONS] IMG_PATH\n\nOptions:\n  -y, --yolov8-model-path PATH    Path to YOLOv8 model\n  -u, --yunet-model-path PATH     Path to YuNet model\n  -r, --rmbg-model-path PATH      Path to RMBG model\n  -sz, --size-config PATH         Path to size configuration file\n  -cl, --color-config PATH        Path to color configuration file\n  -b, --rgb-list RGB_LIST         RGB channel values list (comma-separated)\n                                  for image composition\n  -s, --save-path PATH            Path to save the output image\n  -p, --photo-type TEXT           Photo types\n  -ps, --photo-sheet-size TEXT    Size of the photo sheet\n  -c, --compress / --no-compress  Whether to compress the image\n  -sv, --save-corrected / --no-save-corrected\n                                  Whether to save the corrected image\n  -bg, --change-background / --no-change-background\n                                  Whether to change the background\n  -sb, --save-background / --no-save-background\n                                  Whether to save the image with changed\n                                  background\n  -lo, --layout-only              Only layout the photo without changing\n                                  background\n  -sr, --sheet-rows INTEGER       Number of rows in the photo sheet\n  -sc, --sheet-cols INTEGER       Number of columns in the photo sheet\n  -rt, --rotate / --no-rotate     Whether to rotate the photo by 90 degrees\n  -rs, --resize / --no-resize     Whether to resize the image\n  -svr, --save-resized / --no-save-resized\n                                  Whether to save the resized image\n  -al, --add-crop-lines / --no-add-crop-lines\n                                  Add crop lines to the photo sheet\n  -ts, --target-size INTEGER      Target file size in KB. When specified,\n                                  ignores quality and size-range.\n  -szr, --size-range SIZE_RANGE   File size range in KB as min,max (e.g.,\n                                  10,20)\n  -uc, --use-csv-size / --no-use-csv-size\n                                  Whether to use file size limits from CSV\n  --help                          Show this message and exit.\n\n```\n\n### Configuration Files\n\nIn this version, the `data` directory contains standard ID photo configuration files (`size_XX.csv`) and commonly used color configurations (`color_XX.csv`). You can modify, add, or remove configurations based on the provided CSV template format.\n\n\u003cbr\u003e\n\n## Changelog\n\n**Note: This version includes changes to CIL parameters. Please carefully read the latest CIL help documentation to avoid issues.**\n\n- **2025/06/30 Update**\n  - Added `size_range` option, allowing users to input a min and max file size, attempting to maintain quality while keeping the file size within the range.\n  - Added `target_size` option to control the photo file size.\n  - Added support for RMBG-2.0 and higher iterations of yolov8 (requires Latest environment).\n  - Added automatic builds for CLI/BAT/WEBUI versions.\n  - Added model path configuration options.\n  - Fixed known bugs.\n\n\u003cdetails\u003e\n    \u003csummary\u003ePrevious Changelog\u003c/summary\u003e\n\n- **2025/02/07 Update**\n  - **Added WebUI**\n  - Optimized configuration method by replacing INI files with CSV\n  - Added CI/CD for automated builds and testing\n  - Added options for layout-only photos and whether to add crop lines on the photo grid\n  - Improved fallback handling for non-face images\n  - Fixed known bugs\n  - Added and refined more photo sizes\n\n- **2024/08/06 Update**\n  - Added support for entering width and height in pixels directly for `photo-type` and `photo-sheet-size`, and support for configuration via `data.ini`.\n  - Fixed issues related to some i18n configurations; now compatible with both English and Chinese settings.\n  - Fixed other known bugs.\n\u003c/details\u003e\n\n\u003cbr\u003e\n\n## Acknowledgments\n\nThe project was created to help my parents complete their work more easily. I would like to thank my parents for their support.\n\n### Related Projects\n\nSpecial thanks to the following projects and contributors for providing models and theories:\n\n- [Yunnet](https://github.com/ShiqiYu/libfacedetection)\n- [RMBG-1.4](https://huggingface.co/briaai/RMBG-1.4)\n- [ultralytics](https://github.com/ultralytics/ultralytics)\n\nYou might also be interested in the image compression part, which is another open-source project of mine:\n\n- [AGPicCompress](https://github.com/aoguai/AGPicCompress)\n\nIt depends on:\n\n- [mozjpeg](https://github.com/mozilla/mozjpeg)\n- [pngquant](https://github.com/kornelski/pngquant)\n- [mozjpeg-lossless-optimization](https://github.com/wanadev/mozjpeg-lossless-optimization)\n\n\u003cbr\u003e\n\n## Contribution\n\nLiYing is an open-source project, and community participation is highly welcomed. To contribute to this project, please follow the [Contribution Guide](./CONTRIBUTING.md).\n\n\u003cbr\u003e\n\n## License Notice\n\n[LiYing](https://github.com/aoguai/LiYing) is open-sourced under the AGPL-3.0 license. For details, please refer to the [LICENSE](../LICENSE) file.\n\n\u003cbr\u003e\n\n## Sponsors\n\nIf this project is helpful to you, feel free to give any appreciation, it helps me a lot, thank you for your support!\n\n```\nUSDT(TRON):TWFDp8aZMWZHPXjBodyhfPeK8LUyrWe9mi\n```\n\n\u003cimg src=\"../images/usdt_thanks.jpg\" width = \"300\" height = \"300\" alt=\"usdt_thanks\"/\u003e\n\n\u003cbr\u003e\n\n## Star History\n\n\u003ca href=\"https://star-history.com/#aoguai/LiYing\u0026Timeline\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/svg?repos=aoguai/subscription\u0026type=Timeline\u0026theme=dark\" /\u003e\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/svg?repos=aoguai/subscription\u0026type=Timeline\" /\u003e\n    \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/svg?repos=aoguai/subscription\u0026type=Timeline\" /\u003e\n  \u003c/picture\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faoguai%2FLiYing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faoguai%2FLiYing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faoguai%2FLiYing/lists"}