当前位置:网站首页>"Record" MMDetection Introduction
"Record" MMDetection Introduction
2022-07-29 18:07:00 【ViatorSun】
OpenMMLabis a deep learning high-level library,通过OpenMMLab The software stack can be seen,The lower level is still used Pytorch,So the user is not learning a whole new library,but more advanced,更加方便的Pytorch库,OpenMMLabIt can bring higher efficiency to users,So that users can only focus on the core algorithm,Don't waste more time on configuration files
MMdet 主要由 4 个部分组成,datasets、models、core 和 apis
另外,MMCV is for the whole OpenMMLab All open source libraries,There are general classes and utility classes,Convenient for all downstream codebase 复用


backbone
mmdet/models/backbones
__all__ = [ 'RegNet', 'ResNet', 'ResNetV1d', 'ResNeXt', 'SSDVGG', 'HRNet', 'Res2Net',
'HourglassNet', 'DetectoRS_ResNet', 'DetectoRS_ResNeXt', 'Darknet',
'ResNeSt', 'TridentResNet' ]
通过 MMCV Registrar mechanism in ,你可以通过 dict form configuration to instantiate any registered class,非常方便和灵活.
# Pretrained weight paths for the skeleton
pretrained='torchvision://resnet50',
backbone=dict(
type='ResNet', # Skeleton class name,The following parameters are the initialization parameters of the class
depth=50,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch'),
neck
neck 可以认为是 backbone 和 head 的连接层,主要负责对 backbone The features are efficiently fused and enhanced,The input single-scale or multi-scale features can be fused、Enhanced output, etc.
mmdet/models/necks
__all__ = [
'FPN', 'BFP', 'ChannelMapper', 'HRFPN', 'NASFPN', 'FPN_CARAFE', 'PAFPN',
'NASFCOS_FPN', 'RFP', 'YOLOV3Neck'
]
最常用的应该是 FPN,A typical usage is:
neck=dict(
type='FPN',
in_channels=[256, 512, 1024, 2048], # 骨架多尺度特征图输出通道
out_channels=256, # 增强后通道输出
num_outs=5), # 输出num_outs个多尺度特征图
head
The output of the target detection algorithm generally includes two branches: classification and box coordinate regression,不同算法 head Modules vary in complexity,灵活度比较高.在网络构建方面,To understand the target detection algorithm is mainly to understand head 模块.
MMDetection 中 head Modules are divided into two-stage 所需的 RoIHead 和 one-stage 所需的 DenseHead,
- 所有的 one-stage 算法的 head 模块都在mmdet/models/dense_heads中
- 而 two-stage The algorithm also includes additional mmdet/models/roi_heads
Almost every algorithm includes a standalone head
# dense_heads:
__all__ = [
'AnchorFreeHead', 'AnchorHead', 'GuidedAnchorHead', 'FeatureAdaption',
'RPNHead', 'GARPNHead', 'RetinaHead', 'RetinaSepBNHead', 'GARetinaHead',
'SSDHead', 'FCOSHead', 'RepPointsHead', 'FoveaHead',
'FreeAnchorRetinaHead', 'ATSSHead', 'FSAFHead', 'NASFCOSHead',
'PISARetinaHead', 'PISASSDHead', 'GFLHead', 'CornerHead', 'YOLACTHead',
'YOLACTSegmHead', 'YOLACTProtonet', 'YOLOV3Head', 'PAAHead',
'SABLRetinaHead', 'CentripetalHead', 'VFNetHead', 'TransformerHead'
]
需要注意的是:two-stage 或者 mutli-stage 算法,Will additionally include a region extractor roi extractor,Used to convert different sizes RoI The feature maps are unified into the same size.
虽然 head Part of the network construction is relatively simple,But due to positive and negative sample property definition、Sum of positive and negative samples bbox 编解码模块都在 head A combined call is made in the module,故
MMDetection The most complex module in head.
下载配置文件
建议在 Conda环境中,在Pycharm中好像不能用,暂时还不知道是什么原因造成的
# 安装 mim
pip install openmim
mim search mmdet --model "mask r-cnn"
mim download mmdet --config "mask_rcnn_r50_fpn_2x_coco" --dest .
注意!--dest . 中间有空格


运行测试模型
from mmdet.apis import init_detector, inference_detector, train_detector, show_result_pyplot
from mmdet.datasets import build_dataset
from mmcv import Config
import mmcv
import os.path as osp
import multiprocessing
if __name__ == '__main__':
multiprocessing.freeze_support()
config_file = 'solo_r50_fpn_3x_coco.py'
checkpoint_file = 'solo_r50_fpn_3x_coco_20210901_012353-11d224d7.pth'
model = init_detector(config_file, checkpoint_file, device='cuda:0')
# print(model)
cfg = Config.fromfile(config_file)
dataset = [build_dataset(cfg.data.train)]
mmcv.mkdir_or_exist(osp.abspath('./work_dir_sum'))
train_detector(model, dataset, cfg, distributed=False, validate=False)
# 推理演示图像
result = inference_detector(model, '81.jpg')
show_result_pyplot(model,'81.jpg', result)
边栏推荐
猜你喜欢

鸡兔同笼

reading order

Groeb - "gramm, explicit and complete n -" gramm mask language model, implements the explicit n - "gramm semantic unit modeling knowledge.

解析idea中的debug调试模式

js骏马奔腾点击裁剪js特效

一文搞定代码中的命名

Texture 】 【 terrain 】 【 virtual virtual terrain texture technology is introduced

递归法解决N皇后问题

面试官:MySQL如何根据执行计划调优SQL语句?

unbuntu18.04-----bilibili网页端无法播放视频
随机推荐
Arduino框架下轻量级ssd1306 I2C屏幕驱动库
query词权重, 搜索词权重计算
阅读顺序
GMAT考什么?
Thread Dump分析方法
leetcode136 -- 只出现一次的数字
TensorFlow Serving high-performance machine learning model of service system
Frame双向通信插件FrameDataTrans
量化初级 -- akshare获得股票代码,最简策略
休息天的早晨感觉不到在休息
Quantitative Finance
Loadrunner与Jmeter区别与相同
Dynamic planning to climb the stairs
HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
“我“眼中的测试/开发程序员,预想与现实的碰撞......
[网络]LAN技术MSTP
如何让照片中的人物笑起来?HMS Core视频编辑服务一键微笑功能,让人物笑容更自然
js彩色树叶飘落动画js特效
面试官:MySQL如何根据执行计划调优SQL语句?
详解析构函数、拷贝构造函数