未验证 提交 0b33aced 编写于 作者: K Kaipeng Deng 提交者: GitHub

Add yolov3_mobilenet_v3 (#443)

* add yolov3_mobilenet_v3
上级 365082f2
architecture: YOLOv3
use_gpu: true
max_iters: 500200
max_iters: 500000
log_smooth_window: 20
save_dir: output
snapshot_iter: 2000
snapshot_iter: 10000
metric: COCO
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar
weights: output/yolov3_darknet/model_final
......
architecture: YOLOv3
use_gpu: true
max_iters: 500200
max_iters: 500000
log_smooth_window: 20
save_dir: output
snapshot_iter: 2000
snapshot_iter: 10000
metric: COCO
pretrain_weights: http://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar
weights: output/yolov3_mobilenet_v1/model_final
......
architecture: YOLOv3
use_gpu: true
max_iters: 500000
log_smooth_window: 20
save_dir: output
snapshot_iter: 10000
metric: COCO
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_large_x1_0_pretrained.tar
weights: output/yolov3_mobilenet_v3/model_final
num_classes: 80
use_fine_grained_loss: false
YOLOv3:
backbone: MobileNetV3
yolo_head: YOLOv3Head
MobileNetV3:
norm_type: sync_bn
norm_decay: 0.
model_name: large
scale: 1.
with_extra_blocks: false
YOLOv3Head:
anchor_masks: [[6, 7, 8], [3, 4, 5], [0, 1, 2]]
anchors: [[10, 13], [16, 30], [33, 23],
[30, 61], [62, 45], [59, 119],
[116, 90], [156, 198], [373, 326]]
norm_decay: 0.
yolo_loss: YOLOv3Loss
nms:
background_label: -1
keep_top_k: 100
nms_threshold: 0.45
nms_top_k: 1000
normalized: false
score_threshold: 0.01
YOLOv3Loss:
# batch_size here is only used for fine grained loss, not used
# for training batch_size setting, training batch_size setting
# is in configs/yolov3_reader.yml TrainReader.batch_size, batch
# size here should be set as same value as TrainReader.batch_size
batch_size: 8
ignore_thresh: 0.7
label_smooth: false
LearningRate:
base_lr: 0.001
schedulers:
- !PiecewiseDecay
gamma: 0.1
milestones:
- 400000
- 450000
- !LinearWarmup
start_factor: 0.
steps: 4000
OptimizerBuilder:
optimizer:
momentum: 0.9
type: Momentum
regularizer:
factor: 0.0005
type: L2
_READER_: 'yolov3_reader.yml'
architecture: YOLOv3
use_gpu: true
max_iters: 500200
max_iters: 500000
log_smooth_window: 20
save_dir: output
snapshot_iter: 2000
snapshot_iter: 10000
metric: COCO
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet34_pretrained.tar
weights: output/yolov3_r34/model_final
......
......@@ -133,6 +133,9 @@ The backbone models pretrained on ImageNet are available. All backbone models ar
| MobileNet-V1 | ImageNet | 608 | False | 8 | 270e | 78.302 | 29.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1 | ImageNet | 416 | False | 8 | 270e | - | 29.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1 | ImageNet | 320 | False | 8 | 270e | - | 27.1 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V3 | ImageNet | 608 | False | 8 | 270e | - | 31.6 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v3.pdparams) |
| MobileNet-V3 | ImageNet | 416 | False | 8 | 270e | - | 29.9 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v3.pdparams) |
| MobileNet-V3 | ImageNet | 320 | False | 8 | 270e | - | 27.1 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v3.pdparams) |
| ResNet34 | ImageNet | 608 | False | 8 | 270e | 63.356 | 36.2 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| ResNet34 | ImageNet | 416 | False | 8 | 270e | - | 34.3 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| ResNet34 | ImageNet | 320 | False | 8 | 270e | - | 31.4 | [model](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
......
......@@ -129,6 +129,9 @@ Paddle提供基于ImageNet的骨架网络预训练模型。所有预训练模型
| MobileNet-V1 | ImageNet | 608 | 否 | 8 | 270e | 78.302 | 29.3 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1 | ImageNet | 416 | 否 | 8 | 270e | - | 29.3 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1 | ImageNet | 320 | 否 | 8 | 270e | - | 27.1 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v1.tar) |
| MobileNet-V1 | ImageNet | 608 | 否 | 8 | 270e | - | 31.6 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v3.pdparams) |
| MobileNet-V1 | ImageNet | 416 | 否 | 8 | 270e | - | 29.9 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v3.pdparams) |
| MobileNet-V1 | ImageNet | 320 | 否 | 8 | 270e | - | 27.1 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_mobilenet_v3.pdparams) |
| ResNet34 | ImageNet | 608 | 否 | 8 | 270e | 63.356 | 36.2 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| ResNet34 | ImageNet | 416 | 否 | 8 | 270e | - | 34.3 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
| ResNet34 | ImageNet | 320 | 否 | 8 | 270e | - | 31.4 | [下载链接](https://paddlemodels.bj.bcebos.com/object_detection/yolov3_r34.tar) |
......
......@@ -15,7 +15,8 @@ class MobileNetV3():
model_name='small',
with_extra_blocks=False,
conv_decay=0.0,
bn_decay=0.0,
norm_type='bn',
norm_decay=0.0,
extra_block_filters=[[256, 512], [128, 256], [128, 256],
[64, 128]]):
self.scale = scale
......@@ -23,7 +24,7 @@ class MobileNetV3():
self.with_extra_blocks = with_extra_blocks
self.extra_block_filters = extra_block_filters
self.conv_decay = conv_decay
self.bn_decay = bn_decay
self.norm_decay = norm_decay
self.inplanes = 16
self.end_points = []
self.block_stride = 1
......@@ -90,9 +91,9 @@ class MobileNetV3():
bias_attr=False)
bn_name = name + '_bn'
bn_param_attr = ParamAttr(
name=bn_name + "_scale", regularizer=L2Decay(self.bn_decay))
name=bn_name + "_scale", regularizer=L2Decay(self.norm_decay))
bn_bias_attr = ParamAttr(
name=bn_name + "_offset", regularizer=L2Decay(self.bn_decay))
name=bn_name + "_offset", regularizer=L2Decay(self.norm_decay))
bn = fluid.layers.batch_norm(
input=conv,
param_attr=bn_param_attr,
......@@ -238,6 +239,8 @@ class MobileNetV3():
i = 0
for layer_cfg in cfg:
self.block_stride *= layer_cfg[5]
if layer_cfg[5] == 2:
blocks.append(conv)
conv = self._residual_unit(
input=conv,
num_in_filter=inplanes,
......@@ -250,9 +253,10 @@ class MobileNetV3():
name='conv' + str(i + 2))
inplanes = int(scale * layer_cfg[2])
i += 1
blocks.append(conv)
if not self.with_extra_blocks:
return conv
return blocks
# extra block
conv_extra = self._conv_bn_layer(
......
......@@ -92,6 +92,13 @@ def _load_state(path):
return state
def _strip_postfix(path):
path, ext = os.path.splitext(path)
assert ext in ['', '.pdparams', '.pdopt', '.pdmodel'], \
"Unknown postfix {} from weights".format(ext)
return path
def load_params(exe, prog, path, ignore_params=[]):
"""
Load model from the given path.
......@@ -106,6 +113,8 @@ def load_params(exe, prog, path, ignore_params=[]):
if is_url(path):
path = _get_weight_path(path)
path = _strip_postfix(path)
if not (os.path.isdir(path) or os.path.exists(path + '.pdparams')):
raise ValueError("Model pretrain path {} does not "
"exists.".format(path))
......@@ -151,6 +160,8 @@ def load_checkpoint(exe, prog, path):
"""
if is_url(path):
path = _get_weight_path(path)
path = _strip_postfix(path)
if not (os.path.isdir(path) or os.path.exists(path + '.pdparams')):
raise ValueError("Model pretrain path {} does not "
"exists.".format(path))
......
......@@ -201,7 +201,11 @@ def get_path(url, root_dir, md5sum=None, check_exist=True):
else:
exist_flag = False
fullname = _download(url, root_dir, md5sum)
_decompress(fullname)
# new weights format which postfix is 'pdparams' not
# need to decompress
if osp.splitext(fullname)[-1] != '.pdparams':
_decompress(fullname)
return fullpath, exist_flag
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册