mantasu / face-crop-plus Goto Github PK
View Code? Open in Web Editor NEWFace aligner and cropper with quality enhancement and attribute parsing
Home Page: https://mantasu.github.io/face-crop-plus/
License: MIT License
Face aligner and cropper with quality enhancement and attribute parsing
Home Page: https://mantasu.github.io/face-crop-plus/
License: MIT License
could you please, add the link to the pertained model for predicting facial attributes?
If the script encounters a non-image file it fails with the following warning:
Processing: 50% 1/2 [00:03<00:03, 3.72s/it]/usr/local/lib/python3.10/dist-packages/face_crop_plus/utils.py:264: UserWarning: Could not read the image input/.ipynb_checkpoints
warnings.warn(f"Could not read the image {path}")
Processing: 50% 1/2 [00:03<00:03, 3.72s/it]
Traceback (most recent call last):
File "/usr/local/bin/face-crop-plus", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/__main__.py", line 278, in main
cropper.process_dir(input_dir, output_dir)
File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/cropper.py", line 909, in process_dir
list(imap)
File "/usr/local/lib/python3.10/dist-packages/tqdm/std.py", line 1182, in __iter__
for obj in iterable:
File "/usr/lib/python3.10/multiprocessing/pool.py", line 873, in next
raise value
File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
result = (True, func(*args, **kwds))
File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/cropper.py", line 817, in process_batch
images, _, paddings = as_batch(images, self.resize_size)
File "/usr/local/lib/python3.10/dist-packages/face_crop_plus/utils.py", line 342, in as_batch
return np.stack(img_batch), np.stack(unscales), np.stack(paddings)
File "<__array_function__ internals>", line 180, in stack
File "/usr/local/lib/python3.10/dist-packages/numpy/core/shape_base.py", line 422, in stack
raise ValueError('need at least one array to stack')
ValueError: need at least one array to stack
First time I saw it i thought no image in the input folder was cropped.
EDIT: I know one should put images in the input folder but sometimes some hidden files are created as it happens when running script from a Google's Colab (as seen in example above).
Some ideas for new features:
For example: make it more convenient to process datasets where all the files are inside a single folder: Face Synthetics
Just a general to-do list and notes for the future update from v1.0.3.
paddings
is tried to be accessed when landmarks are provided, i.e., missing initialization of paddings = None
STANDARD_LANDMARKS_5
is modified in _init_landmarks_target
padding
to constant
(to avoid heads coming out of heads)enh_threshold
to None
(to avoid unnecessary wasting time on enhancement)process_dir
It would be nice to have a way to turn off the face aligment to avoid using padding. Especially good for training models where the position of the face/body is not important.
image = cv2.cvtColor(cv2.imread(path), cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
cli argument: (windows)
face-crop-plus -i I:\AI\imgtmp_1024x768\sharpened\AI\1024_1024x768 --output-size 512 512 -d cuda:0 -b 5 --face-factor 0.75 -o I:\AI\imgtmp_1024x768\sharpened\AI\1024_1024x768\faces
4090 cuda 12.1
Wondering if it broke on a 0 byte file it tried to parse or a broken image?
I've run this in WSL2 and Windows proper and I'm not even sure if this is supposed to run on either so this is just a thought. Here i'm talking about Windows 10 proper:
The _faces dir won't write if the input dir has specific garbage characters that came in with the filename. e.g. "―". I have quoted directories in Windows to no avail. e.g.
F:\face-crop-plus>face-crop-plus -i "M:_____Digital\junk 0602" -s 1024 -ff 0.25 -d cuda:0 --det-threshold 0.99 --padding constant
This above will not generate any output or will crash, depending on the character in the filename.
Here's the output of processing a directory that above character in the filename- it will bomb after finding these:
Processing: 45%|███████████████████████████████▌ | 14/31 [00:28<00:35, 2.07s/it][ WARN:[email protected]] global loadsave.cpp:244 cv::findDecoder imread_('C:\Users\ML-scrapes\Downloads\Faces-web\Faces _ΓÇò_752DB5E.jpg'): can't open/read file: check file path/integrity
I know it's probably about escaping certain chars from linux to windows, almost certainly. Also any sort of garbage filenames in Windows will break it. I could easily run dos2unix on the filenames in the pipeline, just wanted to point out that behavior.
Also- may I recommend the default directory being a sub directory of the input dir instead of at the top? Am I being too picky yet? :)
Again- not complaining- just really find this an incredibly useful tool for my ML work.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.