importmmcv from mmcv.runnerimportload_checkpoint from mmdet.modelsimportbuild_detector # Choose to use a config and initialize the detector config='configs/faster_rcnn/faster_rcnn_r50_caffe_fpn_mstrain_3x_coco.p
runner.register_hook(eval_hook(val_dataloader,**eval_cfg))#6.注册用户自定义 hook runner.register_hook(hook,priority=priority)#7.权重恢复和加载ifcfg.resume_from:runner.resume(cfg.resume_from)elif cfg.load_from:runner.load_checkpoint(cfg.load_from)#8.运行,开始训练 runner.run(data_loaders,cfg....
import mmcv import os import numpy as np from mmcv.runner import load_checkpoint from mmdet.models import build_detector from mmdet.apis import init_detector, inference_detector, show_result config_file = 'configs/faster_rcnn_voc.py' checkpoint_file = 'work_dirs/faster_rcnn_voc/epoch_24.pth...
checkpoint='checkpoints/faster_rcnn_r50_caffe_fpn_mstrain_3x_coco_20210526_095054-1f77628b.pth' # Set the device to be used for evaluation device='cuda:0' # Load the config config=mmcv.Config.fromfile(config) # Set pretrained to be None since we do not need pretrained model here confi...
resume和load_checkpoint。分布对应加载断点文件和预训练模型。 save_checkpoint方法,保存断点,将由checkpointhook调用。 register_hook负责注册hook类到self._hooks中 call_hook调用hook类 train和val run方法开启真正的工作流 mmcv中Runner类主要有三个:BaseRunner基类,以及继承于它的EpochBasedRunner类和IterBasedRunner类...
defafter_train_epoch(self, runner):"""We load parameter values from ema backup to model before theEvalHook."""self._swap_ema_parameters() checkpoint.py的HOOK中,同样也定义了after_train_epoch函数如下: @master_onlydefafter_train_epoch(self, runner):ifn...
<CHECKPOINT_FILE> --gpus 8 --out results.pkl --eval 1. 2. 在测试过程中可视化结果同样很方便,只需添加一个参数 --show: python tools/test.py <CONFIG_FILE> <CHECKPOINT_FILE> --show 1. 测试图像 import mmcv from mmcv.runner import load_checkpoint ...
python tools/test.py <CONFIG_FILE> <CHECKPOINT_FILE> --show 2. 测试图像 开发者提供了一些高级 api 来测试图像:import mmcvfrom mmcv.runner import load_checkpointfrom mmdet.models import build_detectorfrom mmdet.apis import inference_detector, show_resultcfg = mmcv.Config.fromfile('configs/faster_...
--resume_from ${CHECKPOINT_FILE}:从先前的检查点文件恢复。resume_from和load_from之间的区别: resume_from加载模型权重和优化器状态,并且epoch也从指定的检查点继承。它通常用于恢复意外中断的训练过程。 load_from仅加载模型权重,训练时期从0开始。通常用于微调。用多台机器训练 如果在由slurm(https://slurm....
python tools/test.py <CONFIG_FILE> <CHECKPOINT_FILE> --show 2. 测试图像 开发者提供了一些高级 api 来测试图像: import mmcv from mmcv.runner import load_checkpoint from mmdet.models import build_detector from mmdet.apis import inference_detector, show_result ...