提交 9c99e7cc 编写于 作者: W weishengyu

add bnneck, last stride=1

上级 5615bc6c
......@@ -18,13 +18,14 @@ from .circlemargin import CircleMargin
from .fc import FC
from .vehicle_neck import VehicleNeck
from paddle.nn import Tanh
from .bnneck import BNNeck
__all__ = ['build_gear']
def build_gear(config):
support_dict = [
'ArcMargin', 'CosMargin', 'CircleMargin', 'FC', 'VehicleNeck', 'Tanh'
'ArcMargin', 'CosMargin', 'CircleMargin', 'FC', 'VehicleNeck', 'Tanh', "BNNeck"
]
module_name = config.pop('name')
assert module_name in support_dict, Exception(
......
class BNNeck(nn.Layer):
def __init__(self, num_filters, trainable=False):
super(BNNeck, self).__init__()
self.num_filters = num_filters
self.bn = paddle.nn.BatchNorm(
self.num_filters)
if not trainable:
self.bn.weight.trainable = False
self.bn.bias.trainable = False
def forward(self, input, label=None):
out = self.bn(input)
return out
......@@ -36,6 +36,7 @@ Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
- TripletLossV2:
weight: 1.0
margin: 0.3
......@@ -48,8 +49,10 @@ Optimizer:
name: Adam
lr:
name: Piecewise
decay_epochs: [40, 70]
decay_epochs: [30, 60]
values: [0.00035, 0.000035, 0.0000035]
warmup_epoch: 10
warmup_start_lr: 0.0000035
regularizer:
name: 'L2'
coeff: 0.0005
......@@ -73,17 +76,13 @@ DataLoader:
padding: 10
- RandCropImage:
size: [128, 256]
scale: [0.8022, 0.8022]
ratio: [0.5, 0.5]
- NormalizeImage:
scale: 0.00392157
mean: [0.485, 0.456, 0.406]
std: [0.229, 0.224, 0.225]
order: ''
- RandomErasing:
EPSILON: 0.5
sl: 0.02
sh: 0.4
r1: 0.3
mean: [0.4914, 0.4822, 0.4465]
sampler:
name: DistributedRandomIdentitySampler
batch_size: 64
......
......@@ -21,11 +21,15 @@ Arch:
infer_output_key: "features"
infer_add_softmax: False
Backbone:
name: "ResNet50"
name: "ResNet50_last_stage_stride1"
pretrained: True
stem_act: null
BackboneStopLayer:
name: "flatten"
Neck:
name: BNNeck
num_filters: 2048
trainale: false
Head:
name: "FC"
embedding_size: 2048
......@@ -76,6 +80,8 @@ DataLoader:
padding: 10
- RandCropImage:
size: [128, 256]
scale: [ 0.8022, 0.8022 ]
ratio: [ 0.5, 0.5 ]
- NormalizeImage:
scale: 0.00392157
mean: [0.485, 0.456, 0.406]
......@@ -88,9 +94,9 @@ DataLoader:
r1: 0.3
mean: [0.4914, 0.4822, 0.4465]
sampler:
name: PKSampler
name: DistributedRandomIdentitySampler
batch_size: 64
sample_per_id: 4
num_instances: 4
drop_last: True
shuffle: True
loader:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册