当前位置:网站首页>"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)
边栏推荐
猜你喜欢
随机推荐
HER2-2-ME-BSANPs单抗特异性的2-甲氧基雌二醇白蛋白纳米粒的研究与制备
【高并发】我用多线程进一步优化了亿级流量电商业务下的海量数据校对系统,性能再次提升了200%!!(全程干货,建议收藏)
Frame双向通信插件FrameDataTrans
澜舟孟子轻量化预训练模型技术实践
Quantitative Finance
大佬们一个 sql 优化问题。我有个4千万的表。然后加了一个字段,只有10+条数据会给值,其他行数据
Loadrunner与Jmeter区别与相同
[网络]LAN技术MSTP
零花钱
Pycaret on diamond data sets using the regression problem
reading order
鸡兔同笼
接口项目02文档:Jmeter接口测试与性能测试
hihoCoder #1143 : 骨牌覆盖问题·一
ASCII码排序
“我“眼中的测试/开发程序员,预想与现实的碰撞......
泰山OFFICE技术讲座:影响文字效果的因素,由四大升级为五大
一键搭建博客:如何使用WordPress插件搭建专属博客
js选择多张图片对比功能插件
[High Concurrency] I used multithreading to further optimize the massive data proofreading system under the billion-level traffic e-commerce business, and the performance has been improved by 200% aga








