current position:Home>[Introduction to mmaction2] slowfast training configuration log analysis test result analysis

[Introduction to mmaction2] slowfast training configuration log analysis test result analysis

2022-08-06 19:36:49CV-Yang Fan

需要下载的资源(免费):
22-8-6 mmaction2 slowfast训练配置 Training log analysis:https://download.csdn.net/download/WhiffeYF/86339417

b站:https://www.bilibili.com/video/BV16B4y1474U

before starting this blog,you need to be able tommaction2上用slowfast训练数据集(or use a custom dataset),In my previous blog relevant tutorial:

自定义avaDataset and train and test 完整版 space-time action/行为 Video dataset production yolov5, deep sort, VIA MMAction, SlowFast

【mmaction2 slowfast 行为分析(商用级别)】总目录

0 参考资料

MMAction2 学习笔记 (四)——实用工具及demo演示:https://blog.csdn.net/Jason_____Wang/article/details/121488466

mmaction2官网_日志分析:https://mmaction2.readthedocs.io/zh_CN/latest/useful_tools.html#id2

mmaction2官网_训练配置:https://mmaction2.readthedocs.io/zh_CN/latest/getting_started.html#id10

mmaction2官网_如何编写配置文件:https://mmaction2.readthedocs.io/zh_CN/latest/tutorials/1_config.html#id7

1 GPU平台

使用的AIThe construction of the pole chain platform:https://cloud.videojj.com/auth/register?inviter=18452&activityChannel=student_invite

2 训练配置(Training setting)

对日志的分析,Of course you need to train first.,In order to get a more detailed and comprehensive training log,我们需要先知道,What are the configurations for training?

2.1 The training configuration document of the official website

在mmaction2的中训练配置(Most of the following are copied from the documentation on the official website,If there is a Chinese-English bibliography, I copied it)

所有的输出(log file and model weights file)will be saved to the working directory.Working directory via parameter in config file work_dir 指定.

All outputs (log files and checkpoints) will be saved to the working directory, which is specified by work_dir in the config file.

默认情况下,MMAction2 The model is evaluated on the validation set after each epoch,Can be modified through configuration in training interval 参数来更改评估间隔

By default we evaluate the model on the validation set after each epoch, you can change the evaluation interval by modifying the interval argument in the training config

evaluation = dict(interval=5)  # This evaluate the model per 5 epoch.

上面这段代码在(其中一个config):https://github.com/open-mmlab/mmaction2/blob/master/configs/detection/ava/slowfast_context_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.py

在这里插入图片描述
根据 Linear Scaling Rule,当 GPU quantity or each GPU The video on the batch size changes,User can scale proportionally to batch size学习率,如,当 4 GPUs x 2 video/gpu 时,lr=0.01;当 16 GPUs x 4 video/gpu 时,lr=0.08.

According to the Linear Scaling Rule, you need to set the learning rate proportional to the batch size if you use different GPUs or videos per GPU, e.g., lr=0.01 for 4 GPUs x 2 video/gpu and lr=0.08 for 16 GPUs x 4 video/gpu.

python tools/train.py ${CONFIG_FILE} [optional arguments]

Next, let's talk about optional parameters(Optional arguments):

  • --validate (强烈建议):During training every k Verify once every cycle(默认值为 5,by modifying the evaluation 字典变量的 interval 值进行改变).
    --validate (strongly recommended): Perform evaluation at every k (default value is 5, which can be modified by changing the interval value in evaluation dict in each config file) epochs during the training.
  • --test-last:Use the parameters of the last checkpoint to test after training,Store test results in ${WORK_DIR}/last_pred.pkl 中.
    --test-last: Test the final checkpoint when training is over, save the prediction to ${WORK_DIR}/last_pred.pkl.
  • --test-best:Test with the parameters of the best performing checkpoint after training,Store test results in ${WORK_DIR}/best_pred.pkl 中.
    --test-best: Test the best checkpoint when training is over, save the prediction to ${WORK_DIR}/best_pred.pkl.
  • --work-dir ${WORK_DIR}:覆盖配置文件中指定的工作目录.
    --work-dir ${WORK_DIR}: Override the working directory specified in the config file.
  • --resume-from ${CHECKPOINT_FILE}:Resume training from previous model weights file.
    --resume-from ${CHECKPOINT_FILE}: Resume from a previous checkpoint file.

resume-from 和 load-from 的不同点: resume-from Load model parameters and optimizer states,and keep the number of cycles the checkpoint is in,Often used to resume training that was accidentally interrupted. load-from 只加载模型参数,but the number of cycles from 0 开始计数,Often used to fine-tune models.

Difference between resume-from and load-from: resume-from loads both the model weights and optimizer status, and the epoch is also inherited from the specified checkpoint. It is usually used for resuming the training process that is interrupted accidentally. load-from only loads the model weights and the training epoch starts from 0. It is usually used for finetuning.

2.2 Analysis of the configuration file system of the spatiotemporal motion detection of the official website(Config System for Spatio-Temporal Action Detection)

The official website copied from this section,because the config file I'm using,Almost the same as the website,So directly use the analysis of the official website.

以 FastRCNN 为例

An Example of FastRCNN

# 模型设置 model setting
model = dict(  # 模型的配置 Config of the model
    type='FastRCNN',  # spatiotemporal detector type Type of the detector
    backbone=dict(  # Backbone 字典设置 Dict for backbone
        type='ResNet3dSlowOnly',  # Backbone 名 Name of the backbone
        depth=50, # ResNet 模型深度 Depth of ResNet model 
        pretrained=None,   # 预训练模型的 url or file location The url/site of the pretrained model
        pretrained2d=False, # Whether the pretrained model is 2D 模型 If the pretrained model is 2D
        lateral=False,  # backbone Is there a side connection If the backbone is with lateral connections
        num_stages=4, # ResNet 模型阶数 Stages of ResNet model
        conv1_kernel=(1, 7, 7), # Conv1 卷积核尺寸 Conv1 kernel size
        conv1_stride_t=1, # Conv1 时序步长 Conv1 temporal stride
        pool1_stride_t=1, # Pool1 时序步长 Pool1 temporal stride
        spatial_strides=(1, 2, 2, 1)),  # 每个 ResNet order space step The spatial stride for each ResNet stage
    roi_head=dict(  # roi_head 字典设置 Dict for roi_head
        type='AVARoIHead',  # roi_head 名 Name of the roi_head
        bbox_roi_extractor=dict(  # bbox_roi_extractor 字典设置 Dict for bbox_roi_extractor
            type='SingleRoIExtractor3D',  # bbox_roi_extractor 名  Name of the bbox_roi_extractor
            roi_layer_type='RoIAlign',  # RoI op 类型 Type of the RoI op
            output_size=8,  # RoI op 输出特征尺寸 Output feature size of the RoI op
            with_temporal_pool=True), # Whether the timing dimension is to be pooled If temporal dim is pooled
        bbox_head=dict( # bbox_head 字典设置 Dict for bbox_head
            type='BBoxHeadAVA', # bbox_head 名 Name of the bbox_head
            in_channels=2048, # 输入特征通道数 Number of channels of the input feature
            num_classes=81, # 动作类别数 + 1(背景) Number of action classes + 1
            multilabel=True,  # Whether the dataset is multi-label If the dataset is multilabel
            dropout_ratio=0.5)),  # dropout 比率 The dropout ratio used
    # Setup for model training and testing model training and testing settings
    train_cfg=dict(  # 训练 FastRCNN The hyperparameter configuration of Training config of FastRCNN
        rcnn=dict(  # rcnn training dictionary settings Dict for rcnn training config
            assigner=dict(  # assigner 字典设置 Dict for assigner
                type='MaxIoUAssignerAVA', # assigner 名 Name of the assigner
                pos_iou_thr=0.9,  # 正样本 IoU 阈值, > pos_iou_thr -> positive ,IoU threshold for positive examples, > pos_iou_thr -> positive
                neg_iou_thr=0.9,  # 负样本 IoU 阈值, < neg_iou_thr -> negative,IoU threshold for negative examples, < neg_iou_thr -> negative
                min_pos_iou=0.9), # Positive sample minimum acceptable IoU Minimum acceptable IoU for positive examples
            sampler=dict( # sample 字典设置 Dict for sample
                type='RandomSampler', # sampler 名 Name of the sampler
                num=32, # sampler 批大小 Batch Size of the sampler
                pos_fraction=1, # sampler Positive bounding box ratio Positive bbox fraction of the sampler
                neg_pos_ub=-1,  # The upper bound of the ratio of negative samples to positive samples Upper bound of the ratio of num negative to num positive
                add_gt_as_proposals=True), # 是否添加 ground truth 为候选  Add gt bboxes as proposals
            pos_weight=1.0, # 正样本 loss 权重 Loss weight of positive examples
            debug=False)), # 是否为 debug 模式 Debug mode
    test_cfg=dict( # 测试 FastRCNN hyperparameter settings Testing config of FastRCNN
        rcnn=dict(  # rcnn Test dictionary settings Dict for rcnn testing config
            action_thr=0.002))) # The threshold of a behavior The threshold of an action

# 数据集设置 dataset settings
dataset_type = 'AVADataset' # 训练,验证,Types of datasets tested Type of dataset for training, validation and testing
data_root = 'data/ava/rawframes'  # 训练集的根目录 Root path to data
anno_root = 'data/ava/annotations'  # Annotation file directory Root path to annotations

ann_file_train = f'{anno_root}/ava_train_v2.1.csv'  # 训练集的标注文件 Path to the annotation file for training
ann_file_val = f'{anno_root}/ava_val_v2.1.csv'  # 验证集的标注文件 Path to the annotation file for validation

exclude_file_train = f'{anno_root}/ava_train_excluded_timestamps_v2.1.csv'  # The path to the dataset file except for training Path to the exclude annotation file for training
exclude_file_val = f'{anno_root}/ava_val_excluded_timestamps_v2.1.csv'  # Validation Excluded Dataset File Path Path to the exclude annotation file for validation

label_file = f'{anno_root}/ava_action_list_v2.1_for_activitynet_2018.pbtxt'  # 标签文件路径 Path to the label file

proposal_file_train = f'{anno_root}/ava_dense_proposals_train.FAIR.recall_93.9.pkl'  # The file path of the training sample detection candidate box Path to the human detection proposals for training examples
proposal_file_val = f'{anno_root}/ava_dense_proposals_val.FAIR.recall_93.9.pkl'  # The file path of the verification sample detection candidate box Path to the human detection proposals for validation examples

img_norm_cfg = dict(  # Image regularization parameter settings Config of image normalization used in data pipeline
    mean=[123.675, 116.28, 103.53], # Image Regularization Average Mean values of different channels to normalize
    std=[58.395, 57.12, 57.375],   # Image regularization variance Std values of different channels to normalize
    to_bgr=False) # Whether to change the number of channels from RGB 转为 BGR Whether to convert channels from RGB to BGR

train_pipeline = [  # A list of steps in the preprocessing pipeline for training data List of training pipeline steps
    dict(  # SampleFrames 类的配置  Config of SampleFrames 
        type='AVASampleFrames',  # Select which video frames to sample Sample frames pipeline, sampling frames from video
        clip_len=4,  # frames per output video clip Frames of each sampled output clip
        frame_interval=16), # Timing interval between adjacent frames taken Temporal interval of adjacent sampled frames
    dict(  # RawFrameDecode 类的配置 Config of RawFrameDecode
        type='RawFrameDecode'),  # given frame sequence,load the corresponding frame,decode the corresponding frame Load and decode Frames pipeline, picking raw frames with given indices
    dict(  # RandomRescale 类的配置 Config of RandomRescale
        type='RandomRescale',   # 给定一个范围,Do random short edge scaling Randomly rescale the shortedge by a given range
        scale_range=(256, 320)),   # RandomRescale The short-edge zoom range of The shortedge size range of RandomRescale
    dict(  # RandomCrop 类的配置 Config of RandomCrop
        type='RandomCrop',   # Random crop given a size Randomly crop a patch with the given size
        size=256),   # 裁剪尺寸 The size of the cropped patch
    dict(  # Flip 类的配置 Config of Flip
        type='Flip',  # 图片翻转 Flip Pipeline
        flip_ratio=0.5),  # Perform flip odds Probability of implementing flip
    dict(  # Normalize 类的配置 Config of Normalize
        type='Normalize',  # image regularization Normalize pipeline
        **img_norm_cfg),  # Image regularization parameters Config of image normalization
    dict(  # FormatShape 类的配置 Config of FormatShape
        type='FormatShape',  # Convert the image format to the given input format Format shape pipeline, Format final image shape to the given input_format
        input_format='NCTHW',  # final image composition format Final image shape format
        collapse=True),   # 去掉 N gradient when N == 1 Collapse the dim N if N == 1
    dict(  # Rename 类的配置 Config of Rename
        type='Rename',  # 重命名 key 名 Rename keys
        mapping=dict(imgs='img')),  # rename mapping dictionary The old name to new name mapping
    dict(  # ToTensor 类的配置 Config of ToTensor
        type='ToTensor',  # ToTensor class converts other types to Tensor 类型 Convert other types to tensor type pipeline
        keys=['img', 'proposals', 'gt_bboxes', 'gt_labels']),  # will be converted from other types to Tensor 类型的特征 Keys to be converted from image to tensor
    dict(  # ToDataContainer 类的配置 Config of ToDataContainer
        type='ToDataContainer',  # transfer some information to ToDataContainer 中 Convert other types to DataContainer type pipeline
        fields=[   # 转化为 Datacontainer 的域 Fields to convert to DataContainer
            dict(   # domain dictionary Dict of fields
                key=['proposals', 'gt_bboxes', 'gt_labels'],  # 将转化为 DataContainer 的键 Keys to Convert to DataContainer
                stack=False)]),  # Whether to heap of these tensor Whether to stack these tensor
    dict(  # Collect 类的配置 Config of Collect
        type='Collect',  # Collect The class determines which keys will be passed to the spatiotemporal detector Collect pipeline that decides which keys in the data should be passed to the detector
        keys=['img', 'proposals', 'gt_bboxes', 'gt_labels'],  # 输入的键 Keys of input ,Keys of input
        meta_keys=['scores', 'entity_ids']),  # Entered meta key Meta keys of input
]

val_pipeline = [  # Validate a list of data preprocessing pipeline steps List of validation pipeline steps
    dict(  # SampleFrames 类的配置 Config of SampleFrames
        type='AVASampleFrames',  # Select which video frames to sample Sample frames pipeline, sampling frames from video
        clip_len=4,  # frames per output video clip Frames of each sampled output clip
        frame_interval=16),  # Timing interval between adjacent frames taken Temporal interval of adjacent sampled frames
    dict(  # RawFrameDecode 类的配置 Config of RawFrameDecode
        type='RawFrameDecode'),  # given frame sequence,load the corresponding frame,decode the corresponding frame Load and decode Frames pipeline, picking raw frames with given indices
    dict(  # Resize 类的配置 Config of Resize
        type='Resize',  # 调整图片尺寸 Resize pipeline
        scale=(-1, 256)),  # 调整比例 The scale to resize images
    dict(  # Normalize 类的配置 Config of Normalize
        type='Normalize',  # image regularization Normalize pipeline
        **img_norm_cfg),  # Image regularization parameters Config of image normalization
    dict(  # FormatShape 类的配置 Config of FormatShape
        type='FormatShape',  # Convert the image format to the given input format Format shape pipeline, Format final image shape to the given input_format
        input_format='NCTHW',  # final image composition format Final image shape format
        collapse=True),   # 去掉 N gradient when N == 1 Collapse the dim N if N == 1
    dict(  # Rename 类的配置 Config of Rename
        type='Rename',  # 重命名 key 名 Rename keys
        mapping=dict(imgs='img')),  # rename mapping dictionary The old name to new name mapping
    dict(  # ToTensor 类的配置 Config of ToTensor
        type='ToTensor',  # ToTensor class converts other types to Tensor 类型 Convert other types to tensor type pipeline
        keys=['img', 'proposals']),  # will be converted from other types to Tensor 类型的特征 Keys to be converted from image to tensor
    dict(  # ToDataContainer 类的配置 Config of ToDataContainer ,Convert other types to DataContainer type pipeline
        type='ToDataContainer',  # transfer some information to ToDataContainer 中 
        fields=[   # 转化为 Datacontainer 的域
            dict(   # domain dictionary
                key=['proposals'],  # 将转化为 DataContainer 的键
                stack=False)]),  # Whether to heap of these tensor
    dict(  # Collect 类的配置
        type='Collect',  # Collect The class determines which keys will be passed to the spatiotemporal detector
        keys=['img', 'proposals'],  # 输入的键
        meta_keys=['scores', 'entity_ids'],  # Entered meta key
        nested=True)  # whether to wrap the data as a nested list
]

data = dict(  # 数据的配置
    videos_per_gpu=16,  # 单个 GPU 的批大小
    workers_per_gpu=2,  # 单个 GPU 的 dataloader 的进程
    val_dataloader=dict(   # 验证过程 dataloader extra settings
        videos_per_gpu=1),  # 单个 GPU 的批大小
    train=dict(   # Settings for the training dataset
        type=dataset_type,
        ann_file=ann_file_train,
        exclude_file=exclude_file_train,
        pipeline=train_pipeline,
        label_file=label_file,
        proposal_file=proposal_file_train,
        person_det_score_thr=0.9,
        data_prefix=data_root),
    val=dict(     # Validation dataset settings
        type=dataset_type,
        ann_file=ann_file_val,
        exclude_file=exclude_file_val,
        pipeline=val_pipeline,
        label_file=label_file,
        proposal_file=proposal_file_val,
        person_det_score_thr=0.9,
        data_prefix=data_root))
data['test'] = data['val']    # Copy validation dataset settings to test dataset settings

# 优化器设置
optimizer = dict(
    # Build the optimizer Settings,支持:
    # (1) 所有 PyTorch native optimizer,The parameters of these optimizers and PyTorch 对应的一致;
    # (2) custom optimizer,These optimizers are `constructor` 的基础上构建.
    # 更多细节可参考 "tutorials/5_new_modules.md" 部分
    type='SGD',  # 优化器类型, 参考 https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/optimizer/default_constructor.py#L13
    lr=0.2,  # 学习率, For details on the use of parameters, please refer to PyTorch the corresponding documentation
    momentum=0.9,  # Momentum size
    weight_decay=0.00001)  # SGD optimizer weight decay

optimizer_config = dict(  # Settings for building optimizer hooks
    grad_clip=dict(max_norm=40, norm_type=2))   # 使用梯度裁剪

lr_config = dict(  # Settings for registering learning rate adjustment hooks
    policy='step',  # Adjuster Policy, 支持 CosineAnnealing,Cyclic等方法.更多细节可参考 https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/hooks/lr_updater.py#L9
    step=[40, 80],  # learning rate decay step size
    warmup='linear',  # Warmup 策略
    warmup_by_epoch=True,  # Warmup 单位为 epoch 还是 iteration
    warmup_iters=5,   # warmup 数
    warmup_ratio=0.1)   # 初始学习率为 warmup_ratio * lr

total_epochs = 20  # The total number of epochs to train the model
checkpoint_config = dict(  # Model Weights File Hook Settings,更多细节可参考 https://github.com/open-mmlab/mmcv/blob/master/mmcv/runner/hooks/checkpoint.py
    interval=1)   # Model weights file save interval
workflow = [('train', 1)]   # runner 的执行流. [('train', 1)] Represent only a execution flow,and this named train The execution flow is executed only once
evaluation = dict(  # Do validation set during the training period
    interval=1, save_best='[email protected]')  # The interval at which validation is performed,以及设置 `[email protected]` 作为指示器,Used to store the best weights model file
log_config = dict(  # Register settings for logging hooks
    interval=20,  # 打印日志间隔
    hooks=[  # Hooks executed during training
        dict(type='TextLoggerHook'),  # A log that records information about the training process
    ])

# 运行设置
dist_params = dict(backend='nccl')  # Setting up for distributed training,The port number can also be set
log_level = 'INFO'  # 日志等级
work_dir = ('./work_dirs/ava/'  # Folder where the current experiment log and model weights files are recorded
            'slowonly_kinetics_pretrained_r50_4x16x1_20e_ava_rgb')
load_from = ('https://download.openmmlab.com/mmaction/recognition/slowonly/'  # As the training model from a given path load model. This option will not be used to resume training from breakpoints
             'slowonly_r50_4x16x1_256e_kinetics400_rgb/'
             'slowonly_r50_4x16x1_256e_kinetics400_rgb_20200704-a69556c6.pth')
resume_from = None  # Loads the model weights file at the given path as a breakpoint continuation model, Training will continue from the epoch point saved at that point in time

2.3 my training configuration

I use a singleGPU上的指令如下:

cd /home/MPCLST/mmaction2_YF
python tools/train.py configs/detection/ava/my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.py --validate

其中
/home/MPCLST/mmaction2_YF为mmation2的地址
configs/detection/ava/my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.pyfor the configuration file address

如果出现中断,You can use the command to continue training:

cd /home/MPCLST/mmaction2_YF
python tools/train.py configs/detection/ava/my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.py --validate --resume-from ./work_dirs/ava2/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb/latest.pth --validate

I will talk about the configuration file after training here.csdn中,供大家下载使用(免费)

22-8-6 mmaction2 slowfast训练配置 Training log analysis:https://download.csdn.net/download/WhiffeYF/86339417

包含配置文件:
训练日志:20220805_165139.log.json
训练配置:my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.py
训练配置(In order to test the effect of training set):my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb2.py

Then tell me where I modified the training configuration file:
First modify the number of categories,my action category71个,所有num_classes = 动作类别数 + 1(背景) = 72
在这里插入图片描述
在data中也要加入num_classes,因为默认的是80,不添加的话,Training occurs dimensions do not match.
在这里插入图片描述

data_root、anno_root Modified to the location of the custom dataset
在这里插入图片描述

3 日志分析

3.1 Official website log analysis tutorial

The official website gives multiple log analysis codes:https://mmaction2.readthedocs.io/zh_CN/latest/useful_tools.html#id2

The input variable specifies a training log file,可通过 tools/analysis/analyze_logs.py 脚本绘制 loss/top-k 曲线.This function depends on seaborn,Please pass before use pip install seaborn 安装依赖包.

tools/analysis/analyze_logs.py plots loss/top-k acc curves given a training log file. Run pip install seaborn first to install the dependency.
在这里插入图片描述

python tools/analysis/analyze_logs.py plot_curve ${JSON_LOGS} [--keys ${KEYS}] [--title ${TITLE}] [--legend ${LEGEND}] [--backend ${BACKEND}] [--style ${STYLE}] [--out ${OUT_FILE}]

例如(Examples:):

Plot the classification loss curve corresponding to a log file.

Plot the classification loss of some run.

python tools/analysis/analyze_logs.py plot_curve log.json --keys loss_cls --legend loss_cls

Draw a log file corresponding to top-1 和 top-5 Accuracy graph,and export the graph as PDF 文件.

Plot the top-1 acc and top-5 acc of some run, and save the figure to a pdf.

python tools/analysis/analyze_logs.py plot_curve log.json --keys top1_acc top5_acc --out results.pdf

3.2 My log analysis

当然,If you use the code from the official website directly,大概率会报错,因为跑slowfast的训练后,In the generated training log,没有:loss_cls、top-5.
只有:[email protected]、loss_action_cls

3.2.1 错误展示

Examples show an error
执行:

cd /home/MPCLST/mmaction2_YF/   
python ./tools/analysis/analyze_logs.py plot_curve ./work_dirs/avaT2/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb/20220804_141745.log.json \
        --keys loss_cls \
        --legend loss_cls

Then there will be the following error

Traceback (most recent call last):
  File "./tools/analysis/analyze_logs.py", line 176, in <module>
    main()
  File "./tools/analysis/analyze_logs.py", line 172, in main
    eval(args.task)(log_dicts, args)
  File "./tools/analysis/analyze_logs.py", line 61, in plot_curve
    raise KeyError(
KeyError: './work_dirs/avaT2/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb/20220804_141745.log.json does not contain metric loss_cls'

The reason is that there is no training log in the:loss_cls,要换成loss_action_cls

3.2.2 损失曲线图

正确的命令如下:

cd /home/MPCLST/mmaction2_YF/   
python ./tools/analysis/analyze_logs.py plot_curve ./1.log.json \
        --keys loss_action_cls \
        --legend loss_action_cls \
        --out ./Aresults.pdf

其中./1.log.jsonlog for training,原本在:home/MPCLST/mmaction2_YF/work_dirs/ava2/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb/20220805_165139.log.json,I then renamed,将其放在了: /home/MPCLST/mmaction2_YF/ 目录下.
结果如下:
在这里插入图片描述

3.2.3 [email protected] [email protected]曲线

python ./tools/analysis/analyze_logs.py plot_curve ./1.log.json \
        --keys [email protected] [email protected] \
        --out Aresults2.pdf

在这里插入图片描述

3.2.4 [email protected] [email protected]

python ./tools/analysis/analyze_logs.py plot_curve ./1.log.json \
        --keys [email protected] [email protected] \
        --out Aresults3.pdf

在这里插入图片描述

4 测试结果分析

4.1 Analysis of the test set

模型测试(Choose the best model for testing)

cd /home/MPCLST/mmaction2_YF/   
python tools/test.py configs/detection/ava/my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb.py ./work_dirs/ava2/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb/[email protected]_epoch_19.pth --eval mAP

测试结果如下:

[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 77/77, 3.4 task/s, elapsed: 22s, ETA:     0s
Evaluating mAP ...
==> 0.119518 seconds to read file /home/MPCLST/Dataset/annotations/val.csv
==> 0.121228 seconds to Reading detection results
==> 0.243677 seconds to read file AVA_20220806_135555_result.csv
==> 0.24525 seconds to Reading detection results
==> 0.0171266 seconds to Convert groundtruth
==> 1.28865 seconds to convert detections
==> 0.0697978 seconds to run_evaluator
[email protected]=     0.16093717926227658
PerformanceByCategory/[email protected]/eye Invisible=  0.21957583593164443
PerformanceByCategory/[email protected]/eye ohter=      nan
PerformanceByCategory/[email protected]/open eyes=      0.3986643043503887
PerformanceByCategory/[email protected]/close eyes=     0.020177562550443905
PerformanceByCategory/[email protected]/lip Invisible=  0.21175944581786216
PerformanceByCategory/[email protected]/lip ohter=      nan
PerformanceByCategory/[email protected]/open mouth=     0.01958912037037037
PerformanceByCategory/[email protected]/close mouth=    0.48263934087246974
PerformanceByCategory/[email protected]/body Invisible= 0.0
PerformanceByCategory/[email protected]/body other=     0.0
PerformanceByCategory/[email protected]/body sit=       0.30172789978134984
PerformanceByCategory/[email protected]/body side Sit=  0.06424825174825174
PerformanceByCategory/[email protected]/body stand=     0.4350772380337405
PerformanceByCategory/[email protected]/body lying down=        nan
PerformanceByCategory/[email protected]/body bend over= 0.011695906432748537
PerformanceByCategory/[email protected]/body squat=     nan
PerformanceByCategory/[email protected]/body rely=      nan
PerformanceByCategory/[email protected]/body lie flat=  nan
PerformanceByCategory/[email protected]/body lateral=   nan
PerformanceByCategory/[email protected]/left hand invisible=    0.21793355606129478
PerformanceByCategory/[email protected]/left hand other=        nan
PerformanceByCategory/[email protected]/left hand palm grip=    0.2490742588261378
PerformanceByCategory/[email protected]/left hand palm spread=  0.3632941972340388
PerformanceByCategory/[email protected]/left hand palm Point=   0.009846153846153846
PerformanceByCategory/[email protected]/left hand applause=     nan
PerformanceByCategory/[email protected]/left hand write=        nan
PerformanceByCategory/[email protected]/left arm invisible=     0.11782264436125489
PerformanceByCategory/[email protected]/left arm other= nan
PerformanceByCategory/[email protected]/left arm flat=  0.024817518248175185
PerformanceByCategory/[email protected]/left arm droop= 0.18134611163016337
PerformanceByCategory/[email protected]/left arm forward=       0.00874243168057601
PerformanceByCategory/[email protected]/left arm flexion=       0.3574295887923012
PerformanceByCategory/[email protected]/left arm raised=        0.29577938647229507
PerformanceByCategory/[email protected]/left handed behavior object invisible=  0.2231242540734685
PerformanceByCategory/[email protected]/left handed behavior object other=      0.004079634464751958
PerformanceByCategory/[email protected]/left handed behavior object book =      0.0743542109449761
PerformanceByCategory/[email protected]/left handed behavior object exercise book=      0.2824925842529067
PerformanceByCategory/[email protected]/left handed behavior object spare head= 0.0
PerformanceByCategory/[email protected]/left handed behavior object electronic equipment=       0.07692307692307693
PerformanceByCategory/[email protected]/left handed behavior object electronic pointing at others=      0.002242152466367713
PerformanceByCategory/[email protected]/left handed behavior object chalk=      nan
PerformanceByCategory/[email protected]/left handed behavior object no interaction=     0.4987584575529982
PerformanceByCategory/[email protected]/right hand invisible=   0.25949074047589055
PerformanceByCategory/[email protected]/right hand other=       0.01671826625386997
PerformanceByCategory/[email protected]/right hand palm grip=   0.24416659319005685
PerformanceByCategory/[email protected]/right hand palm spread= 0.32756514114018953
PerformanceByCategory/[email protected]/right hand palm Point=  0.0005482456140350877
PerformanceByCategory/[email protected]/right hand applause=    nan
PerformanceByCategory/[email protected]/right hand write=       0.0
PerformanceByCategory/[email protected]/right arm invisible=    0.08796983661655658
PerformanceByCategory/[email protected]/right arm other=        nan
PerformanceByCategory/[email protected]/right arm flat= 0.05728406468574387
PerformanceByCategory/[email protected]/right arm droop=        0.1296277801807914
PerformanceByCategory/[email protected]/right arm forward=      0.0034883720930232558
PerformanceByCategory/[email protected]/right arm flexion=      0.29807071272587105
PerformanceByCategory/[email protected]/right arm raised=       0.11511462192356786
PerformanceByCategory/[email protected]/right handed behavior object invisible= 0.25630071018790945
PerformanceByCategory/[email protected]/right handed behavior object other=     0.04049659611278428
PerformanceByCategory/[email protected]/right handed behavior object book =     0.005098051743325904
PerformanceByCategory/[email protected]/right handed behavior object exercise book=     0.10037713766604955
PerformanceByCategory/[email protected]/right handed behavior object spare head=        0.0
PerformanceByCategory/[email protected]/right handed behavior object electronic equipment=      0.02247191011235955
PerformanceByCategory/[email protected]/right handed behavior object electronic pointing at others=     nan
PerformanceByCategory/[email protected]/right handed behavior object chalk=     nan
PerformanceByCategory/[email protected]/leg invisible=  0.3829590019619401
PerformanceByCategory/[email protected]/leg other=      0.29039130666363366
PerformanceByCategory/[email protected]/leg stand=      0.21725870086796184
PerformanceByCategory/[email protected]/leg run=        0.5045035329108362
PerformanceByCategory/[email protected]/leg walk=       nan
PerformanceByCategory/[email protected]/leg jump=       0.01655405405405405
PerformanceByCategory/[email protected]/leg Kick=       nan

[email protected]       0.1609
[email protected]: 0.1609

4.2 Analysis of the training set

If you want to test the training set,我是采用9:1The way to divide the training and test sets,If you want to calculate the accuracy of each action in the training set,Then modify the configuration file(I also uploaded the modified configuration fileCSDN资源中),如下:
在这里插入图片描述

cd /home/MPCLST/mmaction2_YF/   
python tools/test.py configs/detection/ava/my_slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb2.py ./work_dirs/ava2/slowfast_kinetics_pretrained_r50_4x16x1_20e_ava_rgb/[email protected]_epoch_19.pth --eval mAP
[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>] 726/726, 3.5 task/s, elapsed: 206s, ETA:     0s
Evaluating mAP ...
==> 1.46952 seconds to read file /home/MPCLST/Dataset/annotations/train.csv
==> 1.48599 seconds to Reading detection results
==> 0.842957 seconds to read file AVA_20220806_140626_result.csv
==> 0.851932 seconds to Reading detection results
==> 0.196215 seconds to Convert groundtruth
==> 11.8547 seconds to convert detections
==> 0.54392 seconds to run_evaluator
[email protected]=     0.19678775434136514
PerformanceByCategory/[email protected]/eye Invisible=  0.12645567913113967
PerformanceByCategory/[email protected]/eye ohter=      0.0
PerformanceByCategory/[email protected]/open eyes=      0.31708135334566584
PerformanceByCategory/[email protected]/close eyes=     0.25428730997649285
PerformanceByCategory/[email protected]/lip Invisible=  0.11397992971416905
PerformanceByCategory/[email protected]/lip ohter=      0.0
PerformanceByCategory/[email protected]/open mouth=     0.37103021706235095
PerformanceByCategory/[email protected]/close mouth=    0.3225470046664377
PerformanceByCategory/[email protected]/body Invisible= 0.0688460870946835
PerformanceByCategory/[email protected]/body other=     4.749240121580547e-05
PerformanceByCategory/[email protected]/body sit=       0.14118405291274552
PerformanceByCategory/[email protected]/body side Sit=  0.12306737241061394
PerformanceByCategory/[email protected]/body stand=     0.44386059216886853
PerformanceByCategory/[email protected]/body lying down=        0.0
PerformanceByCategory/[email protected]/body bend over= 0.036801890481544024
PerformanceByCategory/[email protected]/body squat=     0.0002886836027713626
PerformanceByCategory/[email protected]/body rely=      0.0022123893805309734
PerformanceByCategory/[email protected]/body lie flat=  nan
PerformanceByCategory/[email protected]/body lateral=   nan
PerformanceByCategory/[email protected]/left hand invisible=    0.09974807472439347
PerformanceByCategory/[email protected]/left hand other=        0.001987585502739207
PerformanceByCategory/[email protected]/left hand palm grip=    0.3573117900804288
PerformanceByCategory/[email protected]/left hand palm spread=  0.18167205413859483
PerformanceByCategory/[email protected]/left hand palm Point=   0.000757983615530252
PerformanceByCategory/[email protected]/left hand applause=     0.014035087719298246
PerformanceByCategory/[email protected]/left hand write=        0.08771929824561403
PerformanceByCategory/[email protected]/left arm invisible=     0.07325714077918277
PerformanceByCategory/[email protected]/left arm other= 0.029137529137529143
PerformanceByCategory/[email protected]/left arm flat=  0.20194234035277414
PerformanceByCategory/[email protected]/left arm droop= 0.3086699563592321
PerformanceByCategory/[email protected]/left arm forward=       0.11754773840177281
PerformanceByCategory/[email protected]/left arm flexion=       0.24046255259110355
PerformanceByCategory/[email protected]/left arm raised=        0.184117174890788
PerformanceByCategory/[email protected]/left handed behavior object invisible=  0.09916514173053004
PerformanceByCategory/[email protected]/left handed behavior object other=      0.3480829069492257
PerformanceByCategory/[email protected]/left handed behavior object book =      0.24313614492470254
PerformanceByCategory/[email protected]/left handed behavior object exercise book=      0.3713436674317362
PerformanceByCategory/[email protected]/left handed behavior object spare head= 0.002527731022507281
PerformanceByCategory/[email protected]/left handed behavior object electronic equipment=       0.6424483333669451
PerformanceByCategory/[email protected]/left handed behavior object electronic pointing at others=      0.9166666666666666
PerformanceByCategory/[email protected]/left handed behavior object chalk=      0.007552439580483356
PerformanceByCategory/[email protected]/left handed behavior object no interaction=     0.29060548802833236
PerformanceByCategory/[email protected]/right hand invisible=   0.09377881522755799
PerformanceByCategory/[email protected]/right hand other=       0.0033517656341853688
PerformanceByCategory/[email protected]/right hand palm grip=   0.2675440929295684
PerformanceByCategory/[email protected]/right hand palm spread= 0.22916889434576543
PerformanceByCategory/[email protected]/right hand palm Point=  0.2314629790615565
PerformanceByCategory/[email protected]/right hand applause=    0.09659090909090909
PerformanceByCategory/[email protected]/right hand write=       0.1866609886273387
PerformanceByCategory/[email protected]/right arm invisible=    0.06665292677403056
PerformanceByCategory/[email protected]/right arm other=        0.011404900405429227
PerformanceByCategory/[email protected]/right arm flat= 0.21954392879903079
PerformanceByCategory/[email protected]/right arm droop=        0.32872736315242523
PerformanceByCategory/[email protected]/right arm forward=      0.21775369133876343
PerformanceByCategory/[email protected]/right arm flexion=      0.21354090936404324
PerformanceByCategory/[email protected]/right arm raised=       0.1777483934967737
PerformanceByCategory/[email protected]/right handed behavior object invisible= 0.09563145964560554
PerformanceByCategory/[email protected]/right handed behavior object other=     0.1686719897439452
PerformanceByCategory/[email protected]/right handed behavior object book =     0.20026198746897292
PerformanceByCategory/[email protected]/right handed behavior object exercise book=     0.22472998828422455
PerformanceByCategory/[email protected]/right handed behavior object spare head=        0.01862149451754349
PerformanceByCategory/[email protected]/right handed behavior object electronic equipment=      0.6060217155637195
PerformanceByCategory/[email protected]/right handed behavior object electronic pointing at others=     0.675430576100219
PerformanceByCategory/[email protected]/right handed behavior object chalk=     0.25698651260273714
PerformanceByCategory/[email protected]/leg invisible=  0.33954092884900344
PerformanceByCategory/[email protected]/leg other=      0.13399553314977775
PerformanceByCategory/[email protected]/leg stand=      0.3200153849107191
PerformanceByCategory/[email protected]/leg run=        0.5807052855820038
PerformanceByCategory/[email protected]/leg walk=       nan
PerformanceByCategory/[email protected]/leg jump=       0.07865124561627221
PerformanceByCategory/[email protected]/leg Kick=       nan

[email protected]       0.1968
[email protected]: 0.1968

copyright notice
author[CV-Yang Fan],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/218/202208061856133305.html

Random recommended