kentaroy47 / frcnn-from-scratch-with-keras

:collision:Faster R-CNN from scratch written with Keras
Apache License 2.0
168 stars 106 forks source link

Which version of keras should I use? #25

Closed tossy-yossy closed 5 years ago

tossy-yossy commented 5 years ago

As an example, I want to set up VOC2007 training.

I got the following error when using Keras 2.2.5.

$ python train_frcnn.py --network mobilenetv1 -p ./VOCdevkit
Using TensorFlow backend.
Traceback (most recent call last):
  File "train_frcnn.py", line 16, in <module>
    from keras_frcnn import losses as losses
  File "/Volumes/HD-EDS-A/Works/frcnn2/keras_frcnn/losses.py", line 4, in <module>
    if K.image_dim_ordering() == 'tf':
AttributeError: module 'keras.backend' has no attribute 'image_dim_ordering'

In Keras 2.2.x, image_dim_ordering seems to have been renamed to image_data_format, so I downgraded it to 2.1.6. But got a different error.

$ python train_frcnn.py --network mobilenetv1 -p ./VOCdevkit
Using TensorFlow backend.
WARNING: Logging before flag parsing goes to stderr.
W0828 18:12:06.414109 4485621184 deprecation_wrapper.py:119] From train_frcnn.py:23: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

W0828 18:12:06.414335 4485621184 deprecation_wrapper.py:119] From train_frcnn.py:25: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.

Traceback (most recent call last):
  File "train_frcnn.py", line 88, in <module>
    from keras_frcnn import mobilenetv1 as nn
  File "/Volumes/HD-EDS-A/Works/frcnn2/keras_frcnn/mobilenetv1.py", line 14, in <module>
    from keras.layers import Flatten, Dense, Input, Conv2D, MaxPooling2D, Dropout, BatchNormalization, Add, ReLU
ImportError: cannot import name 'ReLU' from 'keras.layers' (/Users/toshi/.pyenv/versions/anaconda3-2019.03/lib/python3.7/site-packages/keras/layers/__init__.py)

ReLU is defined in later Keras versions 2.2.x. How can I try VOC2007 training?

kentaroy47 commented 5 years ago

I currently test with Keras 2.2.4 and both 2.1.x should work as well. (with tf=1.12.0) It is weird that you cannot load ReLu, can you try reinstalling Keras?

tossy-yossy commented 5 years ago

Thank you for your reply. An error occurred on OS X (Mojave), but it worked fine on Google Colab. I would try setting up on OS X again.

tossy-yossy commented 5 years ago

After installing Keras 2.2.4 on OS X, the problem disappeared. Thank you.