added sort by one face in images. it trashes all images in which more than 1 face is found

This commit is contained in:
iperov 2019-02-22 11:32:27 +04:00
commit 5e474c3462
4 changed files with 23 additions and 6 deletions

View file

@ -1,6 +1,6 @@
### **Features**:
- works on AMD, NVIDIA, IntelHD graphics and all OpenCL1.2-compatible videocards with at least 512M video memory
- works on AMD, NVIDIA, IntelHD graphics and all OpenCL1.2-compatible videocards with at least 256M video memory. Of course, the more memory available, the better quality you will get.
- CPU-only mode [`--cpu-mode`]. 8th gen Intel core CPU able to train H64 model in 2 days.

View file

@ -61,7 +61,7 @@ if __name__ == "__main__":
sort_parser = subparsers.add_parser( "sort", help="Sort faces in a directory.")
sort_parser.add_argument('--input-dir', required=True, action=fixPathAction, dest="input_dir", help="Input directory. A directory containing the files you wish to process.")
sort_parser.add_argument('--by', required=True, dest="sort_by_method", choices=("blur", "face", "face-dissim", "face-yaw", "face-pitch", "hist", "hist-dissim", "brightness", "hue", "black", "origname", "final", "test"), help="Method of sorting. 'origname' sort by original filename to recover original sequence." )
sort_parser.add_argument('--by', required=True, dest="sort_by_method", choices=("blur", "face", "face-dissim", "face-yaw", "face-pitch", "hist", "hist-dissim", "brightness", "hue", "black", "origname", "oneface", "final", "test"), help="Method of sorting. 'origname' sort by original filename to recover original sequence." )
sort_parser.set_defaults (func=process_sort)
def process_util(arguments):

View file

@ -747,6 +747,21 @@ def sort_by_origname(input_path):
img_list = sorted(img_list, key=operator.itemgetter(1))
return img_list
def sort_by_oneface_in_image(input_path):
print ("Sort by one face in images...")
image_paths = Path_utils.get_image_paths(input_path)
a = [ Path(filepath).stem.split('_') for filepath in image_paths ]
a = np.array ( [ ( int(x[0]), int(x[1]) ) for x in a ] )
idxs = np.ndarray.flatten ( np.argwhere ( a[:,1] != 0 ) )
idxs = np.unique ( a[idxs][:,0] )
idxs = np.ndarray.flatten ( np.argwhere ( np.array([ x[0] in idxs for x in a ]) == True ) )
img_list = [ (i,) for j,i in enumerate(image_paths) if j not in idxs ]
trash_img_list = [ (image_paths[x],) for x in idxs ]
return img_list, trash_img_list
def main (input_path, sort_by_method):
input_path = Path(input_path)
sort_by_method = sort_by_method.lower()
@ -766,6 +781,7 @@ def main (input_path, sort_by_method):
elif sort_by_method == 'hue': img_list = sort_by_hue (input_path)
elif sort_by_method == 'black': img_list = sort_by_black (input_path)
elif sort_by_method == 'origname': img_list = sort_by_origname (input_path)
elif sort_by_method == 'final': img_list, trash_img_list = sort_final (input_path)
elif sort_by_method == 'oneface': img_list, trash_img_list = sort_by_oneface_in_image (input_path)
elif sort_by_method == 'final': img_list, trash_img_list = sort_final (input_path)
final_process (input_path, img_list, trash_img_list)

View file

@ -71,3 +71,4 @@ def add_landmarks_debug_images(input_path):
output_file = '{}{}'.format( str(Path(str(input_path)) / filepath.stem), '_debug.jpg')
cv2_imwrite(output_file, img, [int(cv2.IMWRITE_JPEG_QUALITY), 50] )