Skip to content

malcolmamal/face-cropper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MalcolmRey's Face Cropper

0. Prerequisites

Python, most likely any 3.x would do, but I'm currently running it on 3.10.8

1. Installation

for Windows

python -m venv venv
venv\Scripts\activate.bat
pip install -r requirements.txt

for Linux

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

2. Running

python main.py --resolution=RESOLUTION --source-path=SOURCE_PATH --target-path=TARGET_PATH
  • RESOLUTION is the cropping resolution (usually one of the following: 512, 768, 1024) at the moment only square resolution is supported, default is 512
  • SOURCE_PATH is the path where the original images are fetched from, you should have subfolder for each person for example:
    SOURCE_PATH
      ritaora
      billieeilish
      henrycavill
      someoneelse
    there should be at least one subfolder for the script to do something, but if there are more, all will be cropped
  • TARGET_PATH is the path where the outputs will be saved
    TARGET_PATH
      cropped
        ritaora
        billieeilish
        henrycavill
        someoneelse
    You only need to make sure that the TARGET_PATH exists, other subfolders will be created automatically

Troubleshooting

  • If the script is running slow, check if the DLIB library is using CUDA:
    python main.py --check-dlib
    If the result is false then you have to compile the DLIB library for CUDA: https://www.linkedin.com/pulse/installing-dlib-cuda-support-windows-10-chitransh-mundra
  • If you get some errors -> please report them to me, I will try to do my best to help with them / improve the code
  • Tested with jpg, png and webp formats but most likely others should work too
  • For best experience, try using images with only one person in the photo, there is however some code to recognize which person is our target but this code is WIP still
  • Currently only square resolutions are available (this is why you only provide one value)
  • If you want to crop to higher res (768 or 1024) then smaller images will get upscaled
  • There is no up-scaling for 512 images though
  • Technically you can crop to any resolution, but I have not tested other resolutions besides the 3 supported ones
  • If something is wrong with an image and I recognize it (wrong format, too big, etc.) I will skip it and proceed to the next, you can check the output for skipped files if you are interested in the files that were problematic

External links

Dlib Installation

Face Recognition

MalcolmRey's links

About

Face cropper for datasets

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published