diff --git a/fluid/object_detection/train.py b/fluid/object_detection/train.py index 2aa0779c202330add779c5b41bb094f961a03952..7552c92124c0fac44f34b647f358d7e0acf3b643 100644 --- a/fluid/object_detection/train.py +++ b/fluid/object_detection/train.py @@ -92,24 +92,25 @@ def build_program(main_prog, startup_prog, train_params, is_train): image, gt_box, gt_label, difficult = fluid.layers.read_file(py_reader) locs, confs, box, box_var = mobile_net(class_num, image, image_shape) if is_train: - loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box, - box_var) - loss = fluid.layers.reduce_sum(loss) - optimizer = optimizer_setting(train_params) - optimizer.minimize(loss) + with fluid.unique_name.guard("train"): + loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box, + box_var) + loss = fluid.layers.reduce_sum(loss) + optimizer = optimizer_setting(train_params) + optimizer.minimize(loss) else: - - nmsed_out = fluid.layers.detection_output( - locs, confs, box, box_var, nms_threshold=0.45) - loss = fluid.evaluator.DetectionMAP( - nmsed_out, - gt_label, - gt_box, - difficult, - class_num, - overlap_threshold=0.5, - evaluate_difficult=False, - ap_version=ap_version) + with fluid.unique_name.guard("inference"): + nmsed_out = fluid.layers.detection_output( + locs, confs, box, box_var, nms_threshold=0.45) + 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