日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

deeplab运行指南

發布時間:2023/12/10 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 deeplab运行指南 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

以下僅僅為一個總結,參考了網上的眾多資料,僅備忘記。

主要鏈接

  • deeplab主頁:http://liangchiehchen.com/projects/DeepLab.html
  • 官方代碼:https://bitbucket.org/aquariusjay/deeplab-public-ver2
  • python 版caffe實現:https://github.com/TheLegendAli/DeepLab-Context2
  • model下載:http://liangchiehchen.com/projects/DeepLab_Models.html
  • DeepLabv2_VGG16 預訓練模型
  • DeepLabv2_ResNet101預訓練模型
  • pytorch實現的deeplab:https://github.com/isht7/pytorch-deeplab-resnet
  • 網上開源代碼:martinkersner/train-DeepLab

主要運行步驟

如下我們主要以網上開源的一個版本講解:https://github.com/xmojiao/deeplab_v2 .
主要的步驟可以參考:
1. 圖像語義分割:從頭開始訓練deeplab v2系列之一【源碼解析】
2. 圖像語義分割:從頭開始訓練deeplab v2系列之二【VOC2012數據集】
3. Deeplab v2 調試全過程(Ubuntu 16.04+cuda8.0)

下面說一些這上面沒有的我遇到的一些問題。
1. 安裝 matio:
上面資料中都使用 matio-1.5.2.tar.gz ,但是我裝不上,可能與我的庫不兼容,于是我下載了最新的 matio-1.5.11 ,并且按照如下命令運行安裝:

cd matio-1.5.11 ./configure --prefix=/data1/... (填寫自己的安裝目錄) make make check (可略) make install 最后在bash.rc上加上 LD_LIBRARY_PATH=/your/path/to/libmatio.so.2

參考:http://blog.csdn.net/houqiqi/article/details/46469981
2. 使用的Caffe版本比較陳舊,導致會出現很多和最新環境不兼容的情況,我使用的是cuDNN6.0,cuda8.0
出現:

./include/caffe/util/cudnn.hpp: In function ‘void caffe::cudnn::createPoolingDesc(cudnnPoolingStruct**, caffe::PoolingParameter_PoolMethod, cudnnPoolingMode_t*, int, int, int, int, int, int)’: ./include/caffe/util/cudnn.hpp:127:41: error: too few arguments to function ‘cudnnStatus_t cudnnSetPooling2dDescriptor(cudnnPoolingDescriptor_t, cudnnPoolingMode_t, cudnnNanPropagation_t, int, int, int, int, int, int)’pad_h, pad_w, stride_h, stride_w));

這是由于所使用的cuDNN版本不一致的導致的,作者配置環境是cuDNN 4.0,但是5.0版本后的cuDNN接口有所變化。

解決方法 :將以下幾個文件用最新BVLC版本的caffe對應文件替換并重新編譯

./include/caffe/util/cudnn.hpp ./include/caffe/layers/cudnn_conv_layer.hpp ./include/caffe/layers/cudnn_relu_layer.hpp ./include/caffe/layers/cudnn_sigmoid_layer.hpp ./include/caffe/layers/cudnn_tanh_layer.hpp./src/caffe/layers/cudnn_conv_layer.cpp ./src/caffe/layers/cudnn_conv_layer.cu ./src/caffe/layers/cudnn_relu_layer.cpp ./src/caffe/layers/cudnn_relu_layer.cu ./src/caffe/layers/cudnn_sigmoid_layer.cpp ./src/caffe/layers/cudnn_sigmoid_layer.cu ./src/caffe/layers/cudnn_tanh_layer.cpp ./src/caffe/layers/cudnn_tanh_layer.cu

參考:http://blog.csdn.net/tianrolin/article/details/71246472
3. 如何解決deeplab v2識別結果為全黑圖像的問題?
正如作者而言:http://liangchiehchen.com/projects/DeepLab_FAQ.html

Q: When evaluating the DeepLab outputs (without CRF), I got all-background results (i.e., all black results). Is there anything wrong?A: Please double check if the name of your fc8 is fc8_voc12 in the generated test_val.prototxt or test_test.prototxt (after running run_pascal.sh). The name should be matched for initialization.

主要是作者預訓練的模型與你實際測試的模型出現了偏差。主要是fc8 的問題。
以https://github.com/xmojiao/deeplab_v2 為例,如果直接使用此代碼,則run_pascal.sh出現在voc12目錄下,而run_pascal.sh上EXP2=. ,這與官方的預設不同。官方代碼,假定run_pascal.sh應該出現在voc12上一級目錄下。 這樣最后測試時會出現fc8_voc12_1,fc8_voc12_2,fc8_voc12_3,fc8_voc12_4被忽略的情況。

另外由于測試時需要將test.prototxt復制為test_val.prototxt,所以應該主要修改test.prototxt。
test.prototxt改動如下

layer {name: "data"type: "ImageSegData"top: "data"top: "label"top: "data_dim"include {phase: TEST}transform_param {mirror: falsecrop_size: 513mean_value: 104.008mean_value: 116.669mean_value: 122.675}image_data_param {root_folder: "${DATA_ROOT}"source: "../${EXP}/list/${TEST_SET}.txt" (改變)batch_size: 1label_type: NONE} }

run_pascal.sh改變如下

#!/bin/sh ## MODIFY PATH for YOUR SETTING ROOT_DIR=/data1/caiyong.wang/data/deeplab_dataCAFFE_DIR=../deeplab-public-ver2 CAFFE_BIN=${CAFFE_DIR}/.build_release/tools/caffe.binEXP=voc12 #適應原始訓練好的模型目錄 (改變) EXP2=. #當前目錄下 (改變)if [ "${EXP2}" = "." ]; thenNUM_LABELS=21DATA_ROOT=${ROOT_DIR}/VOC_aug/dataset/ elseNUM_LABELS=0echo "Wrong EXP name" fi## Specify which model to train ########### voc12 ################ NET_ID=deeplab_largeFOV## Variables used for weakly or semi-supervisedly training #TRAIN_SET_SUFFIX= TRAIN_SET_SUFFIX=_aug#TRAIN_SET_STRONG=train #TRAIN_SET_STRONG=train200 #TRAIN_SET_STRONG=train500 #TRAIN_SET_STRONG=train1000 #TRAIN_SET_STRONG=train750#TRAIN_SET_WEAK_LEN=5000DEV_ID=0####### Create dirsCONFIG_DIR=${EXP2}/config/${NET_ID} MODEL_DIR=${EXP2}/model/${NET_ID} mkdir -p ${MODEL_DIR} LOG_DIR=${EXP2}/log/${NET_ID} mkdir -p ${LOG_DIR} export GLOG_log_dir=${LOG_DIR}## RunRUN_TRAIN=0 RUN_TEST=1 RUN_TRAIN2=0 RUN_TEST2=0## Training #1 (on train_aug)if [ ${RUN_TRAIN} -eq 1 ]; then#LIST_DIR=${EXP2}/listTRAIN_SET=train${TRAIN_SET_SUFFIX}if [ -z ${TRAIN_SET_WEAK_LEN} ]; thenTRAIN_SET_WEAK=${TRAIN_SET}_diff_${TRAIN_SET_STRONG}comm -3 ${LIST_DIR}/${TRAIN_SET}.txt ${LIST_DIR}/${TRAIN_SET_STRONG}.txt > ${LIST_DIR}/${TRAIN_SET_WEAK}.txtelseTRAIN_SET_WEAK=${TRAIN_SET}_diff_${TRAIN_SET_STRONG}_head${TRAIN_SET_WEAK_LEN}comm -3 ${LIST_DIR}/${TRAIN_SET}.txt ${LIST_DIR}/${TRAIN_SET_STRONG}.txt | head -n ${TRAIN_SET_WEAK_LEN} > ${LIST_DIR}/${TRAIN_SET_WEAK}.txtfi#MODEL=${EXP2}/model/${NET_ID}/init.caffemodel#echo Training net ${EXP2}/${NET_ID}for pname in train solver; dosed "$(eval echo $(cat sub.sed))" \${CONFIG_DIR}/${pname}.prototxt > ${CONFIG_DIR}/${pname}_${TRAIN_SET}.prototxtdoneCMD="${CAFFE_BIN} train \--solver=${CONFIG_DIR}/solver_${TRAIN_SET}.prototxt \--gpu=${DEV_ID}"if [ -f ${MODEL} ]; thenCMD="${CMD} --weights=${MODEL}"fiecho Running ${CMD} && ${CMD} fi## Test #1 specification (on val or test)if [ ${RUN_TEST} -eq 1 ]; then#for TEST_SET in val; doTEST_ITER=`cat ${EXP2}/list/${TEST_SET}.txt | wc -l`MODEL=${EXP2}/model/${NET_ID}/test.caffemodelif [ ! -f ${MODEL} ]; thenMODEL=`ls -t ${EXP2}/model/${NET_ID}/train_iter_*.caffemodel | head -n 1`fi#echo Testing net ${EXP2}/${NET_ID}FEATURE_DIR=${EXP2}/features/${NET_ID}mkdir -p ${FEATURE_DIR}/${TEST_SET}/fc8mkdir -p ${FEATURE_DIR}/${TEST_SET}/fc9mkdir -p ${FEATURE_DIR}/${TEST_SET}/seg_scoresed "$(eval echo $(cat sub.sed))" \${CONFIG_DIR}/test.prototxt > ${CONFIG_DIR}/test_${TEST_SET}.prototxtCMD="${CAFFE_BIN} test \--model=${CONFIG_DIR}/test_${TEST_SET}.prototxt \--weights=${MODEL} \--gpu=${DEV_ID} \--iterations=${TEST_ITER}"echo Running ${CMD} && ${CMD}done fi## Training #2 (finetune on trainval_aug)if [ ${RUN_TRAIN2} -eq 1 ]; then#LIST_DIR=${EXP2}/listTRAIN_SET=trainval${TRAIN_SET_SUFFIX}if [ -z ${TRAIN_SET_WEAK_LEN} ]; thenTRAIN_SET_WEAK=${TRAIN_SET}_diff_${TRAIN_SET_STRONG}comm -3 ${LIST_DIR}/${TRAIN_SET}.txt ${LIST_DIR}/${TRAIN_SET_STRONG}.txt > ${LIST_DIR}/${TRAIN_SET_WEAK}.txtelseTRAIN_SET_WEAK=${TRAIN_SET}_diff_${TRAIN_SET_STRONG}_head${TRAIN_SET_WEAK_LEN}comm -3 ${LIST_DIR}/${TRAIN_SET}.txt ${LIST_DIR}/${TRAIN_SET_STRONG}.txt | head -n ${TRAIN_SET_WEAK_LEN} > ${LIST_DIR}/${TRAIN_SET_WEAK}.txtfi#MODEL=${EXP2}/model/${NET_ID}/init2.caffemodelif [ ! -f ${MODEL} ]; thenMODEL=`ls -t ${EXP2}/model/${NET_ID}/train_iter_*.caffemodel | head -n 1`fi#echo Training2 net ${EXP2}/${NET_ID}for pname in train solver2; dosed "$(eval echo $(cat sub.sed))" \${CONFIG_DIR}/${pname}.prototxt > ${CONFIG_DIR}/${pname}_${TRAIN_SET}.prototxtdoneCMD="${CAFFE_BIN} train \--solver=${CONFIG_DIR}/solver2_${TRAIN_SET}.prototxt \--weights=${MODEL} \--gpu=${DEV_ID}"echo Running ${CMD} && ${CMD} fi## Test #2 on official test setif [ ${RUN_TEST2} -eq 1 ]; then#for TEST_SET in val test; doTEST_ITER=`cat ${EXP2}/list/${TEST_SET}.txt | wc -l`MODEL=${EXP2}/model/${NET_ID}/test2.caffemodelif [ ! -f ${MODEL} ]; thenMODEL=`ls -t ${EXP2}/model/${NET_ID}/train2_iter_*.caffemodel | head -n 1`fi#echo Testing2 net ${EXP2}/${NET_ID}FEATURE_DIR=${EXP2}/features2/${NET_ID}mkdir -p ${FEATURE_DIR}/${TEST_SET}/fc8mkdir -p ${FEATURE_DIR}/${TEST_SET}/crfsed "$(eval echo $(cat sub.sed))" \${CONFIG_DIR}/test.prototxt > ${CONFIG_DIR}/test_${TEST_SET}.prototxtCMD="${CAFFE_BIN} test \--model=${CONFIG_DIR}/test_${TEST_SET}.prototxt \--weights=${MODEL} \--gpu=${DEV_ID} \--iterations=${TEST_ITER}"echo Running ${CMD} && ${CMD}done fi

總結

以上是生活随笔為你收集整理的deeplab运行指南的全部內容,希望文章能夠幫你解決所遇到的問題。

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