主要参考(按顺序):
http://www.cnblogs.com/denny402/p/5083300.html
http://www.cnblogs.com/denny402/p/5082341.html
http://www.cnblogs.com/denny402/p/5083300.html
https://www.cnblogs.com/denny402/p/5685909.html
其它:
https://blog.csdn.net/u010682375/article/details/77777827
https://blog.csdn.net/where_is_my_keyboard/article/details/79882466
一、准备数据
数据下载地址:
(1).可以去imagenet的官网:http://www.image-net.org/download-images,下载imagenet图片来训练。
(2).使用Corel数据集:https://blog.csdn.net/garfielder007/article/details/51483759
我在corel中下载图片,并选取了500张图片,其中400张作为训练集,100张作为测试集,图片序号是200 - 699。图片放在caffe/examples/myfile/images下的train文件夹(400张)和test文件夹(100),其中myfile是我自己创建的文件夹。
二、转换为lmdb格式
首先,制作图片列表清单:
cd到caffe目录下,执行以下命令,在myfile文件夹中添加create_filelist.sh文件
# sudo vi examples/myfile/create_filelist.sh
并在其中加入以下代码:
create_filelist.sh
#!/usr/bin/env sh
DATA=examples/myfile/images
MY=examples/myfile
echo "Create train.txt..."
rm -rf $MY/train.txt
for i in 2 3 4 5 6
do
find $DATA/train -name $i*.jpg | cut -d '/' -f4-5 | sed "s/$/ $i/">>$MY/train.txt
done
echo "Create test.txt..."
rm -rf $MY/test.txt
for i in 2 3 4 5 6
do
find $DATA/test -name $i*.jpg | cut -d '/' -f4-5 | sed "s/$/ $i/">>$MY/test.txt
done
echo "All done"
然后,运行此脚本
# sudo sh examples/myfile/create_filelist.sh
成功的话,就会在examples/myfile/ 文件夹下生成train.txt和test.txt两个文本文件,里面就是图片的列表清单。
另外,也可以用python来制作列表清单:
# -*- coding: utf-8 -*-
import os
data_path='examples/myfile/images/'
my='examples/myfile/'
classes=[3,