Caffe_Windows学习笔记(七)细粒度图像分类

0、参考文献

[1]https://github.com/ouceduxzk/Fine_Grained_Classification/tree/master/codes

[2]http://blog.csdn.net/lynnandwei/article/details/44458033

1.

install caffe

download bvlc_googlenet.caffemodel

 http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel

download images into the cars_train and cars_test folder under the prepare folder 

 http://ai.stanford.edu/~jkrause/cars/car_dataset.html

2.

in the prepare folder, change the directory of train_path and test_path to your own path 

run : python preprocessing.py, which will generate the  crop_train and crop_test

train_path = 'D:/caffe_test/caffe-master/fine_grained/cars_train/'
train_files = os.listdir(train_path)
train_files = [ f for f in train_files if f.endswith('jpg')]
test_path = 'D:/caffe_test/caffe-master/fine_grained/cars_test/'
test_files = os.listdir(test_path)

遇到unindent的报错的话,用Notepad解决,具体参考https://www.crifan.com/python_syntax_error_indentationerror/

结果:




3.

sh pre.sh , which will call caffe to save the images into a database

#!/bin/bash
D:/caffe_test/caffe-master/Build/x64/Release/convert_imageset D:/caffe_test/caffe-master/fine-grained/crop_train/ train2.txt ./train -resize_width=227 -resize_height=227 -check_size -shuffle true
D:/caffe_test/caffe-master/Build/x64/Release/convert_imageset D:/caffe_test/caffe-master/fine-grained/crop_test/ test2.txt ./test -resize_width=227 -resize_height=227 -check_size -shuffle true

结果:

4.

change the path in the models/finetuen_car/train_val.prototxt into the path of your db

layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size: 224
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  data_param {
    source: "D:/caffe_test/caffe-master/fine-grained/train/"
    batch_size: 32
    backend: LMDB
  }
}
layer {
  name: "data"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    mirror: false
    crop_size: 224
    mean_value: 104
    mean_value: 117
    mean_value: 123
  }
  data_param {
    source: "D:/caffe_test/caffe-master/fine-grained/test/"
    batch_size: 50
    backend: LMDB
  }
}

5.

sh run.sh, the models will be saved in the models directory

solver.prototxt:

net: "D:/caffe_test/caffe-master/fine-grained/train_val.prototxt"
test_iter: 100
test_interval: 400
test_initialization: false
display: 20
base_lr: 0.001
lr_policy: "step"
stepsize: 10000
gamma: 0.1
max_iter: 50000
momentum: 0.9
weight_decay: 0.0005
snapshot: 1000
snapshot_prefix: "D:/caffe_test/caffe-master/fine-grained/car_googlenet"
solver_mode: GPU

run.sh:

#!/bin/bash
D:/caffe_test/caffe-master/Build/x64/Release/caffe train --solver D:/caffe_test/caffe-master/fine-grained/solver.prototxt --weights D:/caffe_test/caffe-master/fine-grained/bvlc_googlenet.caffemodel --gpu 0

结果:

一直遇到*** Check failure stack trace: ***的问题,但是路径都没错啊,目前没解决。

不知道是不是Windows不好跑的原因,我放到Linux上就通过了,汗……

6.

hyper parameters are in solver.prototxt file and you can play with that .

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值