主頁 >  其他 > 【slowfast 損失函式改進】深度學習網路通用改進方案:slowfast的損失函式(使用focal loss解決不平衡資料)改進

【slowfast 損失函式改進】深度學習網路通用改進方案:slowfast的損失函式(使用focal loss解決不平衡資料)改進

2021-11-05 09:28:54 其他

目錄

  • 引言
  • 二,專案搭建
    • 2.1 平臺選擇
    • 2.2 開始搭建
  • 三,資料集
    • 3.1 資料集下載
    • 3.2 上傳資料集
    • 3.3 資料集的統計
  • 四,專案運行
    • 4.1 focal loss
    • 4.2 訓練前準備
    • 4.3 slowfast對資料集訓練
    • 4.4 改進的slowfast對資料集訓練
    • 4.5 實驗對比
    • 4.6 實時查看GPU使用情況

引言

我最近一個月都在寫論文,反反復復改了不下20次,我覺得還是寫博客舒服,只要把思路寫清楚就可以,不用在乎用詞和語法問題,

本文所寫的改進方案適合資料集中資料存在不平衡的情況,資料越失衡,效果越好,

二,專案搭建

使用的專案的例子就用我之前的slowfast專案:
01【mmaction2 slowfast 行為分析(商用級別)】專案下載
02【mmaction2 slowfast 行為分析(商用級別)】專案demo搭建

2.1 平臺選擇

我還是用極鏈AI
創建實體:
在這里插入圖片描述
在這里插入圖片描述

2.2 開始搭建

進入home

cd home

下載專案

git clone https://github.com/Wenhai-Zhu/JN-OpenLib-mmaction2.git

或者用碼云(國內速度快)

git clone https://gitee.com/YFwinston/JN-OpenLib-mmaction2.git

在這里插入圖片描述
環境搭建

pip install mmcv-full==1.2.7 -f https://download.openmmlab.com/mmcv/dist/cu102/torch1.6.0/index.html

pip install mmpycocotools

pip install moviepy  opencv-python terminaltables seaborn decord -i https://pypi.douban.com/simple

進入JN-OpenLib-mmaction2

cd JN-OpenLib-mmaction2/
python setup.py develop

注意:上面的 cu102/torch1.6.0 一定要和創建環境的配置一直,cuda版本,torch版本

三,資料集

3.1 資料集下載

我們先在AI云平臺上創建上傳資料集,這個資料集是一個監控打架的資料集

鏈接: https://pan.baidu.com/s/1wI7PVB9g5k6CcVDOfICW7A 提取碼: du5o

這個資料集有6個動作分類:

options={'0':'None','1':'handshake', '2':'point', '3':'hug', '4':'push','5':'kick', '6':'punch'}

3.2 上傳資料集

我們要把資料集放到資料AI云平臺的資料管理的位置,放在這個位置,方便我們創建的所有實體的使用,

在根目錄下,進入user-data

cd user-data

創建slowfastDataSet檔案夾

mkdir slowfastDataSet

上傳資料集:采用下面鏈接對應的方法
https://cloud.videojj.com/help/docs/data_manage.html#vcloud-oss-cli
在這里插入圖片描述
資料集上傳到slowfastDataSet檔案夾下
在這里插入圖片描述
在這里插入圖片描述

3.3 資料集的統計

使用本文的改進方案,最重要的就是確保這個資料集是不平衡的,所以,我們來對這個資料集每個類別進行資料統計,看看資料集是不是不平衡的,

我們在AI平臺上創建一個notebook(要在這里面寫資料集統計代碼)
在這里插入圖片描述

重命名為dataTemp.ipynb
在這里插入圖片描述
代碼如下:

import json
#統計資料集中訓練集/測驗集的資料分布
file_dir = "/user-data/slowfastDataSet/Datasets/Interaction/annotations/train/"
#file_dir = "/user-data/slowfastDataSet/Datasets/Interaction/annotations/test/"

#訓練集/測驗集下檔案名字
names = ['seq1','seq2','seq3','seq4','seq6','seq7','seq8','seq9','seq11','seq12',
         'seq13','seq14','seq16','seq17','seq18','seq19']
#names = ['seq5','seq10','seq15','seq20']

#動作類別統計
action1=0
action2=0
action3=0
action4=0
action5=0
action6=0

#開始統計
for name in names:
    file_name = file_dir + name + '.json'
    f = open(file_name, encoding='utf-8')
    setting = json.load(f)  # 把json檔案轉化為python用的型別
    f.close()



    for file_1 in setting['metadata']:
        str = file_1.split("_")
        if str[1].isdigit():
            action = setting['metadata'][file_1]['av']['1']
            actions = action.split(",")
            if '1' in actions:
                action1 = 1 + action1
            if '2' in actions:
                action2 = 1 + action2
            if '3' in actions:
                action3 = 1 + action3
            if '4' in actions:
                action4 = 1 + action4
            if '5' in actions:
                action5 = 1 + action5
            if '6' in actions:
                action6 = 1 + action6

print("action1",action1)
print("action2",action2)
print("action3",action3)
print("action4",action4)
print("action5",action5)
print("action6",action6)

當我們對訓練集進行統計時:
結果:

action1 1011
action2 709
action3 757
action4 358
action5 250
action6 320

當我們對測驗集進行統計時:
結果:

action1 243
action2 132
action3 209
action4 95
action5 64
action6 94

我們在用excel,把這些圖用圖表的形式展示出來,
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
從上面統計資料來看,可以判斷這個資料集是不平衡的,

四,專案運行

4.1 focal loss

簡而言之,focal loss的作用就是將預測值低的類,賦予更大的損失函式權重,在不平衡的資料中,難分類別的預測值低,那么這些難分樣本的損失函式被賦予的權重就更大,
在這里插入圖片描述

4.2 訓練前準備

創建鏈接 /user-data/slowfastDataSet/Datasets 檔案夾的軟鏈接:
先進入JN-OpenLib-mmaction2

cd JN-OpenLib-mmaction2

創建軟鏈接

ln -s /user-data/slowfastDataSet/Datasets  data

在這里插入圖片描述

4.3 slowfast對資料集訓練

python tools/train.py configs/detection/via3/my_slowfast_kinetics_pretrained_r50_8x8x1_20e_via3_rgb.py --validate

在這里插入圖片描述
在這里插入圖片描述
這里紅色框出來的地方代表訓練剩余時間

4.4 改進的slowfast對資料集訓練

修改slowfast損失函式的位置:home/JN-OpenLib-mmaction2/mmaction/models/heads/bbox_head.py

在這里插入圖片描述

class F_BCE(nn.Module):
    def __init__(self, pos_weight=1, reduction='mean'):
        super(F_BCE, self).__init__()
        self.pos_weight = pos_weight
        self.reduction = reduction

    def forward(self, logits, target):
        # logits: [N, *], target: [N, *]
        logits = F.sigmoid(logits)

        loss = - self.pos_weight * target * (1-logits)**2 * torch.log(logits) - \
               (1 - target) * logits**2 * torch.log(1 - logits)
        
        if self.reduction == 'mean':
            loss = loss.mean()
        elif self.reduction == 'sum':
            loss = loss.sum()
        return loss

在這里插入圖片描述

        self.f_bce = F_BCE()
        self.BN = nn.BatchNorm1d(8)

在這里插入圖片描述

            cls_score = self.BN(cls_score)

            f_bce_loss = self.f_bce
            losses['loss_action_cls'] = f_bce_loss(cls_score, labels)

在這里插入圖片描述
bbox_head.py完整代碼如下:

import torch
import torch.nn as nn
import torch.nn.functional as F

from mmaction.core.bbox import bbox_target

try:
    from mmdet.models.builder import HEADS as MMDET_HEADS
    mmdet_imported = True
except (ImportError, ModuleNotFoundError):
    mmdet_imported = False
class F_BCE(nn.Module):
    def __init__(self, pos_weight=1, reduction='mean'):
        super(F_BCE, self).__init__()
        self.pos_weight = pos_weight
        self.reduction = reduction

    def forward(self, logits, target):
        # logits: [N, *], target: [N, *]
        logits = F.sigmoid(logits)

        loss = - self.pos_weight * target * (1-logits)**2 * torch.log(logits) - \
               (1 - target) * logits**2 * torch.log(1 - logits)
        
        if self.reduction == 'mean':
            loss = loss.mean()
        elif self.reduction == 'sum':
            loss = loss.sum()
        return loss



class BBoxHeadAVA(nn.Module):
    """Simplest RoI head, with only two fc layers for classification and
    regression respectively.

    Args:
        temporal_pool_type (str): The temporal pool type. Choices are 'avg' or
            'max'. Default: 'avg'.
        spatial_pool_type (str): The spatial pool type. Choices are 'avg' or
            'max'. Default: 'max'.
        in_channels (int): The number of input channels. Default: 2048.
        num_classes (int): The number of classes. Default: 81.
        dropout_ratio (float): A float in [0, 1], indicates the dropout_ratio.
            Default: 0.
        dropout_before_pool (bool): Dropout Feature before spatial temporal
            pooling. Default: True.
        topk (int or tuple[int]): Parameter for evaluating multilabel accuracy.
            Default: (3, 5)
        multilabel (bool): Whether used for a multilabel task. Default: True.
            (Only support multilabel == True now).
    """

    def __init__(
            self,
            temporal_pool_type='avg',
            spatial_pool_type='max',
            in_channels=2048,
            # The first class is reserved, to classify bbox as pos / neg
            num_classes=81,
            dropout_ratio=0,
            dropout_before_pool=True,
            topk=(3, 5),
            multilabel=True,
            loss_cfg = None):
        super(BBoxHeadAVA, self).__init__()
        assert temporal_pool_type in ['max', 'avg']
        assert spatial_pool_type in ['max', 'avg']
        self.temporal_pool_type = temporal_pool_type
        self.spatial_pool_type = spatial_pool_type

        self.in_channels = in_channels
        self.num_classes = num_classes

        self.dropout_ratio = dropout_ratio
        self.dropout_before_pool = dropout_before_pool

        self.multilabel = multilabel

        if topk is None:
            self.topk = ()
        elif isinstance(topk, int):
            self.topk = (topk, )
        elif isinstance(topk, tuple):
            assert all([isinstance(k, int) for k in topk])
            self.topk = topk
        else:
            raise TypeError('topk should be int or tuple[int], '
                            f'but get {type(topk)}')
        # Class 0 is ignored when calculaing multilabel accuracy,
        # so topk cannot be equal to num_classes
        assert all([k < num_classes for k in self.topk])

        # Handle AVA first
        assert self.multilabel

        in_channels = self.in_channels
        # Pool by default
        if self.temporal_pool_type == 'avg':
            self.temporal_pool = nn.AdaptiveAvgPool3d((1, None, None))
        else:
            self.temporal_pool = nn.AdaptiveMaxPool3d((1, None, None))
        if self.spatial_pool_type == 'avg':
            self.spatial_pool = nn.AdaptiveAvgPool3d((None, 1, 1))
        else:
            self.spatial_pool = nn.AdaptiveMaxPool3d((None, 1, 1))

        if dropout_ratio > 0:
            self.dropout = nn.Dropout(dropout_ratio)

        self.fc_cls = nn.Linear(in_channels, num_classes)
        self.debug_imgs = None
        
        self.f_bce = F_BCE()
        self.BN = nn.BatchNorm1d(6)

    def init_weights(self):
        nn.init.normal_(self.fc_cls.weight, 0, 0.01)
        nn.init.constant_(self.fc_cls.bias, 0)

    def forward(self, x):
        if self.dropout_before_pool and self.dropout_ratio > 0:
            x = self.dropout(x)

        x = self.temporal_pool(x)
        x = self.spatial_pool(x)

        if not self.dropout_before_pool and self.dropout_ratio > 0:
            x = self.dropout(x)

        x = x.view(x.size(0), -1)
        cls_score = self.fc_cls(x)
        # We do not predict bbox, so return None
        return cls_score, None

    def get_targets(self, sampling_results, gt_bboxes, gt_labels,
                    rcnn_train_cfg):
        pos_proposals = [res.pos_bboxes for res in sampling_results]
        neg_proposals = [res.neg_bboxes for res in sampling_results]
        pos_gt_labels = [res.pos_gt_labels for res in sampling_results]
        cls_reg_targets = bbox_target(pos_proposals, neg_proposals,
                                      pos_gt_labels, rcnn_train_cfg)
        return cls_reg_targets

    def recall_prec(self, pred_vec, target_vec):
        """
        Args:
            pred_vec (tensor[N x C]): each element is either 0 or 1
            target_vec (tensor[N x C]): each element is either 0 or 1

        """
        correct = pred_vec & target_vec
        # Seems torch 1.5 has no auto type conversion
        recall = correct.sum(1) / (target_vec.sum(1).float()+ 1e-6)
        prec = correct.sum(1) / (pred_vec.sum(1) + 1e-6)
        return recall.mean(), prec.mean()

    def multilabel_accuracy(self, pred, target, thr=0.5):
        pred = pred.sigmoid()
        pred_vec = pred > thr
        # Target is 0 or 1, so using 0.5 as the borderline is OK
        target_vec = target > 0.5
        recall_thr, prec_thr = self.recall_prec(pred_vec, target_vec)

        recalls, precs = [], []
        for k in self.topk:
            _, pred_label = pred.topk(k, 1, True, True)
            pred_vec = pred.new_full(pred.size(), 0, dtype=torch.bool)

            num_sample = pred.shape[0]
            for i in range(num_sample):
                pred_vec[i, pred_label[i]] = 1
            recall_k, prec_k = self.recall_prec(pred_vec, target_vec)
            recalls.append(recall_k)
            precs.append(prec_k)
        return recall_thr, prec_thr, recalls, precs


    def loss(self,
             cls_score,
             bbox_pred,
             rois,
             labels,
             label_weights,
             bbox_targets=None,
             bbox_weights=None,
             reduce=True):
        losses = dict()
        if cls_score is not None:
            # Only use the cls_score
            #labels = labels[:, 1:]
            # pos_inds = torch.sum(labels, dim=-1) > 0
            # cls_score = cls_score[pos_inds, 1:]
            # labels = labels[pos_inds]
            labels = labels[:, 1:]
            cls_score = cls_score[:, 1:]
            
            cls_score = self.BN(cls_score)

            f_bce_loss = self.f_bce
            losses['loss_action_cls'] = f_bce_loss(cls_score, labels)
            
            #bce_loss = F.binary_cross_entropy_with_logits
            #losses['loss_action_cls'] = bce_loss(cls_score, labels)
            recall_thr, prec_thr, recall_k, prec_k = self.multilabel_accuracy(
                cls_score, labels, thr=0.5)
            losses['recall@thr=0.5'] = recall_thr
            losses['prec@thr=0.5'] = prec_thr
            for i, k in enumerate(self.topk):
                losses[f'recall@top{k}'] = recall_k[i]
                losses[f'prec@top{k}'] = prec_k[i]
        return losses

    def get_det_bboxes(self,
                       rois,
                       cls_score,
                       img_shape,
                       flip=False,
                       crop_quadruple=None,
                       cfg = None):

        # might be used by testing w. augmentation
        if isinstance(cls_score, list):
            cls_score = sum(cls_score) / float(len(cls_score))

        assert self.multilabel

        scores = cls_score.sigmoid() if cls_score is not None else None
        bboxes = rois[:, 1:]
        assert bboxes.shape[-1] == 4

        # First reverse the flip
        img_h, img_w = img_shape
        if flip:
            bboxes_ = bboxes.clone()
            bboxes_[:, 0] = img_w - 1 - bboxes[:, 2]
            bboxes_[:, 2] = img_w - 1 - bboxes[:, 0]
            bboxes = bboxes_

        # Then normalize the bbox to [0, 1]
        bboxes[:, 0::2] /= img_w
        bboxes[:, 1::2] /= img_h

        def _bbox_crop_undo(bboxes, crop_quadruple):
            decropped = bboxes.clone()

            if crop_quadruple is not None:
                x1, y1, tw, th = crop_quadruple
                decropped[:, 0::2] = bboxes[..., 0::2] * tw + x1
                decropped[:, 1::2] = bboxes[..., 1::2] * th + y1

            return decropped

        bboxes = _bbox_crop_undo(bboxes, crop_quadruple)
        return bboxes, scores


if mmdet_imported:
    MMDET_HEADS.register_module()(BBoxHeadAVA)


開始訓練:

python tools/train.py configs/detection/via3/my_slowfast_kinetics_pretrained_r50_8x8x1_20e_via3_rgb.py --validate

在這里插入圖片描述

4.5 實驗對比

經過15個小時的訓練

首先是原模型(改進前)
來看看結果
在這里插入圖片描述

0s2021-11-04 11:26:56,234 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq5.json with 556 images now
2021-11-04 11:26:56,234 - mmaction - INFO - Evaluating mAP ...
==> 0.035635 seconds to process groundtruth results
==> 0.0550323 seconds to process prediction results
==> 0.122445 seconds to Convert groundtruth
==> 0.302411 seconds to convert prediction
==> 0.0125372 seconds to run_evaluator
mAP@0.5IOU=     0.822277391327469
PerformanceByCategory/AP@0.5IOU/handshake=      0.8867924528301887
PerformanceByCategory/AP@0.5IOU/point=  0.6091617933723197
PerformanceByCategory/AP@0.5IOU/hug=    0.7931456548347613
PerformanceByCategory/AP@0.5IOU/push=   0.8666666666666667
PerformanceByCategory/AP@0.5IOU/kick=   0.7
PerformanceByCategory/AP@0.5IOU/punch=  0.9945054945054945
2021-11-04 11:26:56,766 - mmaction - INFO - 
mAP@0.5IOU       0.8223
2021-11-04 11:26:56,768 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq10.json with 557 images now
2021-11-04 11:26:56,768 - mmaction - INFO - Evaluating mAP ...
==> 0.0580194 seconds to process groundtruth results
==> 0.0607066 seconds to process prediction results
==> 0.097141 seconds to Convert groundtruth
==> 0.315272 seconds to convert prediction
==> 0.015708 seconds to run_evaluator
mAP@0.5IOU=     0.40562803653484647
PerformanceByCategory/AP@0.5IOU/handshake=      0.45454545454545453
PerformanceByCategory/AP@0.5IOU/point=  0.391812865497076
PerformanceByCategory/AP@0.5IOU/hug=    0.6896551724137931
PerformanceByCategory/AP@0.5IOU/push=   0.37356321839080453
PerformanceByCategory/AP@0.5IOU/kick=   0.0
PerformanceByCategory/AP@0.5IOU/punch=  0.0
2021-11-04 11:26:57,318 - mmaction - INFO - 
mAP@0.5IOU       0.4056
2021-11-04 11:26:57,318 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq15.json with 607 images now
2021-11-04 11:26:57,318 - mmaction - INFO - Evaluating mAP ...
==> 0.0335379 seconds to process groundtruth results
==> 0.0631692 seconds to process prediction results
==> 0.10759 seconds to Convert groundtruth
==> 0.37948 seconds to convert prediction
==> 0.0157986 seconds to run_evaluator
mAP@0.5IOU=     0.5331220241603439
PerformanceByCategory/AP@0.5IOU/handshake=      0.8571428571428571
PerformanceByCategory/AP@0.5IOU/point=  0.25
PerformanceByCategory/AP@0.5IOU/hug=    0.7222222222222222
PerformanceByCategory/AP@0.5IOU/push=   0.452991452991453
PerformanceByCategory/AP@0.5IOU/kick=   0.1
PerformanceByCategory/AP@0.5IOU/punch=  0.38461538461538464
2021-11-04 11:26:57,921 - mmaction - INFO - 
mAP@0.5IOU       0.5331
2021-11-04 11:26:57,921 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq20.json with 622 images now
2021-11-04 11:26:57,921 - mmaction - INFO - Evaluating mAP ...
==> 0.0534511 seconds to process groundtruth results
==> 0.085907 seconds to process prediction results
==> 0.128184 seconds to Convert groundtruth
==> 0.38158 seconds to convert prediction
==> 0.0196507 seconds to run_evaluator
mAP@0.5IOU=     0.49892216373873616
PerformanceByCategory/AP@0.5IOU/handshake=      0.5131485429992891
PerformanceByCategory/AP@0.5IOU/point=  0.5477982978485432
PerformanceByCategory/AP@0.5IOU/hug=    0.8906976744186047
PerformanceByCategory/AP@0.5IOU/push=   0.42094630515683146
PerformanceByCategory/AP@0.5IOU/kick=   0.0
PerformanceByCategory/AP@0.5IOU/punch=  0.17647058823529413
2021-11-04 11:26:58,594 - mmaction - INFO - 
mAP@0.5IOU       0.4989
2021-11-04 11:26:58,599 - mmaction - INFO - Epoch(val) [20][2643]       0_mAP@0.5IOU: 0.8223, 1_mAP@root@61826ea1b4e40269dc480687:/home/JN-OpenLib-mmaction2# , all_mAP@0.5IOU: 0.5650

可以看出原模型最后準確率:56.50%

然后是改進后的模型
在這里插入圖片描述

Evaluateing data/Interaction/annotations/test/seq5.json with 556 images now
2021-11-04 12:14:31,246 - mmaction - INFO - Evaluating mAP ...
==> 0.0391157 seconds to process groundtruth results
==> 0.0535824 seconds to process prediction results
==> 0.127968 seconds to Convert groundtruth
==> 0.653159 seconds to convert prediction
==> 0.0301211 seconds to run_evaluator
mAP@0.5IOU=     0.9069741460566432
PerformanceByCategory/AP@0.5IOU/handshake=      0.9942538308459411
PerformanceByCategory/AP@0.5IOU/point=  0.6242095754290875
PerformanceByCategory/AP@0.5IOU/hug=    0.9607235142118863
PerformanceByCategory/AP@0.5IOU/push=   1.0
PerformanceByCategory/AP@0.5IOU/kick=   0.9636363636363636
PerformanceByCategory/AP@0.5IOU/punch=  0.9395604395604397
2021-11-04 12:14:32,155 - mmaction - INFO - 
mAP@0.5IOU       0.9070
2021-11-04 12:14:32,155 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq10.json with 557 images now
2021-11-04 12:14:32,156 - mmaction - INFO - Evaluating mAP ...
==> 0.0397999 seconds to process groundtruth results
==> 0.0588491 seconds to process prediction results
==> 0.0968714 seconds to Convert groundtruth
==> 0.665299 seconds to convert prediction
==> 0.0389373 seconds to run_evaluator
mAP@0.5IOU=     0.7747222320890791
PerformanceByCategory/AP@0.5IOU/handshake=      0.9065866429798629
PerformanceByCategory/AP@0.5IOU/point=  0.8147161450436735
PerformanceByCategory/AP@0.5IOU/hug=    0.9150861013434618
PerformanceByCategory/AP@0.5IOU/push=   0.9839296652614131
PerformanceByCategory/AP@0.5IOU/kick=   0.5192805038670355
PerformanceByCategory/AP@0.5IOU/punch=  0.43140462721305534
2021-11-04 12:14:33,073 - mmaction - INFO - 
mAP@0.5IOU       0.7747
2021-11-04 12:14:33,073 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq15.json with 607 images now
2021-11-04 12:14:33,073 - mmaction - INFO - Evaluating mAP ...
==> 0.0371342 seconds to process groundtruth results
==> 0.0646772 seconds to process prediction results
==> 0.101891 seconds to Convert groundtruth
==> 0.739635 seconds to convert prediction
==> 0.0439842 seconds to run_evaluator
mAP@0.5IOU=     0.7889970077502289
PerformanceByCategory/AP@0.5IOU/handshake=      0.8908877061148943
PerformanceByCategory/AP@0.5IOU/point=  0.8125
PerformanceByCategory/AP@0.5IOU/hug=    0.9966124661246613
PerformanceByCategory/AP@0.5IOU/push=   0.6567905778432095
PerformanceByCategory/AP@0.5IOU/kick=   0.7602408702408703
PerformanceByCategory/AP@0.5IOU/punch=  0.4837407437954634
2021-11-04 12:14:34,069 - mmaction - INFO - 
mAP@0.5IOU       0.7890
2021-11-04 12:14:34,070 - mmaction - INFO - 
Evaluateing data/Interaction/annotations/test/seq20.json with 622 images now
2021-11-04 12:14:34,070 - mmaction - INFO - Evaluating mAP ...
==> 0.0685616 seconds to process groundtruth results
==> 0.0815992 seconds to process prediction results
==> 0.108798 seconds to Convert groundtruth
==> 0.813663 seconds to convert prediction
==> 0.0507228 seconds to run_evaluator
mAP@0.5IOU=     0.7211447472837192
PerformanceByCategory/AP@0.5IOU/handshake=      0.9027139539608279
PerformanceByCategory/AP@0.5IOU/point=  0.4597024418984696
PerformanceByCategory/AP@0.5IOU/hug=    0.9709107878976433
PerformanceByCategory/AP@0.5IOU/push=   0.7328256368708507
PerformanceByCategory/AP@0.5IOU/kick=   0.7415679515722716
PerformanceByCategory/AP@0.5IOU/punch=  0.35279228700716714
2021-11-04 12:14:35,201 - mmaction - INFO - 
mAP@0.5IOU       0.7211
2021-11-04 12:14:35,207 - mmaction - INFO - Epoch(val) [20][2643]       0_mAP@0.5IOU: 0.9070, 1_mAP@0.5IOU: 0.7747, 2_mAP@0.5IOU: 0.7890, 3_mAP@0.5IOU: 0.7211, all_mAP@0.5IOU: 0.7980

可以看出原模型最后準確率:79.80%
可以看出這是明顯的提高

4.6 實時查看GPU使用情況

參考:https://blog.csdn.net/u014261408/article/details/109853936

有人寫了個小工具gpustat把nvidia-smi封裝了起來,用起來很爽很方便,推薦給大家,
首先安裝:

pip install gpustat

然后使用:

gpustat -cp

輸出為:
在這里插入圖片描述

注意-c選項為顯示行程名,-p選項為顯示行程PID,如果想要不間斷持續輸出,請使用:

gpustat -cp -i 1

在這里插入圖片描述

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/348547.html

標籤:AI

上一篇:機器學習之LSTM的Python實作

下一篇:深度學習高級,Keras多輸入和混合資料實作回歸模型

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023年最新微信小程式抓包教程

    01 開門見山 隔一個月發一篇文章,不過分。 首先回顧一下《微信系結手機號資料庫被脫庫事件》,我也是第一時間得知了這個訊息,然后跟蹤了整件事情的經過。下面是這起事件的相關截圖以及近日流出的一萬條資料樣本: 個人認為這件事也沒什么,還不如關注一下之前45億快遞資料查詢渠道疑似在近日復活的訊息。 訊息是 ......

    uj5u.com 2023-04-20 08:48:24 more
  • web3 產品介紹:metamask 錢包 使用最多的瀏覽器插件錢包

    Metamask錢包是一種基于區塊鏈技術的數字貨幣錢包,它允許用戶在安全、便捷的環境下管理自己的加密資產。Metamask錢包是以太坊生態系統中最流行的錢包之一,它具有易于使用、安全性高和功能強大等優點。 本文將詳細介紹Metamask錢包的功能和使用方法。 一、 Metamask錢包的功能 數字資 ......

    uj5u.com 2023-04-20 08:47:46 more
  • vulnhub_Earth

    前言 靶機地址->>>vulnhub_Earth 攻擊機ip:192.168.20.121 靶機ip:192.168.20.122 參考文章 https://www.cnblogs.com/Jing-X/archive/2022/04/03/16097695.html https://www.cnb ......

    uj5u.com 2023-04-20 07:46:20 more
  • 從4k到42k,軟體測驗工程師的漲薪史,給我看哭了

    清明節一過,盲猜大家已經無心上班,在數著日子準備過五一,但一想到銀行卡里的余額……瞬間心情就不美麗了。最近,2023年高校畢業生就業調查顯示,本科畢業月平均起薪為5825元。調查一出,便有很多同學表示自己又被平均了。看著這一資料,不免讓人想到前不久中國青年報的一項調查:近六成大學生認為畢業10年內會 ......

    uj5u.com 2023-04-20 07:44:00 more
  • 最新版本 Stable Diffusion 開源 AI 繪畫工具之中文自動提詞篇

    🎈 標簽生成器 由于輸入正向提示詞 prompt 和反向提示詞 negative prompt 都是使用英文,所以對學習母語的我們非常不友好 使用網址:https://tinygeeker.github.io/p/ai-prompt-generator 這個網址是為了讓大家在使用 AI 繪畫的時候 ......

    uj5u.com 2023-04-20 07:43:36 more
  • 漫談前端自動化測驗演進之路及測驗工具分析

    隨著前端技術的不斷發展和應用程式的日益復雜,前端自動化測驗也在不斷演進。隨著 Web 應用程式變得越來越復雜,自動化測驗的需求也越來越高。如今,自動化測驗已經成為 Web 應用程式開發程序中不可或缺的一部分,它們可以幫助開發人員更快地發現和修復錯誤,提高應用程式的性能和可靠性。 ......

    uj5u.com 2023-04-20 07:43:16 more
  • CANN開發實踐:4個DVPP記憶體問題的典型案例解讀

    摘要:由于DVPP媒體資料處理功能對存放輸入、輸出資料的記憶體有更高的要求(例如,記憶體首地址128位元組對齊),因此需呼叫專用的記憶體申請介面,那么本期就分享幾個關于DVPP記憶體問題的典型案例,并給出原因分析及解決方法。 本文分享自華為云社區《FAQ_DVPP記憶體問題案例》,作者:昇騰CANN。 DVPP ......

    uj5u.com 2023-04-20 07:43:03 more
  • msf學習

    msf學習 以kali自帶的msf為例 一、msf核心模塊與功能 msf模塊都放在/usr/share/metasploit-framework/modules目錄下 1、auxiliary 輔助模塊,輔助滲透(埠掃描、登錄密碼爆破、漏洞驗證等) 2、encoders 編碼器模塊,主要包含各種編碼 ......

    uj5u.com 2023-04-20 07:42:59 more
  • Halcon軟體安裝與界面簡介

    1. 下載Halcon17版本到到本地 2. 雙擊安裝包后 3. 步驟如下 1.2 Halcon軟體安裝 界面分為四大塊 1. Halcon的五個助手 1) 影像采集助手:與相機連接,設定相機引數,采集影像 2) 標定助手:九點標定或是其它的標定,生成標定檔案及內參外參,可以將像素單位轉換為長度單位 ......

    uj5u.com 2023-04-20 07:42:17 more
  • 在MacOS下使用Unity3D開發游戲

    第一次發博客,先發一下我的游戲開發環境吧。 去年2月份買了一臺MacBookPro2021 M1pro(以下簡稱mbp),這一年來一直在用mbp開發游戲。我大致分享一下我的開發工具以及使用體驗。 1、Unity 官網鏈接: https://unity.cn/releases 我一般使用的Apple ......

    uj5u.com 2023-04-20 07:40:19 more