未验证 提交 287af3d1 编写于 作者: K Kaipeng Deng 提交者: GitHub

remove load_static_weights & polish ppdet.engine log (#2366)

* remove load_static_weights
上级 b00be04e
architecture: CascadeRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
CascadeRCNN:
......
architecture: CascadeRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
CascadeRCNN:
......
architecture: FasterRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
FasterRCNN:
backbone: ResNet
......
architecture: FasterRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
FasterRCNN:
backbone: ResNet
......
architecture: FCOS
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
FCOS:
backbone: ResNet
......
architecture: FasterRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/HRNet_W18_C_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/HRNet_W18_C_pretrained.pdparams
FasterRCNN:
backbone: HRNet
......
architecture: MaskRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
MaskRCNN:
backbone: ResNet
......
architecture: MaskRCNN
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
MaskRCNN:
backbone: ResNet
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_large_x1_0_ssld_pretrained.tar
load_static_weights: true
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV3_large_x1_0_ssld_pretrained.pdparams
norm_type: sync_bn
use_ema: true
ema_decay: 0.9998
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar
load_static_weights: true
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV3_small_x1_0_ssld_pretrained.pdparams
norm_type: sync_bn
use_ema: true
ema_decay: 0.9998
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet18_vd_pretrained.tar
load_static_weights: true
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet18_vd_pretrained.pdparams
norm_type: sync_bn
use_ema: true
ema_decay: 0.9998
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_ssld_pretrained.tar
load_static_weights: true
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_vd_ssld_pretrained.pdparams
norm_type: sync_bn
use_ema: true
ema_decay: 0.9998
......
# Weights of yolov3_mobilenet_v1_voc
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/dygraph/yolov3_mobilenet_v1_270e_voc.pdparams
load_static_weights: False
weight_type: resume
slim: Pruner
......
# Weights of yolov3_mobilenet_v1_voc
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/dygraph/yolov3_mobilenet_v1_270e_voc.pdparams
load_static_weights: False
weight_type: resume
slim: Pruner
......
# Weights of yolov3_mobilenet_v1_coco
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/dygraph/yolov3_mobilenet_v1_270e_coco.pdparams
load_static_weights: False
weight_type: resume
slim: QAT
......
# Weights of yolov3_mobilenet_v3_coco
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/dygraph/yolov3_mobilenet_v3_large_270e_coco.pdparams
load_static_weights: False
weight_type: resume
slim: QAT
......
architecture: SOLOv2
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_cos_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_cos_pretrained.pdparams
SOLOv2:
backbone: ResNet
......
architecture: SSD
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/ssd_mobilenet_v1_coco_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ssd_mobilenet_v1_coco_pretrained.pdparams
SSD:
backbone: MobileNet
......
architecture: SSD
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_ssld_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV1_ssld_pretrained.pdparams
SSD:
backbone: MobileNet
......
architecture: SSD
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_large_x1_0_ssld_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV3_large_x1_0_ssld_pretrained.pdparams
SSD:
backbone: MobileNetV3
......
architecture: SSD
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV3_small_x1_0_ssld_pretrained.pdparams
SSD:
backbone: MobileNetV3
......
architecture: TTFNet
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/DarkNet53_pretrained.pdparams
TTFNet:
backbone: DarkNet
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/DarkNet53_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/DarkNet53_pretrained.pdparams
norm_type: sync_bn
YOLOv3:
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV1_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV1_pretrained.pdparams
norm_type: sync_bn
YOLOv3:
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_large_x1_0_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV3_large_x1_0_ssld_pretrained.pdparams
norm_type: sync_bn
YOLOv3:
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/MobileNetV3_small_x1_0_ssld_pretrained.pdparams
norm_type: sync_bn
YOLOv3:
......
architecture: YOLOv3
pretrain_weights: https://paddle-imagenet-models-name.bj.bcebos.com/ResNet50_vd_ssld_pretrained.tar
load_static_weights: True
pretrain_weights: https://paddledet.bj.bcebos.com/models/pretrained/ResNet50_vd_ssld_pretrained.pdparams
norm_type: sync_bn
YOLOv3:
......
......@@ -5,7 +5,6 @@ _BASE_: [
'_base_/yolov3_reader.yml',
]
pretrain_weights: https://paddlemodels.bj.bcebos.com/object_detection/dygraph/yolov3_mobilenet_v1_270e_coco.pdparams
load_static_weights: false
norm_type: sync_bn
weights: output/yolov3_mobilenet_v1_roadsign/model_final
metric: VOC
......
......@@ -29,7 +29,7 @@ from ppdet.utils.checkpoint import save_model
from ppdet.optimizer import ModelEMA
from ppdet.utils.logger import setup_logger
logger = setup_logger(__name__)
logger = setup_logger('ppdet.engine')
__all__ = ['Callback', 'ComposeCallback', 'LogPrinter', 'Checkpointer']
......@@ -53,27 +53,27 @@ class Callback(object):
class ComposeCallback(object):
def __init__(self, callbacks):
callbacks = [h for h in list(callbacks) if h is not None]
for h in callbacks:
assert isinstance(h,
Callback), "hook shoule be subclass of Callback"
callbacks = [c for c in list(callbacks) if c is not None]
for c in callbacks:
assert isinstance(
c, Callback), "callback should be subclass of Callback"
self._callbacks = callbacks
def on_step_begin(self, status):
for h in self._callbacks:
h.on_step_begin(status)
for c in self._callbacks:
c.on_step_begin(status)
def on_step_end(self, status):
for h in self._callbacks:
h.on_step_end(status)
for c in self._callbacks:
c.on_step_end(status)
def on_epoch_begin(self, status):
for h in self._callbacks:
h.on_epoch_begin(status)
for c in self._callbacks:
c.on_epoch_begin(status)
def on_epoch_end(self, status):
for h in self._callbacks:
h.on_epoch_end(status)
for c in self._callbacks:
c.on_epoch_end(status)
class LogPrinter(Callback):
......
......@@ -23,7 +23,7 @@ from collections import OrderedDict
from ppdet.metrics import get_categories
from ppdet.utils.logger import setup_logger
logger = setup_logger(__name__)
logger = setup_logger('ppdet.engine')
# Global dictionary
TRT_MIN_SUBGRAPH = {
......
......@@ -38,7 +38,7 @@ from .callbacks import Callback, ComposeCallback, LogPrinter, Checkpointer, Wife
from .export_utils import _dump_infer_config
from ppdet.utils.logger import setup_logger
logger = setup_logger(__name__)
logger = setup_logger('ppdet.engine')
__all__ = ['Trainer']
......@@ -157,7 +157,7 @@ class Trainer(object):
metric.reset()
def register_callbacks(self, callbacks):
callbacks = [h for h in list(callbacks) if h is not None]
callbacks = [c for c in list(callbacks) if c is not None]
for c in callbacks:
assert isinstance(c, Callback), \
"metrics shoule be instances of subclass of Metric"
......@@ -179,9 +179,7 @@ class Trainer(object):
logger.debug("Resume weights of epoch {}".format(self.start_epoch))
else:
self.start_epoch = 0
load_pretrain_weight(self.model, weights,
self.cfg.get('load_static_weights', False),
weight_type)
load_pretrain_weight(self.model, weights, weight_type)
logger.debug("Load {} weights {} to start training".format(
weight_type, weights))
......
......@@ -142,10 +142,7 @@ def load_weight(model, weight, optimizer=None):
return last_epoch
def load_pretrain_weight(model,
pretrain_weight,
load_static_weights=False,
weight_type='pretrain'):
def load_pretrain_weight(model, pretrain_weight, weight_type='pretrain'):
assert weight_type in ['pretrain', 'finetune']
if is_url(pretrain_weight):
......@@ -161,23 +158,6 @@ def load_pretrain_weight(model,
model_dict = model.state_dict()
if load_static_weights:
pre_state_dict = paddle.static.load_program_state(path)
param_state_dict = {}
for key in model_dict.keys():
weight_name = model_dict[key].name
if weight_name in pre_state_dict.keys():
logger.info('Load weight: {}, shape: {}'.format(
weight_name, pre_state_dict[weight_name].shape))
param_state_dict[key] = pre_state_dict[weight_name]
else:
if 'backbone' in key:
logger.info('Lack weight: {}, structure name: {}'.format(
weight_name, key))
param_state_dict[key] = model_dict[key]
model.set_dict(param_state_dict)
return
param_state_dict = paddle.load(path + '.pdparams')
if weight_type == 'pretrain':
model.backbone.set_dict(param_state_dict)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册