From 2a2b7f4cab83399f6de8d86b2d757ff544b61d21 Mon Sep 17 00:00:00 2001 From: dangqingqing Date: Tue, 27 Mar 2018 11:29:50 +0800 Subject: [PATCH] Refine train.py for MobileNet-SSD. --- fluid/object_detection/image_util.py | 2 +- fluid/object_detection/train.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fluid/object_detection/image_util.py b/fluid/object_detection/image_util.py index 78193229..e538449a 100644 --- a/fluid/object_detection/image_util.py +++ b/fluid/object_detection/image_util.py @@ -216,7 +216,7 @@ def distort_image(img, settings): def expand_image(img, bbox_labels, img_width, img_height, settings): prob = random.uniform(0, 1) - if prob < settings._hue_prob: + if prob < settings._expand_prob: expand_ratio = random.uniform(1, settings._expand_max_ratio) if expand_ratio - 1 >= 0.01: height = int(img_height * expand_ratio) diff --git a/fluid/object_detection/train.py b/fluid/object_detection/train.py index e1a4d755..a6c8e9e2 100644 --- a/fluid/object_detection/train.py +++ b/fluid/object_detection/train.py @@ -50,11 +50,12 @@ def train(args, box, box_var) nmsed_out = fluid.layers.detection_output( locs, confs, box, box_var, nms_threshold=0.45) + loss = fluid.layers.reduce_sum(loss) pd.write_output(loss) pd.write_output(nmsed_out) loss, nmsed_out = pd() - loss = fluid.layers.reduce_sum(loss) + loss = fluid.layers.mean(loss) else: locs, confs, box, box_var = mobile_net(image, image_shape) nmsed_out = fluid.layers.detection_output( -- GitLab