diff --git a/fluid/face_detection/pyramidbox.py b/fluid/face_detection/pyramidbox.py index 4012d77cb7b99c36793807f173e38062f1b846ad..bece77af4247075a9bcd2e5ba5915e8446018e27 100644 --- a/fluid/face_detection/pyramidbox.py +++ b/fluid/face_detection/pyramidbox.py @@ -427,6 +427,7 @@ class PyramidBox(object): overlap_threshold=0.35, neg_overlap=0.35) loss = fluid.layers.reduce_sum(loss) + loss.persistable = True return loss def train(self): diff --git a/fluid/face_detection/train.py b/fluid/face_detection/train.py index 13744562c9d1814d457af20e3185d2d3c7a22fb7..f083f1ffbc05b3ac384c1df10d5176b93cb4be8c 100644 --- a/fluid/face_detection/train.py +++ b/fluid/face_detection/train.py @@ -189,13 +189,13 @@ def train(args, config, train_params, train_file_list): fetch_vars = [np.mean(np.array(v)) for v in fetch_vars] if batch_id % 10 == 0: if not args.use_pyramidbox: - print("Pass {0}, batch {1}, loss {2}, time {3}".format( + print("Pass {:d}, batch {:d}, loss {:.6f}, time {:.5f}".format( pass_id, batch_id, fetch_vars[0], start_time - prev_start_time)) else: - print("Pass {0}, batch {1}, face loss {2}, " \ - "head loss {3}, " \ - "time {4}".format(pass_id, + print("Pass {:d}, batch {:d}, face loss {:.6f}, " \ + "head loss {:.6f}, " \ + "time {:.5f}".format(pass_id, batch_id, fetch_vars[0], fetch_vars[1], start_time - prev_start_time)) if pass_id % 1 == 0 or pass_id == epoc_num - 1: diff --git a/fluid/face_detection/widerface_eval.py b/fluid/face_detection/widerface_eval.py index 2a1addd1ed3313f8bb472bde2dad7fe90dd1c591..dd3a1c059ab1a6d3ed28a2cc48fdd377ed980fad 100644 --- a/fluid/face_detection/widerface_eval.py +++ b/fluid/face_detection/widerface_eval.py @@ -82,9 +82,6 @@ def save_widerface_bboxes(image_path, bboxes_scores, output_dir): image_name = image_path.split('/')[-1] image_class = image_path.split('/')[-2] - image_name = image_name.encode('utf-8') - image_class = image_class.encode('utf-8') - odir = os.path.join(output_dir, image_class) if not os.path.exists(odir): os.makedirs(odir) diff --git a/fluid/object_detection/train.py b/fluid/object_detection/train.py index 6e763ea1d4ae1a2579238aa4388bc6425b1400f7..2aa0779c202330add779c5b41bb094f961a03952 100644 --- a/fluid/object_detection/train.py +++ b/fluid/object_detection/train.py @@ -38,7 +38,8 @@ train_parameters = { "batch_size": 64, "lr": 0.001, "lr_epochs": [40, 60, 80, 100], - "lr_decay": [1, 0.5, 0.25, 0.1, 0.01] + "lr_decay": [1, 0.5, 0.25, 0.1, 0.01], + "ap_version": '11point', }, "coco2014": { "train_images": 82783, @@ -47,7 +48,8 @@ train_parameters = { "batch_size": 64, "lr": 0.001, "lr_epochs": [12, 19], - "lr_decay": [1, 0.5, 0.25] + "lr_decay": [1, 0.5, 0.25], + "ap_version": 'integral', # should use eval_coco_map.py to test model }, "coco2017": { "train_images": 118287, @@ -56,7 +58,8 @@ train_parameters = { "batch_size": 64, "lr": 0.001, "lr_epochs": [12, 19], - "lr_decay": [1, 0.5, 0.25] + "lr_decay": [1, 0.5, 0.25], + "ap_version": 'integral', # should use eval_coco_map.py to test model } } @@ -77,6 +80,7 @@ def optimizer_setting(train_params): def build_program(main_prog, startup_prog, train_params, is_train): image_shape = train_params['image_shape'] class_num = train_params['class_num'] + ap_version = train_params['ap_version'] with fluid.program_guard(main_prog, startup_prog): py_reader = fluid.layers.py_reader( capacity=64, @@ -97,16 +101,15 @@ def build_program(main_prog, startup_prog, train_params, is_train): nmsed_out = fluid.layers.detection_output( locs, confs, box, box_var, nms_threshold=0.45) - with fluid.program_guard(main_prog): - loss = fluid.evaluator.DetectionMAP( - nmsed_out, - gt_label, - gt_box, - difficult, - class_num, - overlap_threshold=0.5, - evaluate_difficult=False, - ap_version=args.ap_version) + loss = fluid.evaluator.DetectionMAP( + nmsed_out, + gt_label, + gt_box, + difficult, + class_num, + overlap_threshold=0.5, + evaluate_difficult=False, + ap_version=ap_version) return py_reader, loss @@ -230,7 +233,7 @@ def train(args, loss_v = np.mean(np.array(loss_v)) every_epoc_loss.append(loss_v) if batch_id % 20 == 0: - print("Epoc {0}, batch {1}, loss {2}, time {3}".format( + print("Epoc {:d}, batch {:d}, loss {:.6f}, time {:.5f}".format( epoc_id, batch_id, loss_v, start_time - prev_start_time)) end_time = time.time() total_time += end_time - start_time