未验证 提交 8bb5f593 编写于 作者: X Xin Pan 提交者: GitHub

Merge pull request #1363 from panyx0718/pick_fix

fix model to use different names for train and test so that var name …
...@@ -88,25 +88,27 @@ def build_program(main_prog, startup_prog, train_params, is_train): ...@@ -88,25 +88,27 @@ def build_program(main_prog, startup_prog, train_params, is_train):
image, gt_box, gt_label, difficult = fluid.layers.read_file(py_reader) image, gt_box, gt_label, difficult = fluid.layers.read_file(py_reader)
locs, confs, box, box_var = mobile_net(class_num, image, image_shape) locs, confs, box, box_var = mobile_net(class_num, image, image_shape)
if is_train: if is_train:
loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box, with fluid.unique_name.guard("train"):
box_var) loss = fluid.layers.ssd_loss(locs, confs, gt_box, gt_label, box,
loss = fluid.layers.reduce_sum(loss) box_var)
optimizer = optimizer_setting(train_params) loss = fluid.layers.reduce_sum(loss)
optimizer.minimize(loss) optimizer = optimizer_setting(train_params)
optimizer.minimize(loss)
else: else:
nmsed_out = fluid.layers.detection_output( with fluid.unique_name.guard("inference"):
locs, confs, box, box_var, nms_threshold=0.45) nmsed_out = fluid.layers.detection_output(
with fluid.program_guard(main_prog): locs, confs, box, box_var, nms_threshold=0.45)
loss = fluid.evaluator.DetectionMAP( with fluid.program_guard(main_prog):
nmsed_out, loss = fluid.evaluator.DetectionMAP(
gt_label, nmsed_out,
gt_box, gt_label,
difficult, gt_box,
class_num, difficult,
overlap_threshold=0.5, class_num,
evaluate_difficult=False, overlap_threshold=0.5,
ap_version=args.ap_version) evaluate_difficult=False,
ap_version=args.ap_version)
return py_reader, loss return py_reader, loss
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册