def test_net(root_path, dataset_path, prefix, epoch, batch_size, ctx, test_mode="onet", thresh=[0.6, 0.6, 0.7], min_face_size=24, stride=2, slide_window=False, shuffle=False, vis=False): detectors = [None, None, None] # load pnet model args, auxs = load_param(prefix[0], epoch[0], convert=False, ctx=ctx) if slide_window: PNet = Detector(P_Net("test"), 12, batch_size[0], ctx, args, auxs) else: PNet = FcnDetector(P_Net("test"), ctx, args, auxs) detectors[0] = PNet # load rnet model if test_mode in ["rnet", "onet"]: args, auxs = load_param(prefix[1], epoch[0], convert=False, ctx=ctx) RNet = Detector(R_Net("test"), 24, batch_size[1], ctx, args, auxs) detectors[1] = RNet # load onet model if test_mode == "onet": args, auxs = load_param(prefix[2], epoch[2], convert=False, ctx=ctx) ONet = Detector(O_Net("test"), 48, batch_size[2], ctx, args, auxs) detectors[2] = ONet mtcnn_detector = MtcnnDetector(detectors=detectors, ctx=ctx, min_face_size=min_face_size, stride=stride, threshold=thresh, slide_window=slide_window) for i in range(1, 11): image_set = "fold-" + str(i).zfill(2) imdb = IMDB("fddb", image_set, root_path, dataset_path, 'test') gt_imdb = imdb.gt_imdb() test_data = TestLoader(gt_imdb) all_boxes = mtcnn_detector.detect_face(imdb, test_data, vis=vis) imdb.write_results(all_boxes)
def test_net(root_path, dataset_path, prefix, epoch, batch_size, test_mode="onet", thresh=[0.6, 0.6, 0.7], min_face_size=24, stride=2, slide_window=False, shuffle=False, vis=False): detectors = [None, None, None] model_path = ['%s-%s' % (x, y) for x, y in zip(prefix, epoch)] # load pnet model if slide_window: PNet = Detector(P_Net, 12, batch_size[0], model_path[0]) else: PNet = FcnDetector(P_Net, model_path[0]) detectors[0] = PNet # load rnet model if test_mode in ["rnet", "onet"]: RNet = Detector(R_Net, 24, batch_size[1], model_path[1]) detectors[1] = RNet # load onet model if test_mode == "onet": ONet = Detector(O_Net, 48, batch_size[2], model_path[2]) detectors[2] = ONet mtcnn_detector = MtcnnDetector(detectors=detectors, min_face_size=min_face_size, stride=stride, threshold=thresh, slide_window=slide_window) for i in range(1, 11): image_set = "fold-" + str(i).zfill(2) imdb = IMDB("fddb", image_set, root_path, dataset_path, 'test') gt_imdb = imdb.gt_imdb() test_data = TestLoader(gt_imdb) all_boxes = mtcnn_detector.detect_face(imdb, test_data, vis=vis) imdb.write_results(all_boxes)
def test_net(root_path, dataset_path, prefix, epoch, batch_size, ctx, test_mode="onet", thresh=[0.6, 0.6, 0.7], min_face_size=24, stride=2, slide_window=False, shuffle=False, vis=False): detectors = [None, None, None] # load pnet model args, auxs = load_param(prefix[0], epoch[0], convert=True, ctx=ctx) if slide_window: PNet = Detector(P_Net("test"), 12, batch_size[0], ctx, args, auxs) else: PNet = FcnDetector(P_Net("test"), ctx, args, auxs) detectors[0] = PNet # load rnet model if test_mode in ["rnet", "onet"]: args, auxs = load_param(prefix[1], epoch[0], convert=True, ctx=ctx) RNet = Detector(R_Net("test"), 24, batch_size[1], ctx, args, auxs) detectors[1] = RNet # load onet model if test_mode == "onet": args, auxs = load_param(prefix[2], epoch[2], convert=True, ctx=ctx) ONet = Detector(O_Net("test"), 48, batch_size[2], ctx, args, auxs) detectors[2] = ONet mtcnn_detector = MtcnnDetector(detectors=detectors, ctx=ctx, min_face_size=min_face_size, stride=stride, threshold=thresh, slide_window=slide_window) for i in range(1,11): image_set = "fold-" + str(i).zfill(2) imdb = IMDB("fddb", image_set, root_path, dataset_path, 'test') gt_imdb = imdb.gt_imdb() test_data = TestLoader(gt_imdb) all_boxes = mtcnn_detector.detect_face(imdb, test_data, vis=vis) imdb.write_results(all_boxes)