caffe报错:Check failed: width <= datum_width (28 vs. 17)
生活随笔
收集整理的這篇文章主要介紹了
caffe报错:Check failed: width <= datum_width (28 vs. 17)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
??使用caffe建立模型的時(shí)候需要轉(zhuǎn)換LMDB格式,但轉(zhuǎn)換完成進(jìn)行訓(xùn)練的時(shí)候卻會(huì)報(bào)錯(cuò)Check failed。這個(gè)錯(cuò)誤的原因是圖片大小不匹配。在之前我一直以為在轉(zhuǎn)換之前要把所有圖片大小轉(zhuǎn)換為目標(biāo)尺寸,于是自己寫了一個(gè)腳本把所有圖片大小轉(zhuǎn)換。但還是有紕漏的地方,今天發(fā)現(xiàn)一個(gè)更好的方法,記錄下來(lái)!
??其實(shí)也很簡(jiǎn)單:就是把大小修改放在轉(zhuǎn)換lmdb的腳本中,在腳本中添加如下語(yǔ)句:
再把下面訓(xùn)練集和測(cè)試集resize_height和resize_width參數(shù)換成上文的變量即可。
GLOG_logtostderr=1 $TOOLS/convert_imageset \--resize_height=$RESIZE_HEIGHT \--resize_width=$RESIZE_WIDTH \--shuffle \$TRAIN_DATA_ROOT \$DATA/train.txt \$EXAMPLE/TibetanWord_train_lmdb??發(fā)現(xiàn)了這個(gè)方法,覺得以前憨憨的。以后就用這個(gè)啦!
??文末附完整代碼:
#!/usr/bin/env sh # Create the imagenet lmdb inputs # N.B. set the path to the imagenet train + val data dirs set -eEXAMPLE=examples/TibetanWord DATA=examples/TibetanWord TOOLS=build/tools#TRAIN_DATA_ROOT=/home/user/caffe/examples/TibetanWord/train/ TRAIN_DATA_ROOT=examples/TibetanWord/ #VAL_DATA_ROOT=/home/user/caffe/examples/TibetanWord/test/ VAL_DATA_ROOT=examples/TibetanWord/rm -rf $EXAMPLE/TibetanWord_train_lmdb rm -rf $EXAMPLE/TibetanWord_test_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; thenRESIZE_HEIGHT=28RESIZE_WIDTH=28 elseRESIZE_HEIGHT=0RESIZE_WIDTH=0 fiif [ ! -d "$TRAIN_DATA_ROOT" ]; thenecho "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 fiif [ ! -d "$VAL_DATA_ROOT" ]; thenecho "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 fiecho "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/TibetanWord_train_lmdbecho "train finish" 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/TibetanWord_test_lmdbecho "Done."由于作者水平有限,如有錯(cuò)誤,請(qǐng)?jiān)谙路皆u(píng)論區(qū)指正,謝謝!
總結(jié)
以上是生活随笔為你收集整理的caffe报错:Check failed: width <= datum_width (28 vs. 17)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 《论文笔记》COVINS: Visual
- 下一篇: QT5基础操作(一)