Caffe的数据集准备

时间:2019-12-26 09:52:24

标签: python caffe lmdb

我是机器学习的新手,并通过使用caffe框架准备了用于面部检测的模型。 我创建了我的daddase,并对其进行了排序。我已经创建了train.txt和val.txt,其中三元分类和图像类也相应地将图片移动到相应的存储库中。

现在,当我准备数据库进行培训时,我无法成功转换lmdb文件夹。我总是遇到一个问题。

首先,我认为自己的道路不正确,但是我尝试了所有事情,但仍然遇到错误。这是错误和代码的图片。

有人可以帮我解决这个问题吗?

我运行以下脚本来创建lmdb(sh示例/FaceDetection/create_lmdb.sh)

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

    EXAMPLE=/home/hashim/caffe/examples/imagenet

    DATA=/home/hashim/Desktop/IVP/Face_6k

    TOOLS=build/tools

    TRAIN_DATA_ROOT=/home/hashim/Desktop/IVP/Face_6k

    VAL_DATA_ROOT=/home/hashim/Desktop/IVP/Face_6k

    # Set RESIZE=true to resize the images to 256x256. Leave as false if images have
    # already been resized using another tool.

    RESIZE=false

    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/ilsvrc12_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_lmdb



    echo "Done."

我得到以下输出:

正在创建火车lmdb ...

    I1226 10:25:36.794904  3324 convert_imageset.cpp:86] Shuffling data

    I1226 10:25:36.795342  3324 convert_imageset.cpp:89] A total of 3602 images.

    F1226 10:25:36.796409  3324 db_lmdb.cpp:13] Check failed: mkdir(source.c_str(), 0744) == 0 (-1 
    vs. 0) mkdir /home/hashim/caffe/examples/imagenet/ilsvrc12_train_lmdb failed

    *** Check failure stack trace: ***

        @     0x7fe6b4bf20cd  google::LogMessage::Fail()

        @     0x7fe6b4bf3f33  google::LogMessage::SendToLog()

        @     0x7fe6b4bf1c28  google::LogMessage::Flush()

        @     0x7fe6b4bf4999  google::LogMessageFatal::~LogMessageFatal()

        @     0x7fe6b4febbe8  caffe::db::LMDB::Open()

        @     0x558490bb05e9  (unknown)

        @     0x7fe6b39f2b97  __libc_start_main

        @     0x558490bb186a  (unknown)

    Aborted (core dumped)



    Creating val lmdb...

    I1226 10:25:36.966315  3334 convert_imageset.cpp:86] Shuffling data

    I1226 10:25:36.966552  3334 convert_imageset.cpp:89] A total of 1197 images.

    F1226 10:25:36.966617  3334 db_lmdb.cpp:13] Check failed: mkdir(source.c_str(), 0744) == 0 (-1 vs. 0) mkdir /home/hashim/caffe/examples/imagenet/ilsvrc12_val_lmdb failed

    *** Check failure stack trace: ***

        @     0x7f999df730cd  google::LogMessage::Fail()

        @     0x7f999df74f33  google::LogMessage::SendToLog()

        @     0x7f999df72c28  google::LogMessage::Flush()

        @     0x7f999df75999  google::LogMessageFatal::~LogMessageFatal()

        @     0x7f999e36cbe8  caffe::db::LMDB::Open()

        @     0x5614b3ed95e9  (unknown)

        @     0x7f999cd73b97  __libc_start_main

        @     0x5614b3eda86a  (unknown)

    Aborted (core dumped)

    Done.

请帮助我解决这个问题。谢谢。

1 个答案:

答案 0 :(得分:0)

您的程序似乎正在尝试创建目录/home/hashim/caffe/examples/imagenet/ilsvrc12_train_lmdb,但失败了。我建议检查以下内容:

  • 通向ilsvrc12_train_lmdb的路径中的所有父目录是否存在?
  • 如果存在父目录,那么运行脚本的用户帐户是否对所有父目录都具有正确的权限?权限是否足以允许该用户创建此目录?
  • 您是否尝试过在运行程序之前手动创建目录?您可以对-p命令使用mkdir标志来创建任何缺少的中间目录:
mkdir -p /home/hashim/caffe/examples/imagenet/ilsvrc12_train_lmdb
  • 您是否尝试将EXAMPLE设置为其他目录?

不过,很可能是权限问题。