首页 > 解决方案 > 在 mmdetection 中运行 train_detector 后如何保存模型权重?

问题描述

cfg.optimizer.lr = 0.02 / 8
cfg.lr_config.warmup = None
cfg.log_config.interval = 600
# Change the evaluation metric since we use customized dataset.
cfg.evaluation.metric = 'bbox'
# We can set the evaluation interval to reduce the evaluation times
cfg.evaluation.interval = 3
# We can set the checkpoint saving interval to reduce the storage cost
cfg.checkpoint_config.interval = 3
# Set seed thus the results are more reproducible
cfg.seed = 0
set_random_seed(0, deterministic=False)
cfg.gpu_ids = range(1)

cfg.load_from = 'gdrive/My Drive/mmdetection/checkpoints/vfnet_r50_fpn_mdconv_c3- 
c5_mstrain_2x_coco_20201027pth-6879c318.pth'
cfg.work_dir = "../vinbig"
cfg.runner.max_epochs = 6
cfg.total_epochs = 6model = build_detector(cfg.model)
datasets = [build_dataset(cfg.data.train)]
train_detector(model, datasets[0], cfg, distributed=False, validate=True)

现在,我的问题是,一旦我对自定义数据集上的模型进行了微调,我该如何使用它进行测试?微调后的模型存储在哪里?在大多数地方,模型会立即用于测试,但我如何保存微调后的模型以供以后测试。

img = mmcv.imread('kitti_tiny/training/image_2/000068.jpeg')

model.cfg = cfg
result = inference_detector(model, img)
show_result_pyplot(model, img, result)

以上主要是在训练阶段之后发生的。但那是因为模型已经在运行时。如何创建自己的 mmdetection 模型检查点?我一直在研究 Google colab。

标签: deep-learningneural-networkgoogle-colaboratory

解决方案


好吧,我不知道如何手动执行,但是您的检查点会自动保存在cfg.work_dir = "../vinbig". 在那里你可以找到'latest.pth'文件作为你的最终检查点。


推荐阅读