日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

caffe报错:Check failed: width <= datum_width (28 vs. 17)

發布時間:2025/3/15 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 caffe报错:Check failed: width <= datum_width (28 vs. 17) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

??使用caffe建立模型的時候需要轉換LMDB格式,但轉換完成進行訓練的時候卻會報錯Check failed。這個錯誤的原因是圖片大小不匹配。在之前我一直以為在轉換之前要把所有圖片大小轉換為目標尺寸,于是自己寫了一個腳本把所有圖片大小轉換。但還是有紕漏的地方,今天發現一個更好的方法,記錄下來!
??其實也很簡單:就是把大小修改放在轉換lmdb的腳本中,在腳本中添加如下語句:

RESIZE=true if $RESIZE; thenRESIZE_HEIGHT=28RESIZE_WIDTH=28 elseRESIZE_HEIGHT=0RESIZE_WIDTH=0 fi

再把下面訓練集和測試集resize_height和resize_width參數換成上文的變量即可。

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

??發現了這個方法,覺得以前憨憨的。以后就用這個啦!

??文末附完整代碼:

#!/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."

由于作者水平有限,如有錯誤,請在下方評論區指正,謝謝!

總結

以上是生活随笔為你收集整理的caffe报错:Check failed: width <= datum_width (28 vs. 17)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。