1. 深度学习目标检测系列:faster RCNN实现|附python源码
https://yq.aliyun.com/articles/679245
2. 目标检测算法图解:
译文:一文看懂RCNN系列算法
https://zhuanlan.zhihu.com/p/52379393
原文:A Step-by-Step Introduction to the Basic Object Detection Algorithms (Part 1)
3. Github下的项目:keras-frcnn
https://github.com/kbardool/keras-frcnn
该项目在运行时,出现了如下错误:
Traceback (most recent call last):
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1864, in _create_c_op
c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 1 but is rank 0 for 'bn_conv1/Reshape_4' (op: 'Reshape') with input shapes: [1,1,1,64], [].
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "train_frcnn.py", line 122, in <module>
shared_layers = nn.nn_base(img_input, trainable=True)
File "D:\OneDrive - Continental AG\Develop\PCB\Code-Ref\keras-frcnn-master\keras_frcnn\resnet.py", line 180, in nn_base
x = FixedBatchNormalization(axis=bn_axis, name='bn_conv1')(x)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\keras\engine\base_layer.py", line 457, in __call__
output = self.call(inputs, **kwargs)
File "D:\OneDrive - Continental AG\Develop\PCB\Code-Ref\keras-frcnn-master\keras_frcnn\FixedBatchNormalization.py", line 73, in call
epsilon=self.epsilon)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\keras\backend\tensorflow_backend.py", line 1908, in batch_normalization
mean = tf.reshape(mean, (-1))
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 7714, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
op_def=op_def)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
op_def=op_def)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 2027, in __init__
control_input_ops)
File "C:\Users\uidt8491\AppData\Local\Continuum\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\framework\ops.py", line 1867, in _create_c_op
raise ValueError(str(e))
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种:
https://github.com/kbardool/keras-frcnn/issues/23
https://github.com/keras-team/keras/commit/e3a2f7d29f2f1c21ecc978bd0038b1d1330d33c2
4. 在Jetson下进行训练,安装Keras:
尝试用pip方式安装,安装失败
用apt-get安装,成功:
$ sudo apt-get install python3-keras
查看keras的版本:
$ python3 -W ignore -c "import keras; print('Keras Version:',keras.__version__)"
发现在Arm64位的Ubuntu 18.0.4下,Keras的最高版本是2.1.1-1., 运行时会产生如下错误:
Exception: Error when checking target: expected rpn_out_class to have shape (None, None, None, 9) but got array with shape (1, 56, 38, 18)
我在Windows里面可以正常运行,而Windows里的Keras是2.2.4版本,所以需要手动升级Ubuntu下的Keras
方法:
1. 从github下载2.2.4版本的Keras
https://github.com/keras-team/keras/tree/2.2.4
2. 下载后,解压缩到某个文件夹。
3. 编辑解压缩文件夹中的keras/backend/tensorflow_backend.py文件。
由于Keras 2.2.4会出现如下错误:
Shape must be rank 1 but is rank 0 for 'bn_conv1/Reshape_4' (op: 'Reshape') with input shapes: [1,1,1,64], [].
根据上面文章的提示,对keras/backend/tensorflow_backend.py进行编辑,更改如下:
原文链接:https://github.com/keras-team/keras/commit/e3a2f7d29f2f1c21ecc978bd0038b1d1330d33c2
4. 根据github上面的Readme.md的指导,在该文件夹下执行如下命令安装:
sudo python3 setup.py install
根据以上步骤,keras-fcnn的training可以在Arm64的Ubuntu 18.0.4下顺利运行。