Welcome to the face cropper module !
This module will :
- Automatically detect faces on a provided picture
- Return the biggest one
- Save it in a location of your choosing !
- Python > 3.7
- pip > 20.1.1
pip install face-cropper
- Clone the repo
pip install -r requirements.txt
python main.py --image_path=path\to\my\image --saving_path=where\to\save\cropped\image
Just run the main.py module
- image_path : The path of the image to be cropped
- saving_path : The path where the cropped image should be saved
- verbose : Wether or not the command should output informations about the face detections
Simply import the crop function, and pass it the path of the image to be
cropped as image_path !
It is also possible to pass it another parameter, saving_path, which if
provided will make face_croper save the image in the provided location !
import os
from face_cropper import crop
cropped_image = crop(
image_path=os.path.join(os.getcwd(), "my_image.jpg")
)
import os
from face_cropper import crop
cropped_image = crop(
image_path=os.path.join(os.getcwd(), "my_image.jpg"),
saving_path=os.getcwd()
)
import os
from face_cropper import crop
from face_cropper.exceptions import NoFaceException, AboveThresholdException
try:
cropped_image = crop(
image_path=os.path.join(os.getcwd(), "my_image.jpg")
)
except (NoFaceException, AboveThresholdException):
# Custom code right here