Add If-Else-Return of Yolov3 as Unittest (#25385)

As the title
fix_copy_if_different
Huihuang Zheng 5 years ago committed by GitHub
parent 80f1c50738
commit 30185efdae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -314,21 +314,19 @@ class YOLOv3(fluid.dygraph.Layer):
scores, perm=[0, 2, 1]))
self.downsample //= 2
# TODO(liym27): Uncomment code after "return" statement can be transformed correctly.
# if not self.is_train:
# # get pred
# yolo_boxes = fluid.layers.concat(self.boxes, axis=1)
# yolo_scores = fluid.layers.concat(self.scores, axis=2)
#
# pred = fluid.layers.multiclass_nms(
# bboxes=yolo_boxes,
# scores=yolo_scores,
# score_threshold=cfg.valid_thresh,
# nms_top_k=cfg.nms_topk,
# keep_top_k=cfg.nms_posk,
# nms_threshold=cfg.nms_thresh,
# background_label=-1)
# return pred
# else:
# return sum(self.losses)
return sum(self.losses)
if not self.is_train:
# get pred
yolo_boxes = fluid.layers.concat(self.boxes, axis=1)
yolo_scores = fluid.layers.concat(self.scores, axis=2)
pred = fluid.layers.multiclass_nms(
bboxes=yolo_boxes,
scores=yolo_scores,
score_threshold=cfg.valid_thresh,
nms_top_k=cfg.nms_topk,
keep_top_k=cfg.nms_posk,
nms_threshold=cfg.nms_thresh,
background_label=-1)
return pred
else:
return sum(self.losses)

Loading…
Cancel
Save