mantasu / face-crop-plus

Face aligner and cropper with quality enhancement and attribute parsing
https://mantasu.github.io/face-crop-plus/
MIT License
53 stars 6 forks source link

Not an issue but maybe some enhancements? #2

Closed pinballelectronica closed 1 year ago

pinballelectronica commented 1 year ago

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:0@31.943] 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.

mantasu commented 1 year ago

Hiya, thanks for pointing those out. It is for sure a good feature request; I need to update it either way.

However, I cannot really implement anything that changes the input directory (cuz it's the best practice). The first point would involve preprocessing the file names. The second point would change the input directory to contain more files.

But it is also a bug because the processing should not stop if invalid filenames are detected, at the very least they should be skipped. I will note that down, thanks!

I could create a utility function that would create renamed file copies (with names working cross-platform and appending counters to the end of the names in case there were duplicates after renaming), or would rename in place. The output directory can be changed to be a subdirectory of the input directory with --output-dir option.

mantasu commented 1 year ago

Added to #3