Faster R-CNN代码实战(python)日志 (过程中遇到的错误总结 疑惑解答 各种知识点记录)

目录

 

 

2018.3.19(二) 开始

报错:'NoneType' AttributeError: 'NoneType' object has no attribute 'shape'

pass和continue的区别:continue表示跳过后面的程序,重新循环,而pass表示站位,后面的代码(else之前)还是会执行

报错:ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1/Reshape_4' (op: 'Reshape') with input shapes: [1,1,1,64], [].

报错:TypeError: softmax() got an unexpected keyword argument 'axis'

用conda install keras==2.1不行,

报错:PackagesNotFoundError: The following packages are not available from current channels:

报错:Could not load pretrained model weights. Weights can be found in the keras application folder        https://github.com/fchollet/keras/tree/master/keras/applications

报错:Exception: could not broadcast input array from shape (38, 67, 18) into shape (1, 38, 67)

篮框类和背景类数量,训练集和验证集数量

python numpy数组中冒号的使用

报错:Exception: 'a' cannot be empty unless no samples are taken

报错:SSH连接错误:packet_write_wait: Connection to 10.212.48.236 port 22: Broken pipe

报错:Linux服务器:cp: omitting directory

ubuntu用命令行从官网下载python3: 

报错:Broken pipe  packet_write_wait: Connection to 10.212.48.236 port 22: Broken pipe 训练时服务器中断


 

2018.3.19(二) 开始

 

参考网址,阿里云云栖社区翻译,faster-rcnn实现:

https://y..aliyun.com/articles/679245?utm_content=g_1000031076#

 

原文:

https://www.analyticsvidhya.com/blog/2018/11/implementation-faster-r-cnn-python-object-detection/#comment-157499

 

把xml转换成csv,在转换成txt,克隆github上的仓库,把自己的训练图像和测试图片放进去,运行。

 

报错:'NoneType' AttributeError: 'NoneType' object has no attribute 'shape'

解决:

 

 

根本就没有图像000006.png

 

在simple_parser.py上加一个判断

 

pass和continue的区别:continue表示跳过后面的程序,重新循环,而pass表示站位,后面的代码(else之前)还是会执行

 

报错:ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1/Reshape_4' (op: 'Reshape') with input shapes: [1,1,1,64], [].

解决:把版本降到2.2.0就好了,本来是2.2.4,

 

 

报错:TypeError: softmax() got an unexpected keyword argument 'axis'

解决:降低keras版本

 

用conda install keras==2.1不行,

报错:PackagesNotFoundError: The following packages are not available from current channels:

解决:用pip install keras==2.1

 

删除不对应的xml之前:

 

删除不对应的xml之后:

 

 

报错:Could not load pretrained model weights. Weights can be found in the keras application folder        https://github.com/fchollet/keras/tree/master/keras/applications

解决:在CSDN上下载一个

resnet50_weights_tf_dim_ordering_tf_kernels.h5

然后放到文件夹下,在执行python文件时加上参数

--input_weight_path /Users/zxy/Desktop/zxy/GraduationDesign/keras-frcnn-master/resnet50_weights_tf_dim_ordering_tf_kernels.h5

 

报错:Exception: Error when checking target: expected rpn_out_class to have shape (None, None, None, 9) but got array with shape (1, 38, 67, 18)

解决:降低keras版本!!!降到2.0.9不会报错!!!这个bug困扰了我两天,查Google,搜索关键部分就查到了。

 

报错:Exception: could not broadcast input array from shape (38, 67, 18) into shape (1, 38, 67)

解决:一般是model原始输入图片尺寸和你实际输入图片尺寸不一样,导致报错。

篮框类和背景类数量,训练集和验证集数量

 

 

python numpy数组中冒号的使用

a[ : n]表示从第0个元素到第n个元素(不包括n),a[1: ] 表示该列表中的第1个元素到最后一个元素。

list1[:3:2],tul1[3:6:2](注意3:6是索引第3至5,不包含6)

 

第一种意思,默认全部选择:

如,X[:,0]就是取矩阵X的所有行的第0列的元素,X[:,1] 就是取所有行的第1列的元素

 

第二种意思,指定范围,注意这里含左不含右

如,X[:, m:n]即取矩阵X的所有行中的的第m到n-1列数据,含左不含右

 

cls_loss和reg_loss loss

 

 

报错:Exception: 'a' cannot be empty unless no samples are taken

解决:把background改成bg生成csv,再转换成txt,代码里仍旧写bg

 

报错:SSH连接错误:packet_write_wait: Connection to 10.212.48.236 port 22: Broken pipe

 

https://www.cnblogs.com/chentianwei/p/9866046.html

 

 

报错:Linux服务器:cp: omitting directory

解决:报错是因为目录下面还有目录,因此使用递归拷贝,在cp命令后面加上-r参数。

 

ubuntu用命令行从官网下载python3: 

  1. yum -y install gcc(gcc --version)
  2. yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel s.lite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
  3. wget https://www.python.org/ftp/python/6.8/Python-3.6.8.tgz
  4. tar -zxvf Python-3.7.0.tgz
  5. mkdir /usr/local/python3
  6. cd Python-3.7.0

./configure --prefix=/usr/local/python3

make && make install

  1. ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3

 

 

报错:Broken pipe  packet_write_wait: Connection to 10.212.48.236 port 22: Broken pipe 训练时服务器中断

解决:前往文件夹/etc/ssh/ssh_config,在Host *下添加ServerAliveInterval 300 和ServerAliveCountMax 2

 

新建一个会话窗口:

screen –S sessionName

列出所有的窗口:

screen –ls

离开这个窗口:

screen –d XXXXX

进入这个窗口:

screen –r XXXXX

分离并进入这个窗口:

screen –d –r XXXXX

重新连接到这个窗口:

screen –x XXXXX

删除这个窗口:

screen –X –S XXXXX quit

 

这是我训练过程中保存的一些模型,可以看到训练花费了很长时间。我是在服务器上用一块GPU跑的。

 

你可能感兴趣的:(机器学习)