【计算机视觉】(二)DeepFashion成功复现!代码复现碰到的问题和坎坷,包括代码修改和cudnn库的匹配,

源代码github地址

https://github.com/abhishekrana/DeepFashion

环境:ubuntu

           python2.7

问题一:直接运行./dataset_download.sh命令无法下载img.zip

解决方法

百度网盘链接:

github中只用下载category and attribute那个文件夹就行了

自己从百度网盘下载然后解压缩包,构造格式为:


 

问题二:python dataset_create.py 提示没有文件夹

解决方法

在config.py文件中修改 fashion_dataset_path那一行,改为 

fashion_dataset_path = 'fashion_data/'

另外提示

构造数据集时间挺长的,大概15-20min。

问题三

我们学校的服务器不能连接外网,所以不能从github上下载东西,在vgg16上出现了问题

在train文件import 位置加上

from keras.applications.vgg16 import VGG16

然后修改model那一行,把applications去掉

改为model = VGG16(括号里面内容不变)

这个东西无法避免,只能回去解决了,。

最后我还是先解决了服务器的上网问题,学习还是有进步的~

我们继续

现在已经实战到了python train.py 的地方了

可能也需要比较长的时间,我们开始计时吧,开始时间为10:53,结束时间:10:55,出错了,我看看是什么问题

 

问题四

就是我cuda 库的版本为7.0 但是他的版本是7.1.4 需要更新cuda 

问题

解决方法:

(1)删除旧版本


sudo rm -rf /usr/local/cuda/include/cudnn.h

sudo rm -rf /usr/local/cuda/lib64/libcudnn

(2)注册账号,下载cudnn库,下载地址,

注意千万不要下载deb结尾的,死活安装不上,解决不了

下载for linux的,cudnn-9.0-linux-x64-v7.1.solitairetheme8

修改结尾文件名cudnn-9.0-linux-x64-v7.1.tgz

然后直接解压

tar zxvf cudnn-9.0-linux-x64-v7.1.tgz

然后 

cd cuda

sudo cp include/cudnn.h /usr/local/cuda/include/

sudo cp lib64/lib* /usr/local/cuda/lib64/

(3)建立软连接

sudo chmod +r libcudnn.so.7.1.4

sudo ln -sf libcudnn.so.7.1.4 libcudnn.so.7

sudo ln -sf libcudnn.so.7 libcudnn.so

sudo ldconfig
(4)查看安装结果

cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
显示

#define CUDNN_MAJOR 7
#define CUDNN_MINOR 1
#define CUDNN_PATCHLEVEL 4
--
#define CUDNN_VERSION    (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
成功!

 

在运行python train.py  目前没有什么问题,希望一切顺利

训练需要挺久的,但是我下去玩了一个小时,也不太清楚具体运行了多久。

下面就到了predict 部分

运行 python predict.py 出现了新的问题

错误提示为:

 No such file or directory: 'dataset_prediction/crops/jeans_crop-159_0_421_252.jpg'
解决方法:

修改utils.py文件202行处代码

img_crop.save('dataset_prediction/crops/' + img_crop_name)

为img_crop.save('dataset_prediction/images/' + img_crop_name)

 

修改predict.py文件67行代码

prediction_dataset_path='dataset_prediction/crops/'

prediction_dataset_path='dataset_prediction/images/'

 

或者建立crops文件夹,更推荐建立文件夹。

 

 

问题五

错误提示为:

IOError: Unable to open file (unable to open file: name = 'output/best-weights-011-1.3547.hdf5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
 

解决方法:

修改config文件,58行

top_model_weights_path_load = 'output/best-weights-011-1.3547.hdf5'

改为top_model_weights_path_load = 'output/best-weights-001-0.1637.hdf5'  #自己查看output目录选择一个

 

问题六

ValueError: Layer #9 (named "predictions_class"), weight <tf.Variable 'predictions_class/kernel:0' shape=(256, 19) dtype=float32_ref> has shape (256, 19), but the saved weight has shape (256, 3).
解决方法

主要还是数据的问题,在将原始数据转变为我们所需要的数据dataset_create.py文件运行后,将原始数据转变为我们所需要的数据,请修改dataset_create.py第56行,category_name_generate,这是分类目标目录。修改为第49行即可。

重新产生数据,运行即可。

或在predict.py文件第30行,修改class_name也可以。

 

predict也需要很久

结果:


 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章