Skip to content

Commit dc7a8aa

Browse files
authored
Merge pull request #1114 from will-jl944/bug_fix
Fix ppyolo deployment bug
2 parents 24977f6 + 353aa81 commit dc7a8aa

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

paddlex/cv/models/detector.py

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ def __init__(self,
10821082
"('ResNet50_vd_dcn', 'ResNet18_vd', 'MobileNetV3_large', 'MobileNetV3_small')".
10831083
format(backbone))
10841084
self.backbone_name = backbone
1085+
self.downsample_ratios = [
1086+
32, 16, 8
1087+
] if backbone == 'ResNet50_vd_dcn' else [32, 16]
10851088

10861089
if params.get('with_net', True):
10871090
if paddlex.env_info['place'] == 'gpu' and paddlex.env_info[
@@ -1117,7 +1120,6 @@ def __init__(self,
11171120
freeze_at=-1,
11181121
freeze_norm=False,
11191122
norm_decay=0.)
1120-
downsample_ratios = [32, 16, 8]
11211123

11221124
elif backbone == 'ResNet18_vd':
11231125
backbone = self._get_backbone(
@@ -1129,7 +1131,6 @@ def __init__(self,
11291131
freeze_at=-1,
11301132
freeze_norm=False,
11311133
norm_decay=0.)
1132-
downsample_ratios = [32, 16]
11331134

11341135
elif backbone == 'MobileNetV3_large':
11351136
backbone = self._get_backbone(
@@ -1140,7 +1141,6 @@ def __init__(self,
11401141
with_extra_blocks=False,
11411142
extra_block_filters=[],
11421143
feature_maps=[13, 16])
1143-
downsample_ratios = [32, 16]
11441144

11451145
elif backbone == 'MobileNetV3_small':
11461146
backbone = self._get_backbone(
@@ -1151,7 +1151,6 @@ def __init__(self,
11511151
with_extra_blocks=False,
11521152
extra_block_filters=[],
11531153
feature_maps=[9, 12])
1154-
downsample_ratios = [32, 16]
11551154

11561155
neck = ppdet.modeling.PPYOLOFPN(
11571156
norm_type=norm_type,
@@ -1166,7 +1165,7 @@ def __init__(self,
11661165
loss = ppdet.modeling.YOLOv3Loss(
11671166
num_classes=num_classes,
11681167
ignore_thresh=ignore_threshold,
1169-
downsample=downsample_ratios,
1168+
downsample=self.downsample_ratios,
11701169
label_smooth=label_smooth,
11711170
scale_x_y=scale_x_y,
11721171
iou_loss=ppdet.modeling.IouLoss(
@@ -1217,7 +1216,6 @@ def __init__(self,
12171216
model_name='YOLOv3', num_classes=num_classes, **params)
12181217
self.anchors = anchors
12191218
self.anchor_masks = anchor_masks
1220-
self.downsample_ratios = downsample_ratios
12211219
self.model_name = 'PPYOLO'
12221220

12231221
def _get_test_inputs(self, image_shape):
@@ -1272,7 +1270,7 @@ def __init__(self,
12721270
"PPYOLOTiny only supports MobileNetV3 as backbone. "
12731271
"Backbone is forcibly set to MobileNetV3.")
12741272
self.backbone_name = 'MobileNetV3'
1275-
1273+
self.downsample_ratios = [32, 16, 8]
12761274
if params.get('with_net', True):
12771275
if paddlex.env_info['place'] == 'gpu' and paddlex.env_info[
12781276
'num'] > 1 and not os.environ.get('PADDLEX_EXPORT_STAGE'):
@@ -1288,7 +1286,6 @@ def __init__(self,
12881286
with_extra_blocks=False,
12891287
extra_block_filters=[],
12901288
feature_maps=[7, 13, 16])
1291-
downsample_ratios = [32, 16, 8]
12921289

12931290
neck = ppdet.modeling.PPYOLOTinyFPN(
12941291
detection_block_channels=[160, 128, 96],
@@ -1299,7 +1296,7 @@ def __init__(self,
12991296
loss = ppdet.modeling.YOLOv3Loss(
13001297
num_classes=num_classes,
13011298
ignore_thresh=ignore_threshold,
1302-
downsample=downsample_ratios,
1299+
downsample=self.downsample_ratios,
13031300
label_smooth=label_smooth,
13041301
scale_x_y=scale_x_y,
13051302
iou_loss=ppdet.modeling.IouLoss(
@@ -1350,7 +1347,6 @@ def __init__(self,
13501347
model_name='YOLOv3', num_classes=num_classes, **params)
13511348
self.anchors = anchors
13521349
self.anchor_masks = anchor_masks
1353-
self.downsample_ratios = downsample_ratios
13541350
self.model_name = 'PPYOLOTiny'
13551351

13561352
def _get_test_inputs(self, image_shape):
@@ -1405,6 +1401,7 @@ def __init__(self,
14051401
"backbone: {} is not supported. Please choose one of "
14061402
"('ResNet50_vd_dcn', 'ResNet101_vd_dcn')".format(backbone))
14071403
self.backbone_name = backbone
1404+
self.downsample_ratios = [32, 16, 8]
14081405

14091406
if params.get('with_net', True):
14101407
if paddlex.env_info['place'] == 'gpu' and paddlex.env_info[
@@ -1423,7 +1420,6 @@ def __init__(self,
14231420
freeze_at=-1,
14241421
freeze_norm=False,
14251422
norm_decay=0.)
1426-
downsample_ratios = [32, 16, 8]
14271423

14281424
elif backbone == 'ResNet101_vd_dcn':
14291425
backbone = self._get_backbone(
@@ -1436,7 +1432,6 @@ def __init__(self,
14361432
freeze_at=-1,
14371433
freeze_norm=False,
14381434
norm_decay=0.)
1439-
downsample_ratios = [32, 16, 8]
14401435

14411436
neck = ppdet.modeling.PPYOLOPAN(
14421437
norm_type=norm_type,
@@ -1449,7 +1444,7 @@ def __init__(self,
14491444
loss = ppdet.modeling.YOLOv3Loss(
14501445
num_classes=num_classes,
14511446
ignore_thresh=ignore_threshold,
1452-
downsample=downsample_ratios,
1447+
downsample=self.downsample_ratios,
14531448
label_smooth=label_smooth,
14541449
scale_x_y=scale_x_y,
14551450
iou_loss=ppdet.modeling.IouLoss(
@@ -1501,7 +1496,6 @@ def __init__(self,
15011496
model_name='YOLOv3', num_classes=num_classes, **params)
15021497
self.anchors = anchors
15031498
self.anchor_masks = anchor_masks
1504-
self.downsample_ratios = downsample_ratios
15051499
self.model_name = 'PPYOLOv2'
15061500

15071501
def _get_test_inputs(self, image_shape):

0 commit comments

Comments
 (0)