Skip to content

Commit 68b9332

Browse files
authored
Merge pull request #16882 from heavengate/fix_yolo_param_pick
[cherry-pick] fix yolo param
2 parents 1237dfa + b556072 commit 68b9332

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

paddle/fluid/API.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ paddle.fluid.layers.generate_mask_labels (ArgSpec(args=['im_info', 'gt_classes',
347347
paddle.fluid.layers.iou_similarity (ArgSpec(args=['x', 'y', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '587845f60c5d97ffdf2dfd21da52eca1'))
348348
paddle.fluid.layers.box_coder (ArgSpec(args=['prior_box', 'prior_box_var', 'target_box', 'code_type', 'box_normalized', 'name', 'axis'], varargs=None, keywords=None, defaults=('encode_center_size', True, None, 0)), ('document', '032d0f4b7d8f6235ee5d91e473344f0e'))
349349
paddle.fluid.layers.polygon_box_transform (ArgSpec(args=['input', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '0e5ac2507723a0b5adec473f9556799b'))
350-
paddle.fluid.layers.yolov3_loss (ArgSpec(args=['x', 'gtbox', 'gtlabel', 'anchors', 'anchor_mask', 'class_num', 'ignore_thresh', 'downsample_ratio', 'gtscore', 'use_label_smooth', 'name'], varargs=None, keywords=None, defaults=(None, True, None)), ('document', '57fa96922e42db8f064c3fb77f2255e8'))
350+
paddle.fluid.layers.yolov3_loss (ArgSpec(args=['x', 'gt_box', 'gt_label', 'anchors', 'anchor_mask', 'class_num', 'ignore_thresh', 'downsample_ratio', 'gt_score', 'use_label_smooth', 'name'], varargs=None, keywords=None, defaults=(None, True, None)), ('document', '059021025283ad1ee6f4d32228cf3e4e'))
351351
paddle.fluid.layers.yolo_box (ArgSpec(args=['x', 'img_size', 'anchors', 'class_num', 'conf_thresh', 'downsample_ratio', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '5566169a5ab993d177792c023c7fb340'))
352352
paddle.fluid.layers.box_clip (ArgSpec(args=['input', 'im_info', 'name'], varargs=None, keywords=None, defaults=(None,)), ('document', '397e9e02b451d99c56e20f268fa03f2e'))
353353
paddle.fluid.layers.multiclass_nms (ArgSpec(args=['bboxes', 'scores', 'score_threshold', 'nms_top_k', 'keep_top_k', 'nms_threshold', 'normalized', 'nms_eta', 'background_label', 'name'], varargs=None, keywords=None, defaults=(0.3, True, 1.0, 0, None)), ('document', 'ca7d1107b6c5d2d6d8221039a220fde0'))

python/paddle/fluid/layers/detection.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -509,35 +509,35 @@ def polygon_box_transform(input, name=None):
509509

510510
@templatedoc(op_type="yolov3_loss")
511511
def yolov3_loss(x,
512-
gtbox,
513-
gtlabel,
512+
gt_box,
513+
gt_label,
514514
anchors,
515515
anchor_mask,
516516
class_num,
517517
ignore_thresh,
518518
downsample_ratio,
519-
gtscore=None,
519+
gt_score=None,
520520
use_label_smooth=True,
521521
name=None):
522522
"""
523523
${comment}
524524
525525
Args:
526526
x (Variable): ${x_comment}
527-
gtbox (Variable): groud truth boxes, should be in shape of [N, B, 4],
527+
gt_box (Variable): groud truth boxes, should be in shape of [N, B, 4],
528528
in the third dimenstion, x, y, w, h should be stored
529529
and x, y, w, h should be relative value of input image.
530530
N is the batch number and B is the max box number in
531531
an image.
532-
gtlabel (Variable): class id of ground truth boxes, shoud be in shape
532+
gt_label (Variable): class id of ground truth boxes, shoud be in shape
533533
of [N, B].
534534
anchors (list|tuple): ${anchors_comment}
535535
anchor_mask (list|tuple): ${anchor_mask_comment}
536536
class_num (int): ${class_num_comment}
537537
ignore_thresh (float): ${ignore_thresh_comment}
538538
downsample_ratio (int): ${downsample_ratio_comment}
539539
name (string): the name of yolov3 loss. Default None.
540-
gtscore (Variable): mixup score of ground truth boxes, shoud be in shape
540+
gt_score (Variable): mixup score of ground truth boxes, shoud be in shape
541541
of [N, B]. Default None.
542542
use_label_smooth (bool): ${use_label_smooth_comment}
543543
@@ -558,25 +558,25 @@ def yolov3_loss(x,
558558
.. code-block:: python
559559
560560
x = fluid.layers.data(name='x', shape=[255, 13, 13], dtype='float32')
561-
gtbox = fluid.layers.data(name='gtbox', shape=[6, 4], dtype='float32')
562-
gtlabel = fluid.layers.data(name='gtlabel', shape=[6], dtype='int32')
563-
gtscore = fluid.layers.data(name='gtscore', shape=[6], dtype='float32')
561+
gt_box = fluid.layers.data(name='gt_box', shape=[6, 4], dtype='float32')
562+
gt_label = fluid.layers.data(name='gt_label', shape=[6], dtype='int32')
563+
gt_score = fluid.layers.data(name='gt_score', shape=[6], dtype='float32')
564564
anchors = [10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326]
565565
anchor_mask = [0, 1, 2]
566-
loss = fluid.layers.yolov3_loss(x=x, gtbox=gtbox, gtlabel=gtlabel,
567-
gtscore=gtscore, anchors=anchors,
566+
loss = fluid.layers.yolov3_loss(x=x, gt_box=gt_box, gt_label=gt_label,
567+
gt_score=gt_score, anchors=anchors,
568568
anchor_mask=anchor_mask, class_num=80,
569569
ignore_thresh=0.7, downsample_ratio=32)
570570
"""
571571
helper = LayerHelper('yolov3_loss', **locals())
572572

573573
if not isinstance(x, Variable):
574574
raise TypeError("Input x of yolov3_loss must be Variable")
575-
if not isinstance(gtbox, Variable):
575+
if not isinstance(gt_box, Variable):
576576
raise TypeError("Input gtbox of yolov3_loss must be Variable")
577-
if not isinstance(gtlabel, Variable):
577+
if not isinstance(gt_label, Variable):
578578
raise TypeError("Input gtlabel of yolov3_loss must be Variable")
579-
if gtscore is not None and not isinstance(gtscore, Variable):
579+
if gt_score is not None and not isinstance(gt_score, Variable):
580580
raise TypeError("Input gtscore of yolov3_loss must be Variable")
581581
if not isinstance(anchors, list) and not isinstance(anchors, tuple):
582582
raise TypeError("Attr anchors of yolov3_loss must be list or tuple")
@@ -602,11 +602,11 @@ def yolov3_loss(x,
602602

603603
inputs = {
604604
"X": x,
605-
"GTBox": gtbox,
606-
"GTLabel": gtlabel,
605+
"GTBox": gt_box,
606+
"GTLabel": gt_label,
607607
}
608-
if gtscore:
609-
inputs["GTScore"] = gtscore
608+
if gt_score:
609+
inputs["GTScore"] = gt_score
610610

611611
attrs = {
612612
"anchors": anchors,

python/paddle/fluid/tests/test_detection.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,17 +474,17 @@ def test_yolov3_loss(self):
474474
program = Program()
475475
with program_guard(program):
476476
x = layers.data(name='x', shape=[30, 7, 7], dtype='float32')
477-
gtbox = layers.data(name='gtbox', shape=[10, 4], dtype='float32')
478-
gtlabel = layers.data(name='gtlabel', shape=[10], dtype='int32')
479-
gtscore = layers.data(name='gtscore', shape=[10], dtype='float32')
477+
gt_box = layers.data(name='gt_box', shape=[10, 4], dtype='float32')
478+
gt_label = layers.data(name='gt_label', shape=[10], dtype='int32')
479+
gt_score = layers.data(name='gt_score', shape=[10], dtype='float32')
480480
loss = layers.yolov3_loss(
481481
x,
482-
gtbox,
483-
gtlabel, [10, 13, 30, 13], [0, 1],
482+
gt_box,
483+
gt_label, [10, 13, 30, 13], [0, 1],
484484
10,
485485
0.7,
486486
32,
487-
gtscore=gtscore,
487+
gt_score=gt_score,
488488
use_label_smooth=False)
489489

490490
self.assertIsNotNone(loss)

0 commit comments

Comments
 (0)