Install and fune-tune caffe on Ubuntu
来源:互联网 发布:知乎哪个国家公司 编辑:程序博客网 时间:2024/06/14 03:31
Install and use caffe on Ubuntu
Install
__float128 is undefined
solve: change suffix.hpp line 510, from
extension typedef float128 float128_type;
to
__extension typedef long double float128_type;
Use
Data preparation
crop and resize
Crop and resize 800x600 images to 227x227 as we want to use pretrained models GoogleNet.
copy file to remote server
将文件夹复制到服务器dlserver:
scp -r charger ga04@dlserver:/home/ga04/caffe/data/charger/
scp charger_*.txt ga04@dlserver:/home/ga04/caffe/data/charger/
convert_imageset
Make lmdb from image list. convert_imageset ~/caffe/data/charger/ charger_train.txt charger_train_db
convert_imageset ~/caffe/data/charger/ charger_test.txt charger_test_db
第一次可能失败。把生成的文件夹charger_train_db
删掉再来一次,往往就可以了。。
compute_image_mean
error while loading shared libraries: libcaffe.so.1.0.0
solve: export LD_LIBRARY_PATH=/home/tkt/caffe/build/install/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
compute_image_mean charger_train_db charger_train_mean.binaryproto
compute_image_mean charger_test_db charger_test_mean.binaryproto
train (fine-tuning)
- Modify the
solver.prototxt
andtrain_val.prototxt
files according to the data and model path. You can reference flickr_style for how to modify. Basically you need to- change the name of the last fc8 layer in
train_val.prototxt
to something likefc8_charger
, also thenum_output
to 4. - change the learning rate in solver.prototxt to 1/10, stepsize to much smaller.
- change the name of the last fc8 layer in
- At caffe root directory:
caffe train -solver models/charger/solver.prototxt -weights
models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
2>&1 | tee log/my_model.log
where... 2>&1 | tee -a log/my_model.log
redirects the output from screen to my_model.log, can be omitted.
Now the cool things: Caffe has a script (/caffe/tools/extra/parse_log.py) to parse log files and return two much better formatted files.
# my_model.log.trainNumIters,Seconds,LearningRate,loss6000.0,10.468114,1e-06,0.04761566020.0,17.372427,1e-06,0.01956396040.0,24.237645,1e-06,0.05562746060.0,31.084703,1e-06,0.02446566080.0,37.927866,1e-06,0.03255826100.0,44.778659,1e-06,0.01312746120.0,51.62342,1e-06,0.0607449# my_model.log.testNumIters,Seconds,LearningRate,accuracy,loss6000.0,10.33778,1e-06,0.9944,0.02058596500.0,191.054363,1e-06,0.9948,0.01916567000.0,372.292923,1e-06,0.9951,0.01860957500.0,583.508988,1e-06,0.9947,0.02112638000.0,806.678746,1e-06,0.9947,0.01928248500.0,1027.549856,1e-06,0.9953,0.01839179000.0,1209.650574,1e-06,0.9949,0.0194651
And with a little bit trick, you can automate the parsing process and combine it with curve plotting using a script like this:
# visualize_log.shpython ~/caffe/tools/extra/parse_log.py my_model.log .gnuplot -persist gnuplot_commandswhere gnuplot_commands is a file that stores a set of gnuplot commands.# gnuplot_commandsset datafile separator ','set term x11 0plot '../my_model.log.train' using 1:4 with line title 'training loss',\ '../my_model.log.test' using 1:5 with line title 'test loss'set term x11 1plot '../my_model.log.test' using 1:4 with line
Reference: http://shengshuyang.github.io/A-step-by-step-guide-to-Caffe.html
predict
create deploy.txt
To predict an image, you need to create a deploy.prototxt
file from train_val.prototxt
, which basically does following things:
1. replace the data layers with an input layer like this:
layer { name: "data" type: "Input" top: "data" input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }}
- remove weight and bias filler
create labels.txt
Create a labels.txt
file as follows:
cneuukus
run classification
Call classification
as: classification ../../models/charger/deploy.prototxt ../../models/charger/charger_train_iter_10000.caffemodel charger_train_mean.binaryproto labels.txt eu_template.bmp
Remember to do the exactly same preprocessing to image eu_template.bmp
, otherwise classification result will be wrong.
- Install and fune-tune caffe on Ubuntu
- Install Caffe on Ubuntu 14
- Ubuntu 16.04 install caffe and pycaffe
- Howto Install and Configure VTK on Ubuntu
- Howto Install and Configure QtCreator on Ubuntu
- Howto Install and Configure PCL on Ubuntu
- Howto Install and Configure ROS on Ubuntu
- Install PostgreSql and PostGIS On Ubuntu Server
- Install Haskell on Ubuntu and CentOS
- Install scala and sbt on Ubuntu
- Install Pdf2htmlEX on Amazon Linux and Ubuntu
- Install R and RStudio on Ubuntu
- Teamviewer install on AWS RHEL7 and Ubuntu
- Install and test nginx on Ubuntu 14.04
- Install Flash on Ubuntu and Dockerfile
- compile and install ffmpeg on Ubuntu
- Install caffe on Ubuntu 14.04 with GTX 1080
- Install caffe on ubuntu && mac 错误解决办法集锦
- Android PopupWindow的使用和分析
- 苏宁携手S8南京“搞事情”,背后透露出怎样的信号?
- 说说 JavaScript 在 DOM 2、3 级标准中定义的样式规则(属性和方法)
- ES6语法(4)
- gcc编译,出现错误:expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ........
- Install and fune-tune caffe on Ubuntu
- 如何合理命名你的代码
- SQL中的CASE如何应用.多条件
- EXCEL表格自动统计测试用例数据的方法
- 利用powershell安装 .NET Framework 3.5.1
- xshell下远程访问Linux系统,在sqlplus下退格键乱码问题
- 响应式开发中的rem
- 互联网架构(6):并发编程--Disruptor并发框架
- centos7下安装php环境