caffe 生成lmdb代码

1、得到 ,训练测试的txt文件,格式如下
图片格式

  1. home/data_root
    2. aa
    3. bb
    4. cc
    txt格式,相对路径
    aa/img.jpg 0
    bb/3.jpg 1
    cc/1.jpg 2

2、txt,文件和图片根目录得到lmdb,显示如下
sh create_imagenet.sh
在这里插入图片描述

#!/usr/bin/env sh
# Create the imagenet lmdb inputs
# N.B. set the path to the imagenet train + val data dirs
set -e

EXAMPLE=/home/lmdb
DATA=/home/data_root
TOOLS=/home/caffel/build/tools

TRAIN_DATA_ROOT=/home/data_root/
VAL_DATA_ROOT=/home/data_root/

# 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=240
  RESIZE_WIDTH=240
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/test.txt \
    $EXAMPLE/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/test.txt \
    $EXAMPLE/val_lmdb

echo "Done."
发布了98 篇原创文章 · 获赞 141 · 访问量 26万+

猜你喜欢

转载自blog.csdn.net/m0_37192554/article/details/103694373
今日推荐