diff --git a/configs/face_detection/blazeface_nas.yml b/configs/face_detection/blazeface_nas.yml index 8f7b42170a966b8daf27362ea5123f43f4b61056..5e0f81b23600fc4f62a8edc61f899223417ab462 100644 --- a/configs/face_detection/blazeface_nas.yml +++ b/configs/face_detection/blazeface_nas.yml @@ -98,10 +98,6 @@ EvalReader: - !DecodeImage to_rgb: true - !NormalizeBox {} - - !ResizeImage - interp: 1 - target_size: 640 - use_cv2: false - !Permute {} - !NormalizeImage is_scale: false @@ -111,7 +107,6 @@ EvalReader: TestReader: inputs_def: - image_shape: [3,640,640] fields: ['image', 'im_id', 'im_shape'] dataset: !ImageFolder @@ -119,10 +114,6 @@ TestReader: sample_transforms: - !DecodeImage to_rgb: true - - !ResizeImage - interp: 1 - target_size: 640 - use_cv2: false - !Permute {} - !NormalizeImage is_scale: false diff --git a/configs/face_detection/blazeface_nas_v2.yml b/configs/face_detection/blazeface_nas_v2.yml index e1d6047525f68e493603104d4d439b6a4086db64..f13c6c37a6e9799734bae6891b672ebd134d69e5 100644 --- a/configs/face_detection/blazeface_nas_v2.yml +++ b/configs/face_detection/blazeface_nas_v2.yml @@ -7,7 +7,7 @@ log_smooth_window: 20 log_iter: 20 metric: WIDERFACE save_dir: output -weights: output/blazeface_nas/model_final +weights: output/blazeface_nas_v2/model_final # 1(label_class) + 1(background) num_classes: 2 @@ -98,10 +98,6 @@ EvalReader: - !DecodeImage to_rgb: true - !NormalizeBox {} - - !ResizeImage - interp: 1 - target_size: 640 - use_cv2: false - !Permute {} - !NormalizeImage is_scale: false @@ -111,7 +107,6 @@ EvalReader: TestReader: inputs_def: - image_shape: [3,640,640] fields: ['image', 'im_id', 'im_shape'] dataset: !ImageFolder @@ -119,10 +114,6 @@ TestReader: sample_transforms: - !DecodeImage to_rgb: true - - !ResizeImage - interp: 1 - target_size: 640 - use_cv2: false - !Permute {} - !NormalizeImage is_scale: false diff --git a/tools/face_eval.py b/tools/face_eval.py index a32eb6a57d78d9a93b5e098f67d580189f663c9e..fb6517d01c268858f8c72d3d94aca0ba1a9b1ce1 100644 --- a/tools/face_eval.py +++ b/tools/face_eval.py @@ -25,7 +25,7 @@ if parent_path not in sys.path: import paddle.fluid as fluid import numpy as np -from PIL import Image +import cv2 from collections import OrderedDict import ppdet.utils.checkpoint as checkpoint @@ -81,9 +81,10 @@ def face_eval_run(exe, if eval_mode == 'fddb': image_path += '.jpg' assert os.path.exists(image_path) - image = Image.open(image_path).convert('RGB') + image = cv2.imread(image_path) + image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) if multi_scale: - shrink, max_shrink = get_shrink(image.size[1], image.size[0]) + shrink, max_shrink = get_shrink(image.shape[0], image.shape[1]) det0 = detect_face(exe, compile_program, fetches, image, shrink) det1 = flip_test(exe, compile_program, fetches, image, shrink) [det2, det3] = multi_scale_test(exe, compile_program, fetches, @@ -106,10 +107,10 @@ def face_eval_run(exe, def detect_face(exe, compile_program, fetches, image, shrink): - image_shape = [3, image.size[1], image.size[0]] + image_shape = [3, image.shape[0], image.shape[1]] if shrink != 1: h, w = int(image_shape[1] * shrink), int(image_shape[2] * shrink) - image = image.resize((w, h), Image.ANTIALIAS) + image = cv2.resize(image, (w, h)) image_shape = [3, h, w] img = face_img_process(image) @@ -133,13 +134,13 @@ def detect_face(exe, compile_program, fetches, image, shrink): def flip_test(exe, compile_program, fetches, image, shrink): - img = image.transpose(Image.FLIP_LEFT_RIGHT) + img = cv2.flip(image, 1) det_f = detect_face(exe, compile_program, fetches, img, shrink) det_t = np.zeros(det_f.shape) - # image.size: [width, height] - det_t[:, 0] = image.size[0] - det_f[:, 2] + img_width = image.shape[1] + det_t[:, 0] = img_width - det_f[:, 2] det_t[:, 1] = det_f[:, 1] - det_t[:, 2] = image.size[0] - det_f[:, 0] + det_t[:, 2] = img_width - det_f[:, 0] det_t[:, 3] = det_f[:, 3] det_t[:, 4] = det_f[:, 4] return det_t