Stripped down functionality from Face Crop Plus using AMD's RetinaFace ONNX with no PyTorch dependancy, a 1.7 MB model artifact and a single file of code for inference.
What I need: square image of one face from image of one face that is not square.
What I don't need: 7GB venv with CUDA PyTorch dependencies.
Detects bbox of a face (one face) in the picture (using RetinaFace and ONNX for inference) then crops a square around it with the face being in the center (cv2 slicing).
Local
uv venv
uv pip install -r requirements.txt
. .venv/bin/activateDocker (API)
Build
docker build -t cropper .
docker run -d -p 8080:8080 cropper:latestPull
docker pull ghcr.io/a-tabaza/center_crop:main
docker run -d -p 8080:8080 ghcr.io/a-tabaza/center_crop:mainGo to localhost:8080/docs for SwaggerUI
CLI
python src/crop.py -i input.jpg -o output.jpgAPI
Multiple images (result in .zip file)
curl -X 'POST' \
'http://localhost:8080/crop/' \
-H 'accept: image/jpeg' \
-H 'Content-Type: multipart/form-data' \
-F 'files=@4.jpg;type=image/jpeg' \
-F 'files=@3.jpeg;type=image/jpeg' \
-F 'files=@2.jpg;type=image/jpeg' \
-F 'files=@1.jpg;type=image/jpeg'One image (result back as jpg)
curl -X 'POST' \
'http://localhost:8080/crop/' \
-H 'accept: image/jpeg' \
-H 'Content-Type: multipart/form-data' \
-F 'files=@1.jpg;type=image/jpeg' \No. This isn't for you, it's to save my time, if it helps, I'm glad, if it doesn't, fork and adapt it.







