《临时笔记》caffe2使用记录

本文作为临时笔记,记录笔者在使用caffe2时候的一些问题和解决方法,有空再进行详细整理。

  1. caffe2中对视频的单帧进行了零均值标准化处理,也就是如式子(1.1)所示:
    x ^ = x − m e a n s t d (1.1) \hat{x} = \dfrac{x-\mathrm{mean}}{\mathrm{std}} \tag{1.1} x^=stdxmean(1.1)
    从源码上看[1],这里的均值mean和方差std分别是:
    // 7 channels: (flow_x, flow_y, flow_magitude, gray, Red, Green, Blue)
    const std::vector<float> InputDataMean = {
    
    
        0.0046635, 0.0046261, 0.963986, 102.976, 110.201, 100.64, 95.9966};
    const std::vector<float> InputDataStd = {
    
    
        0.972347, 0.755146, 1.43588, 55.3691, 58.1489, 56.4701, 55.3324};

方差是[58.1489, 56.4701, 55.3324], 均值是[110.201, 100.64, 95.9966],排序是RGB

PS:在pytorch中的torchvision.models.video中,同样对视频单帧进行了相似的处理,不同之处在于其对像素进行了归一化,范围是[0,1]而不是[0,255],除此之外,同样对单帧像素进行了零均值标准化处理,其均值为mean=[0.43216, 0.394666, 0.37645],方差为std = [0.22803, 0.22145, 0.216989]。[2]


Reference

[1]. https://github.com/pytorch/pytorch/blob/master/caffe2/video/video_input_op.h#L374-L378
[2]. https://pytorch.org/docs/stable/torchvision/models.html#video-classification

猜你喜欢

转载自blog.csdn.net/LoseInVain/article/details/105863809