当前位置:网站首页>Mmdetection preliminary use
Mmdetection preliminary use
2022-07-29 04:01:00 【Can__ er】
About the environment
stay linux The deployment is very simple , Just follow the instructions in this chapter ( Although the author's name is in windows Upper Department )windows Lower installation mmdetection.windows There may be various small problems on .
among ,cuda What you need to pay attention to in the installation and configuration of is the version correspondence ,mmcv Attention should be paid to the installation mmcv-full, There is also a large string behind the download link , Corresponding to different cu Version and torch edition :

then github On clone project , Can be installed .mmdet Is a custom library function component , This is also the step to install .
About framework
First put a link to the official document ,Welcome to MMDetection’s documentation! — MMDetection 2.25.0 documentation. Here are some collations and understandings that are helpful for initial use .

【 a key 】 In general , Use human words to describe , We need to use tools Drive script in the directory , Training (train.py), Reasoning (test.py) Or analyze (analysis_tools Under the table of contents ) adopt configs Defined model . and mmdet Directories are less accessible to users , It is often some components that are called .
Here is a detailed introduction configs Catalog , There are many core configurations of the network , But in fact, we only need to master _base_ Catalog , You can start training quickly , Here is a partial reference mmdetection Preliminary use of - You know (zhihu.com) Make a conclusion :
datasets In the file directory , For data set related configuration files ; Here you need to define 【 Dataset name , route , Dataset format , Data set preprocessing mode and reading mode 】, Take a chestnut :
# dataset settings # Dataset name , Path parameter dataset_type = 'CocoDataset' data_root = 'data/coco/' # Configuration of standardized processing , Transformation of color channels img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) # Training ( test ) At the time of the pipeline The order , Generally, it is a well encapsulated strengthening operation train_pipeline = [...] test_pipeline = [...] # Data sets ( route , type , Picture prefix, etc ) data = dict( # Every GPU Of batch_size, Be careful not to let it exceed the video memory samples_per_gpu=2, # Every GPU Of workers workers_per_gpu=2, train=dict(...),, val=dict(...), test=dict(...) # every other interval individual epoch There will be one evaluation, The index is bbox evaluation = dict(interval=1, metric='bbox')if , Here we want to use a custom dataset , The first is to conform to several formats defined , Then generally, the only path that needs to be modified . Because data enhancement is often linked to the basic network , Each has the best fixed parameters .
however , One point that requires additional attention is related to
batch_sizeThe problem of , Every GPU Ofbatch_sizemultiply GPU Quantity is the total . And the learning ratelrNeeds and totalbatch_sizeIn direct proportion to .models File directory , Configure for some classic models ; They define in the form of dictionaries , A complete network structure includes backbone, neck, head And other configurations , This will involve how to choose , There is also the problem of parameter adjustment , Configure for different data set types and Networks .
- among ,backbone For the basic network , That is, the pre trained general object recognition model , such as
resnet,darknet,vggetc. . “ The core is to provide several combinations of receptive field size and central step size for detection , To meet the target detection of different scales and categories ”(Lighthouse - You know (zhihu.com) There are three parts of the specific explanation video ). - neck For the extraction of complex features , Its effect is “ The characteristic maps with different receptive field sizes are coupled , So as to enhance the expression ability ”, Often use
FPN, It's right Backbone Important features extracted , Reprocessing and rational utilization , Conducive to the next step head The specific task of learning . - head It is the output part for specific tasks , It is often easy to see if there is anchor, Is there any quality Learn from two aspects . Often the structure is relatively simple , Determine the category and location of the final box through classification and regression , adopt quality Make simple assessment or confidence adjustment .

- among ,backbone For the basic network , That is, the pre trained general object recognition model , such as
schedules File directory , It's mainly about potimizer and lr, as well as runner Configuration of components , Just look at an example . The parameter definition of learning rate can be seen here course 6: How to customize optimization strategies — MMClassification 0.23.1 file , Basic and pytorch The interfaces in are consistent .
# optimizer
optimizer = dict(type='Adam', lr=0.0001, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=200,
warmup_ratio=0.001,
step=[5, 8, 11])
runner = dict(type='EpochBasedRunner', max_epochs=12)
- Besides , There is another one in the same level directory default_runtime.py file , For the operating environment , Output ,hook And so on , Generally, we only need to pay attention to the first two lines .
# checkpoints hook The configuration file , How often epoch Save once pth file
checkpoint_config = dict(interval=1)
# How many samples are output once hook Information , How often epoch Save once logger
log_config = dict(
interval=100,
hooks=[
dict(type='TextLoggerHook'),
# dict(type='TensorboardLoggerHook')
])
About use
After the above frame structure is clear , We modify the parts we need to define , Then connect it with a file , Here is the self-contained faster_rcnn For example , The corresponding files are the ones introduced above .
# faster_rcnn
_base_ = [
# Model
'../_base_/models/faster_rcnn_r50_fpn.py',
# Data sets
'../_base_/datasets/coco_detection.py',
# Optimizer
'../_base_/schedules/schedule_1x.py',
# How to train
'../_base_/default_runtime.py'
]
Besides , You will find that not all frameworks adopt the above 4 A way of composing components , This is because in many network variants , Only a certain part has changed , We can do it in _base_ Several basic frameworks given in the catalogue , In the code “ quote + overwrite ” Form a new network .
Of course , Directly write the above components to the same file , Or it is also possible to take only a few reused files , such as yolo and fcos, All are _base_ There is no core model in , It is defined separately in its own directory :
_base_ = [
'../_base_/datasets/coco_detection.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
# model settings
model = dict(
type='FCOS',
# The model is defined separately
}
We use the command line to run this py file , You can complete training and other operations , For example, the network containing the above components I define here is called mynetwork.py, Then I just need :
python tools/train.py mynetwork.py
alike , utilize tools Tools in , Can complete the forecast , mark , Result detection and many other work ~
边栏推荐
- Common methods of lodash Library
- CUB_ Visualization of key points in 200 bird dataset
- SQL语句 关于字段转换怎么写
- Data too long for column 'xxx' at row 1 solution
- 企业网的三层架构
- [introduction to C language] zzulioj 1031-1035
- Typescript from getting started to mastering (XXII) namespace namespace (I)
- The const keyword of ES6 declares variables
- Summary on the thought of double pointer
- Shopify卖家:EDM营销就要搭配SaleSmartly,轻松搞定转化率
猜你喜欢

Ssl== certificate related concepts

企业网的三层架构

Basic configuration of BGP - establish peers and route announcements

Typescript from getting started to mastering (XXII) namespace namespace (I)

nacos注册中心

Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds

Is the browser multi process or single process?

Batch production and upload sales NFT opensea eth polygon

Why BGP server is used in sunflower remote control? Automatic optimal route and high-speed transmission across operators

Typescript from getting started to mastering (XVI) configuration file - first knowledge of compileroptions configuration item
随机推荐
Sunflower senior product director technology sharing: "how to apply national remote control" in AD domain environment
Note: restframe work records many to one tables, how to serialize in that table (reverse query)
The function parameters of the new features of ES6 are assigned initial values and rest parameters
Meeting notice of OA project (Query & whether to attend the meeting & feedback details)
Solve the delay in opening the console of Google browser
3. Solve pychart's error unresolved reference 'selenium' unresolved reference 'webdriver‘
HCIP BGP
There is a special cryptology language called asn.1
CUB_200鸟类数据集关键点可视化
Use case of arrow function of new features in ES6
Deep understanding of browser caching mechanism (HTTP)
UCOS task switching process
Lucifer 98 life record ing
Form verification of landline
店铺排名问题,如何解决?
CUB_ Visualization of key points in 200 bird dataset
Typescript from getting started to mastering (XXIII) namespace namespace (Part 2)
1. Mx6u driver development-2-led driver
With more than 5 years of work experience and a salary of 15K, would you accept it if you were me?
SQL语句 关于字段转换怎么写