【Caffe】Caffe版MobileNet实操

github代码:https://github.com/shicai/MobileNet-Caffe

有Mobilenet-V1,Mobilenet-V2的prototxt和caffemodel;

Evaluate MobileNet v1:

python eval_image.py --proto mobilenet_deploy.prototxt --model mobilenet.caffemodel --image ./cat.jpg

Expected Outputs:

0.42 - 'n02123159 tiger cat'
0.08 - 'n02119022 red fox, Vulpes vulpes'
0.07 - 'n02119789 kit fox, Vulpes macrotis'
0.06 - 'n02113023 Pembroke, Pembroke Welsh corgi'
0.06 - 'n02123045 tabby, tabby cat'

Evaluate MobileNet v2:

python eval_image.py --proto mobilenet_v2_deploy.prototxt --model mobilenet_v2.caffemodel --image ./cat.jpg

Expected Outputs:

0.26 - 'n02123159 tiger cat'
0.22 - 'n02124075 Egyptian cat'
0.15 - 'n02123045 tabby, tabby cat'
0.04 - 'n02119022 red fox, Vulpes vulpes'
0.02 - 'n02326432 hare'


Finetuning on your own data(在自己的数据集上进行微调)

Modify deploy.prototxt and save it as your train.prototxt as follows: Remove the first 5 input/input_dim lines, and add Image Data layer in the beginning like this:

layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.017
    mirror: true
    crop_size: 224
    mean_value: [103.94, 116.78, 123.68]
  }
  image_data_param {
    source: "your_list_train_txt"
    batch_size: 32 # your batch size
    new_height: 256
    new_width: 256
    root_folder: "your_path_to_training_data_folder"
  }
}

Remove the last prob layer, and add Loss and Accuracy layers in the end like this:

layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "fc7"
  bottom: "label"
  top: "loss"
}
layer {
  name: "top1/acc"
  type: "Accuracy"
  bottom: "fc7"
  bottom: "label"
  top: "top1/acc"
  include {
    phase: TEST
  }
}
layer {
  name: "top5/acc"
  type: "Accuracy"
  bottom: "fc7"
  bottom: "label"
  top: "top5/acc"
  include {
    phase: TEST
  }
  accuracy_param {
    top_k: 5
  }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值