              action=Radio,
              type=str,
              choices=("blur", "blur-fft", "distance", "face", "face-cnn", "face-cnn-dissim",
                       "face-yaw", "hist", "hist-dissim", "color-gray", "color-luma", "color-green",
                       "color-orange", "size"),
              dest='sort_method',
              group=_("sort settings"),
              default="face",
              help=_("R|Sort by method. Choose how images are sorted. "
                     "\nL|'blur': Sort faces by blurriness."
 
</s> remove             choices=("blur", "blur-fft", "face-cnn", "face-yaw", "hist"),
 </s> add             choices=("blur", "blur-fft", "face-cnn", "face-yaw", "hist", "black-pixels"), </s> remove                    "sorted last.\nDefault: face")))
 </s> add                    "sorted last."
                   "\nL|'black-pixels': Sort images by their number of black pixels. Useful when "
                   "faces are near borders and a large part of the image is black."
                   "\nDefault: face"))) </s> remove             help=_("Integer value. Number of folders that will be used to group by blur and "
                   "face-yaw. For blur folder 0 will be the least blurry, while the last folder "
                   "will be the blurriest. For face-yaw the number of bins is by how much 180 "
                   "degrees is divided. So if you use 18, then each folder will be a 10 degree "
                   "increment. Folder 0 will contain faces looking the most to the left whereas "
                   "the last folder will contain the faces looking the most to the right. If the "
                   "number of images doesn't divide evenly into the number of bins, the remaining "
                   "images get put in the last bin. Default value: 5")))
 </s> add             help=_("Integer value. Number of folders that will be used to group by blur, "
                   "face-yaw and black-pixels. For blur folder 0 will be the least blurry, while "
                   "the last folder will be the blurriest. For face-yaw the number of bins is by "
                   "how much 180 degrees is divided. So if you use 18, then each folder will be "
                   "a 10 degree increment. Folder 0 will contain faces looking the most to the "
                   "left whereas the last folder will contain the faces looking the most to the "
                   "right. If the number of images doesn't divide evenly into the number of "
                   "bins, the remaining images get put in the last bin. For black-pixels it "
                   "represents the divider of the percentage of black pixels. For 10, first "
                   "folder will have the faces with 0 to 10% black pixels, second 11 to 20%, "
                   "etc. Default value: 5")))
                     "color-orange", "size", "black-pixels"),
              action=Radio,
              type=str,
              choices=("blur", "blur-fft", "distance", "face", "face-cnn", "face-cnn-dissim",
                       "face-yaw", "hist", "hist-dissim", "color-gray", "color-luma", "color-green",
                     "color-orange", "size", "black-pixels"),
              dest='sort_method',
              group=_("sort settings"),
              default="face",
              help=_("R|Sort by method. Choose how images are sorted. "
                     "\nL|'blur': Sort faces by blurriness."
keep keep keep keep replace keep keep keep keep keep
 Add a new sorting/grouping feature based on black pixels in images (#1169)

* Add a new sorting/grouping feature based on the percentage of black pixels in images

Context:
- Faces are quite often moving and can get near borders of the image.
- Because of that, the face image has the out of bound part replaced by black pixels.
- Some are still good for training but others not. Also, one might want to keep an alignment file with the near borders faces but excluded (some of) them for training.
- Having to manually move/delete those images in a dataset of thousands of them is painful and prone to mistakes.
- Thus, having a way to sort and group those images would be helpful. At least, it is for me :-)

Added features:
- A new option in Tools/Sort for both Sort and Group By called Black-Pixels.
- Sort feature: calculates the percentage of black pixels in each images and sort them from 0 to 100%.
- Group By feature: Uses the Bins slider number selected and creates 100/Bins folders with the images percentage of black pixels. ie. a Bins of 5 will create 20 folders with the first one containing images with 0-5% of black pixels, the second one with 6-10%, etc. A static method as been added for the rounding error.

* PEP8 fixes

Co-authored-by: Olivier Gagnon <ogagnon@ludia.com> 
tools/sort/cli.py