制作自己的数据集lmdb--120类狗

来源:互联网 发布:fgo刷素材软件 编辑:程序博客网 时间:2024/06/10 04:41

caffe一定要编译通过!!!才能进行下面操作

一、在 caffe 根目录 下创建自己的文件夹My_Files

其中train

其中,train 文件夹里包含训练图片和训练图片的 labels.txt;

二、训练集和label.txt

这里写图片描述

lable.txt 中图片id 与标签用 空格 隔开

这里写图片描述

三、create_imagenet.sh

将 /examples/imagenet/create_imagenet.sh 复制到该文件夹下进行修改,进行训练和测试路径的设置,终端运行./My_Files/create_imagenet.sh

#!/usr/bin/env sh# Create the imagenet lmdb inputs# N.B. set the path to the imagenet train + val data dirsset -eEXAMPLE=My_Files/ #create_imagenet.sh所在文件夹 DATA=My_Files/train/ #lable.txt 所在文件夹TOOLS=build/tools #不能修改,convert_imageset所在文件夹TRAIN_DATA_ROOT=My_Files/train/ #训练数据所在文件夹VAL_DATA_ROOT=My_Files/val/   #验证数据所在文件夹# Set RESIZE=true to resize the images to 256x256. Leave as false if images have# already been resized using another tool.RESIZE=falseif $RESIZE; then  RESIZE_HEIGHT=256  RESIZE_WIDTH=256else  RESIZE_HEIGHT=0  RESIZE_WIDTH=0fiif [ ! -d "$TRAIN_DATA_ROOT" ]; then  echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $TRAIN_DATA_ROOT"  echo "Set the TRAIN_DATA_ROOT variable in create_imagenet.sh to the path" \       "where the ImageNet training data is stored."  exit 1fiif [ ! -d "$VAL_DATA_ROOT" ]; then  echo "Error: VAL_DATA_ROOT is not a path to a directory: $VAL_DATA_ROOT"  echo "Set the VAL_DATA_ROOT variable in create_imagenet.sh to the path" \       "where the ImageNet validation data is stored."  exit 1fiecho "Creating train lmdb..."GLOG_logtostderr=1 $TOOLS/convert_imageset \    --resize_height=$RESIZE_HEIGHT \    --resize_width=$RESIZE_WIDTH \    --shuffle \    $TRAIN_DATA_ROOT \    $DATA/train.txt \    $EXAMPLE/dogs_train_lmdb#echo "Creating val lmdb..."#GLOG_logtostderr=1 $TOOLS/convert_imageset \#    --resize_height=$RESIZE_HEIGHT \#    --resize_width=$RESIZE_WIDTH \#    --shuffle \#    $VAL_DATA_ROOT \#    $DATA/val.txt \#    $EXAMPLE/ilsvrc12_val_lmdbecho "Done."

参考博客http://blog.csdn.net/liuweizj12/article/details/52149743