我想做一些微调来训练我的jpg。在大量文档的指导下,我主要修改了create_imagenet.sh中的data、txt和tool的路径,具体如下:
#!/usr/bin/env sh
# This script converts the mnist data into lmdb/leveldb format,
# depending on the value assigned to $BACKEND.
set -e
EXAMPLE=/home/sun/Documents/python/fine-tuning/Oxford102/data/test
DATA_TEST=/home/sun/Documents/python/fine-tuning/Oxford102/data/test/test/
DATA_TRAIN=/home/sun/Documents/python/fine-tuning/Oxford102/data/test/train/
NOTI=/home/sun/Documents/python/fine-tuning/Oxford102/data/test
BUILD=/home/sun/Documents/caffe/build/tools
#BACKEND="lmdb"
# Set RESIZE=true to resize the images to 256x256. Leave as false if images have
# already been resized using another tool.
RESIZE=true
if $RESIZE; then
RESIZE_HEIGHT=256
RESIZE_WIDTH=256
else
RESIZE_HEIGHT=0
RESIZE_WIDTH=0
fi
if [ ! -d "$DATA_TRAIN" ]; then
echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $DATA_TRAIN"
echo "Set the TRAIN_DATA_ROOT variable in create_imagenet.sh to the path" \
"where the ImageNet training data is stored."
exit 1
fi
if [ ! -d "$DATA_TEST" ]; then
echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $DATA_TEST"
echo "Set the TRAIN_DATA_ROOT variable in create_imagenet.sh to the path" \
"where the ImageNet training data is stored."
exit 1
fi
echo "Creating train lmdb..."
GLOG_logtostderr=1 $BUILD/convert_imageset \
--resize_height=$RESIZE_HEIGHT \
--resize_width=$RESIZE_WIDTH \
--shuffle \
$DATA_TRAIN \
$NOTI/info_train.txt \
$EXAMPLE/img_train_lmdb
echo "Creating test lmdb..."
GLOG_logtostderr=1 $BUILD/convert_imageset \
--resize_height=$RESIZE_HEIGHT \
--resize_width=$RESIZE_WIDTH \
--shuffle \
$DATA_TEST \
$NOTI/info_test.txt \
$EXAMPLE/img_test_lmdb
echo "Done."然后我在终端中运行'sudo sh create_oxford.sh‘,但是什么也得不到。
此外,我的文档结构如下:
在/home/sun/Documents/python/fine-tuning/Oxford102/data/test,中,我放入了info_test.txt、info_train.txt、test(jpg表示测试)和train(jpg表示火车)。在txt中,信息类似于'image_0001.jpg 0‘。
发布于 2018-06-06 18:13:01
1)我成功地运行了代码。
2)当命令行参数没有正确传递时,我得到了用法但什么也得不到。
3)您可以使用以下命令来调试您的-vx脚本: set shell它将显示如下所示的实际论点:
调整高度-- +/home/u5652/.conda/envs/riCffAlex3.6/bin/convert_imageset _=256--调整大小_宽度=256
convert_imageset:将一组图像转换为leveldb/lmdb格式,用作Caffe的输入。用法: convert_imageset标志ROOTFOLDER/ LISTFILE DB_NAME .....................
根据caffe/tools/convert_imageset.cpp:
if (argc < 4) {
gflags::ShowUsageWithFlagsRestrict(argv[0], "tools/convert_imageset");
return 1;
}最小参数应该是4,否则它将显示用法。由于参数不正确,您一定一直在获取用法,但什么也得不到。
4)我运行了以下代码,并成功创建了lmdb:
#!/usr/bin/env sh
set -vx
EXAMPLE=examples/imagenet/test
DATA=data/ilsvrc12/test
TOOLS=~/.conda/envs/riCffAlex3.6/bin
TRAIN_DATA_ROOT=~/caffe/data/ilsvrc12/test/train/
VAL_DATA_ROOT=~/caffe/data/ilsvrc12/test/test/
RESIZE=true
if $RESIZE; then
RESIZE_HEIGHT=256
RESIZE_WIDTH=256
else
RESIZE_HEIGHT=0
RESIZE_WIDTH=0
fi
if [ ! -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 1
fi
if [ ! -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 1
fi
echo "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/train_lmdb
echo "Creating test lmdb..."
GLOG_logtostderr=1 $TOOLS/convert_imageset \
--resize_height=$RESIZE_HEIGHT \
--resize_width=$RESIZE_WIDTH \
--shuffle \
$VAL_DATA_ROOT \
$DATA/val.txt \
$EXAMPLE/test_lmdb
echo "Done."5)我把细节放在和你放在.txt文件里一样的格式。我输入: TestJpg.jpg 0
注意:图像的名称和扩展名应该与您放入.txt中的名称和扩展名相同
试试这条路。您的错误应该得到解决。
谢谢
https://stackoverflow.com/questions/50636798
复制相似问题