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

add bnneck, last stride=1

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