From 3fba477820e3873432b12d6c0b90eb93af1d5ede Mon Sep 17 00:00:00 2001 From: wangguanzhong Date: Sat, 9 May 2020 12:27:01 +0800 Subject: [PATCH] minor fix for cornernet & yolov4 (#621) --- ppdet/modeling/anchor_heads/corner_head.py | 12 ++++++------ ppdet/modeling/architectures/cornernet_squeeze.py | 2 +- ppdet/modeling/losses/yolo_loss.py | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ppdet/modeling/anchor_heads/corner_head.py b/ppdet/modeling/anchor_heads/corner_head.py index fc7c64c19..a43416d15 100644 --- a/ppdet/modeling/anchor_heads/corner_head.py +++ b/ppdet/modeling/anchor_heads/corner_head.py @@ -23,12 +23,8 @@ from paddle.fluid.initializer import Constant from ..backbones.hourglass import _conv_norm, kaiming_init from ppdet.core.workspace import register import numpy as np -try: - import cornerpool_lib -except: - print( - "warning: cornerpool_lib not found, compile in ext_op at first if needed" - ) +import logging +logger = logging.getLogger(__name__) __all__ = ['CornerHead'] @@ -247,6 +243,10 @@ class CornerHead(object): ae_threshold=1, num_dets=1000, top_k=100): + try: + import cornerpool_lib + except: + logger.error("cornerpool_lib not found, compile in ext_op at first") self.train_batch_size = train_batch_size self.test_batch_size = test_batch_size self.num_classes = num_classes diff --git a/ppdet/modeling/architectures/cornernet_squeeze.py b/ppdet/modeling/architectures/cornernet_squeeze.py index bcba61378..fb2ce42a1 100644 --- a/ppdet/modeling/architectures/cornernet_squeeze.py +++ b/ppdet/modeling/architectures/cornernet_squeeze.py @@ -59,7 +59,7 @@ class CornerNetSqueeze(object): body_feats = self.backbone(im) if self.fpn is not None: body_feats, _ = self.fpn.get_output(body_feats) - body_feats = [body_feats.values()[-1]] + body_feats = [list(body_feats.values())[-1]] if mode == 'train': target_vars = [ 'tl_heatmaps', 'br_heatmaps', 'tag_masks', 'tl_regrs', diff --git a/ppdet/modeling/losses/yolo_loss.py b/ppdet/modeling/losses/yolo_loss.py index b2661a4aa..9696dfbab 100644 --- a/ppdet/modeling/losses/yolo_loss.py +++ b/ppdet/modeling/losses/yolo_loss.py @@ -166,7 +166,7 @@ class YOLOv3Loss(object): # self.scale_x_y, Sequence) else self.scale_x_y[i] loss_obj_pos, loss_obj_neg = self._calc_obj_loss( output, obj, tobj, gt_box, self._batch_size, anchors, - num_classes, downsample, self._ignore_thresh, scale_x_y) + num_classes, downsample, self._ignore_thresh) loss_cls = fluid.layers.sigmoid_cross_entropy_with_logits(cls, tcls) loss_cls = fluid.layers.elementwise_mul(loss_cls, tobj, axis=0) @@ -276,7 +276,7 @@ class YOLOv3Loss(object): return (tx, ty, tw, th, tscale, tobj, tcls) def _calc_obj_loss(self, output, obj, tobj, gt_box, batch_size, anchors, - num_classes, downsample, ignore_thresh, scale_x_y): + num_classes, downsample, ignore_thresh): # A prediction bbox overlap any gt_bbox over ignore_thresh, # objectness loss will be ignored, process as follows: -- GitLab