caffe训练自己的数据集——3. 数据处理

测试时间

1. 在lenet.prototxt中,指定输入、输出参数:

layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 3 dim: 32 dim: 32 } }
}
···
inner_product_param {
    num_output: 2
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }

2. 运行caffe自带的time脚本

  • linux平台
    Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz cpu cores : 4
    nvidia 1080 Ti 11GB显存
    对于32x32x3的单张输入图片,用lenet,前向传播的gpu时间消耗为0.289265ms,cpu时间消耗为1.76382ms
/opt/caffe/build/tools/caffe time -model=lenet.prototxt --weights=train_100_all/train_100_lenet_iter_15000.caffemodel --iterations 100

I0917 06:06:54.982923  3741 caffe.cpp:406] Average time per layer:
I0917 06:06:54.982924  3741 caffe.cpp:409]       data   forward: 0.00036 ms.
I0917 06:06:54.982928  3741 caffe.cpp:412]       data   backward: 0.00043 ms.
I0917 06:06:54.982930  3741 caffe.cpp:409]      conv1   forward: 0.4866 ms.
I0917 06:06:54.982933  3741 caffe.cpp:412]      conv1   backward: 0.42957 ms.
I0917 06:06:54.982935  3741 caffe.cpp:409]      pool1   forward: 0.03327 ms.
I0917 06:06:54.982937  3741 caffe.cpp:412]      pool1   backward: 0.00033 ms.
I0917 06:06:54.982939  3741 caffe.cpp:409]      conv2   forward: 0.76444 ms.
I0917 06:06:54.982941  3741 caffe.cpp:412]      conv2   backward: 0.76636 ms.
I0917 06:06:54.982944  3741 caffe.cpp:409]      pool2   forward: 0.01981 ms.
I0917 06:06:54.982946  3741 caffe.cpp:412]      pool2   backward: 0.00021 ms.
I0917 06:06:54.982980  3741 caffe.cpp:409]        ip1   forward: 0.44944 ms.
I0917 06:06:54.982983  3741 caffe.cpp:412]        ip1   backward: 0.6448 ms.
I0917 06:06:54.982998  3741 caffe.cpp:409]      relu1   forward: 0.00264 ms.
I0917 06:06:54.983000  3741 caffe.cpp:412]      relu1   backward: 0.00028 ms.
I0917 06:06:54.983003  3741 caffe.cpp:409]        ip2   forward: 0.00247 ms.
I0917 06:06:54.983008  3741 caffe.cpp:412]        ip2   backward: 0.00045 ms.
I0917 06:06:54.983012  3741 caffe.cpp:409]       prob   forward: 0.00133 ms.
I0917 06:06:54.983018  3741 caffe.cpp:412]       prob   backward: 0.00063 ms.
I0917 06:06:54.983026  3741 caffe.cpp:417] Average Forward pass: 1.76382 ms.
I0917 06:06:54.983032  3741 caffe.cpp:419] Average Backward pass: 1.84606 ms.
I0917 06:06:54.983055  3741 caffe.cpp:421] Average Forward-Backward: 3.61 ms.
I0917 06:06:54.983062  3741 caffe.cpp:423] Total Time: 361 ms.
I0917 06:06:54.983067  3741 caffe.cpp:424] *** Benchmark ends ***
  • windows版本caffe
    Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz cpu cores: 4
    GeForce GTX 960 4GB显存
    对于32x32x3的单张输入图片,用lenet,前向传播的gpu时间消耗为 0.761424ms,cpu时间消耗为0.95426ms
 build/tools/Release/caffe.exe time --model examples/mnist/lenet.prototxt --iterations 100

I0917 07:13:59.470808 16024 caffe.cpp:410]       data   forward: 0 ms.
I0917 07:13:59.470808 16024 caffe.cpp:413]       data   backward: 0 ms.
I0917 07:13:59.470808 16024 caffe.cpp:410]      conv1   forward: 0.11008 ms.
I0917 07:13:59.470808 16024 caffe.cpp:413]      conv1   backward: 0.16188 ms.
I0917 07:13:59.470808 16024 caffe.cpp:410]      pool1   forward: 0.04113 ms.
I0917 07:13:59.470808 16024 caffe.cpp:413]      pool1   backward: 0 ms.
I0917 07:13:59.470808 16024 caffe.cpp:410]      conv2   forward: 0.27619 ms.
I0917 07:13:59.470808 16024 caffe.cpp:413]      conv2   backward: 0.17072 ms.
I0917 07:13:59.470808 16024 caffe.cpp:410]      pool2   forward: 0.01001 ms.
I0917 07:13:59.470808 16024 caffe.cpp:413]      pool2   backward: 0 ms.
I0917 07:13:59.470808 16024 caffe.cpp:410]        ip1   forward: 0.49684 ms.
I0917 07:13:59.470808 16024 caffe.cpp:413]        ip1   backward: 0.28735 ms.
I0917 07:13:59.471801 16024 caffe.cpp:410]      relu1   forward: 0.01 ms.
I0917 07:13:59.471801 16024 caffe.cpp:413]      relu1   backward: 0 ms.
I0917 07:13:59.471801 16024 caffe.cpp:410]        ip2   forward: 0.01001 ms.
I0917 07:13:59.471801 16024 caffe.cpp:413]        ip2   backward: 0 ms.
I0917 07:13:59.471801 16024 caffe.cpp:410]       prob   forward: 0 ms.
I0917 07:13:59.471801 16024 caffe.cpp:413]       prob   backward: 0 ms.
I0917 07:13:59.471801 16024 caffe.cpp:418] Average Forward pass: 0.95426 ms.
I0917 07:13:59.471801 16024 caffe.cpp:420] Average Backward pass: 0.63005 ms.
I0917 07:13:59.471801 16024 caffe.cpp:422] Average Forward-Backward: 1.63 ms.
I0917 07:13:59.471801 16024 caffe.cpp:424] Total Time: 163 ms.
I0917 07:13:59.471801 16024 caffe.cpp:425] *** Benchmark ends ***

绘制loss曲线

#!encoding=utf-8
import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle

squ_base = pickle.load(open('pkl_result/squ_fcm_600_90/person_pr.pkl'))
squ_wsm_resrpn = pickle.load(open('pkl_result/squ_pva_wsm_resrpn_9w_001_897/person_pr.pkl'))

vgg_base = pickle.load(open('pkl_result/vgg_10w_781/person_pr.pkl'))
vgg_wsm = pickle.load(open('pkl_result/vgg16_multi_wsm_fix_877/person_pr.pkl'))
vgg_msrpn = pickle.load(open('pkl_result/vgg16_multi_fix_resrpn_880/person_pr.pkl'))
vgg_wsm_msrpn = pickle.load(open('pkl_result/vgg16_multi_wsm_fix_resrpn_888/person_pr.pkl'))
vgg_ohem = pickle.load(open('pkl_result/vgg16_multi_wsm_fix_resrpn_ohem_897/person_pr.pkl'))

squ_base_rec = squ_base['rec']
squ_base_prec = squ_base['prec']
squ_wsm_resrpn_rec = squ_wsm_resrpn['rec']
squ_wsm_resrpn_prec = squ_wsm_resrpn['prec']

vgg_base_rec = vgg_base['rec']
vgg_base_prec = vgg_base['prec']
vgg_wsm_rec = vgg_wsm['rec']
vgg_wsm_prec = vgg_wsm['prec']
vgg_msrpn_rec = vgg_msrpn['rec']
vgg_msrpn_prec = vgg_msrpn['prec']
vgg_wsm_msrpn_rec = vgg_wsm_msrpn['rec']
vgg_wsm_msrpn_prec = vgg_wsm_msrpn['prec']
vgg_ohem_rec = vgg_ohem['rec']
vgg_ohem_prec = vgg_ohem['prec']


plt.figure(1)
plt.title("Head detection(SqueezeNet)")
plt.subplot(121)
#plt.grid()
plot1 = plt.plot(squ_base_rec, squ_base_prec, 'r', label='squ_base', linewidth=5)
plot2 = plt.plot(squ_wsm_resrpn_rec, squ_wsm_resrpn_prec, 'g', label='squ_wsm/msrpn', linewidth=5)
plt.xticks(fontsize=28)
plt.yticks(fontsize=28)
plt.title("Head detection(SqueezeNet)", fontsize=28)
plt.xlabel("Recall", fontsize=28)
plt.ylabel("Precision", fontsize=28)
plt.legend(loc='lower center', bbox_to_anchor=(0.3,0.08),ncol=1,fancybox=True,shadow=True, fontsize=28)   # make legend
# plt.savefig("result_pic/SqueezeNet.jpg")
plt.subplot(122)
#plt.grid()
plt.plot(vgg_base_rec, vgg_base_prec, 'r', label='vgg_base', linewidth=5)
plt.plot(vgg_wsm_rec, vgg_wsm_prec, 'g', label='vgg_wsm', linewidth=5)
plt.plot(vgg_msrpn_rec, vgg_msrpn_prec, 'b', label='vgg_msrpn', linewidth=5)
plt.plot(vgg_wsm_msrpn_rec, vgg_wsm_msrpn_prec, 'm', label='vgg_wsm/msrpn', linewidth=5)
plt.plot(vgg_ohem_rec, vgg_ohem_prec, 'y', label='vgg_wsm/msrpn/ohem', linewidth=5)
plt.xticks(fontsize=28)
plt.yticks(fontsize=28)
plt.title("Head detection(VGG16)", fontsize=28)
plt.xlabel("Recall", fontsize=28)
plt.ylabel("Precision", fontsize=28)
plt.legend(loc='lower center', bbox_to_anchor=(0.4,0.08),ncol=1,fancybox=True,shadow=True, fontsize=28)  # make legend
plt.savefig("result_pic/TEST.jpg")
plt.show()


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值