HivisionIDPhotos is a lightweight and efficient AI-driven ID photo maker that runs entirely offline on CPU for fast inpainting. It supports generating various standard ID photo sizes and six-inch layout prints, with features for resizing and custom background colors. Implemented in Python, it offers a clean web interface and API services for seamless operation. Released under the Apache-2.0 license, the project is actively maintained and has garnered 16.2k stars and 1.8k forks on GitHub. Compatible with Windows, Linux, and macOS, it’s ideal for emergency ID photo production without requiring a GPU.
Source code: https://github.com/Zeyi-Lin/HivisionIDPhotos
Environment installation and dependencies:
- Python >= 3.7 (the project is mainly tested on Python 3.10)
- OS: Linux, Windows, MacOS
git clone https://github.com/Zeyi-Lin/HivisionIDPhotos.gitcd HivisionIDPhotos
It is recommended that conda create a python3.10 virtual environment and execute the following command
pip install -r requirements.txt
pip install -r requirements-app.txt
Method 1: Script download
python scripts/download_model.py --models all
# 如需指定下载某个模型
# python scripts/download_model.py --models modnet_photographic_portrait_matting
Method 2: Direct download
The models are saved in the project hivision/creator/weights
directory:
Portrait Cutout Model | introduce | download |
---|---|---|
MODNet | MODNet Official Weight | Download (24.7MB) |
hivision_modnet | A cutout model that is more adaptable to solid color background changes | Download (24.7MB) |
rmbg-1.4 | BRIA AI open source cutout model | After downloading (176.2MB), rename it tormbg-1.4.onnx |
birefnet-v1-lite | ZhengPeng7 ‘s open source cutout model has the best segmentation accuracy | After downloading (224MB), rename it tobirefnet-v1-lite.onnx |
If the download speed is not smooth: Go to SwanHub to download.
Expanding the face detection model | introduce | Using the Documentation |
---|---|---|
MTCNN | Offline face detection model, high-performance CPU inference (millisecond level), the default model, low detection accuracy | Clone this project and use it directly |
RetinaFace | Offline face detection model, with medium CPU inference speed (seconds) and high accuracy | After downloading,hivision/creator/retinaface/weights put it in the directory |
Face++ | Megvii’s online face detection API has high detection accuracy. Official documentation | Using the Documentation |
The test environment is Mac M1 Max 64GB, non-GPU acceleration, and the test image resolution is 512×715(1) and 764×1146(2).
Model combination | Memory usage | Reasoning duration(1) | Reasoning time (2) |
---|---|---|---|
MODNet + mtcnn | 410MB | 0.207s | 0.246s |
MODNet + retinaface | 405MB | 0.571s | 0.971s |
birefnet-v1-lite + retinaface | 6.20GB | 7.063s | 7.128s |
In the current version, the models that can be accelerated by NVIDIA GPU are birefnet-v1-lite
, and please make sure you have about 16GB of video memory.
If you need to use NVIDIA GPU to accelerate inference, after ensuring that you have installed CUDA and cuDNN , find the corresponding version and install it according to the onnxruntime-gpu documentonnxruntime-gpu
, and find the corresponding version and install it according to the pytorch official websitetorch
.
# 假如你的电脑安装的是CUDA 12.x, cuDNN 8
# 安装torch是可选的,如果你始终配置不好cuDNN,那么试试安装torch
pip install onnxruntime-gpu==1.18.0
pip install torch --index-url https://download.pytorch.org/whl/cu121
After the installation is complete, birefnet-v1-lite
you can use GPU to accelerate reasoning by calling the model.
TIPS: CUDA supports backward compatibility. For example, if your CUDA version is 12.6,
torch
the highest version currently supported by the official is 12.4 (<12.6), andtorch
you can still use CUDA normally.
Libre Depot original article,Publisher:Libre Depot,Please indicate the source when reprinting:https://www.libredepot.top/5604.html