mmcls调用逻辑
2022-09-09 10:49:15 3 举报
open-mmlab框架系列之mmcls图像分类调用逻辑泳道图
作者其他创作
大纲/内容
dataloader
IterBaseRunner
+ register_training_hooks()
+ run() + train() + val() + resume() + save_checkpoint()
optimizer
配置参数config(dict)model,dataset,schedules,runtime
utils/register.py
openmmlab-cls
装饰
OPTIMIZER_BUILDERS = Registry('optimizer builder')
DATASETS = Registry('dataset')PIPELINES = Registry('pipeline')SAMPLERS = Registry('sampler')
model
构建modelbuild_classifier()
runner
Runner
Config
+ fromfile(filename):return cfg
EpochBaseRunner
+ run() + run_iter() + train()
+ val() + save_checkpoint()
dataset
datasets
构建datasetsbuild_dataset()
runner/optimizer/build.py
dataloader=build_dataloader(dataset)
Hook
+ before_run(runner)+ before_train_epoch(runner)+ before_train_iter(runner)+ after_train_iter(runner)+ after_train_epoch(runner)+ before_val_epoch(runner)+ before_val_iter(runner)+ after_val_iter(runner)+ after_val_epoch(runner)+ after_run(runner)+ get_triggered_stages()
runner/hooks
cnn
CustomHook
+ custom_function(runner)
train.py
runner.register_hook()
RUNNER_BUILDERS.build(cfg)
cfg=Config().fromfile()
cnn.bricks.registry
OPTIMIZERS = Registry('optimizer')
RUNNER = Registry('runner')
runner.register_training_hooks()
train_model流程
MODELS
+ build_classifier(cfg)+ build_backbone(cfg)+ build_head(cfg)+ build_neck(cfg)+ build_loss(cfg)
EvalHook
+ evaluation()
+ before_run(runner)+ before_train_epoch(runner)+ before_train_iter(runner)+ after_train_iter(runner)+ after_train_epoch(runner)
runner/build.py
build_from_cfg()
OptimizerHook
+ after_train_iter(runner)
mmcv
dataset=build_dataset(cfg.data)
CheckpointHook
+ before_run(runner)
+ after_train_iter(runner)+ after_train_epoch(runner)
config
RUNNER_BUILDERS = Registry('runner builder')
Register
+ build() # 编译模块(接口)+ build_func() # 编译(外部函数)
+ register_module() # 注册模块
LrUpdaterHook
+ get_lr(runner)+ get_regular_lr(runner)+ get_warmup_lr(runner)
+ before_run(runner)+ after_train_iter(runner)+ after_train_epoch(runner)
mmcls
BaseRunner
+ run()# 虚函数,在继承类中实现+ train()# 虚函数,在继承类中实现+ val()# 虚函数,在继承类中实现+ save_checkpoint()
- _hooks+ register_hook():return _hooks+ call_hook()+ resume()+ register_lr_hook(cfg)+ register_momentum_hook(cfg)+ register_optimizer_hook(cfg)+ register_checkpoint_hook(cfg)+ register_logger_hook(cfg)+ register_timer_hook(cfg)+ register_custom_hook(cfg)+ register_training_hook(cfg)
HOOKS = Registry('hook')
tools
MMCV_ATTENTION=Register('attention')
logger
api/train.py
0 条评论
下一页