keras-gcnn icon indicating copy to clipboard operation
keras-gcnn copied to clipboard

ImportError: cannot import name '_obtain_input_shape'

Open SteveIb opened this issue 5 years ago • 3 comments

Hi, I installed the repository as stated, I have python 3.5 on anaconda When I try to run the working exmaple : python g_densnet_cifar.py I get the following error:

Using TensorFlow backend. Traceback (most recent call last): File "g_densnet_cifar.py", line 20, in from keras_gcnn.applications.densenetnew import GDenseNet File "****/src/keras-gcnn/keras_gcnn/applications/densenetnew.py", line 17, in from keras.applications.imagenet_utils import _obtain_input_shape ImportError: cannot import name '_obtain_input_shape'

SteveIb avatar Mar 19 '19 13:03 SteveIb

Hi, I had the same problem. I changed from keras_applications.imagenet_utils import _obtain_input_shape to from keras.applications.imagenet_utils import _obtain_input_shape and it worked. Now I get another Error. According Stackoverflow you can also downgrade your Keras to 2.2.0. This did not work for me. If you found the way to use the code, please let me know ;-)

andyfilip avatar Mar 19 '19 14:03 andyfilip

Hi all,

Thanks for bringing up this issue! I'm a bit swamped right now due to conference deadlines and do not have time to look into this. If you find a solution in the mean time: please share here. PRs are welcome too, but I understand that that's a bit of a hassle.

basveeling avatar Mar 19 '19 14:03 basveeling

@andyfilip your solution was correct, change keras_applications. downgrade 2.2.2. I just created a new env conda variable 3.6 i used to use 3.5 one more thing you have to install keras-contrib (https://github.com/keras-team/keras-contrib)

git clone https://www.github.com/keras-team/keras-contrib.git cd keras-contrib python convert_to_tf_keras.py USE_TF_KERAS=1 python setup.py install

now i'm getting the following error when i run the exmaple python g_densnet_cifar.py

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "g_densnet_cifar.py", line 54, in (trainX, trainY), (testX, testY) = cifar10.load_data() File "/home/dell/anaconda2/envs/Py36/lib/python3.6/site-packages/keras/datasets/cifar10.py", line 22, in load_data path = get_file(dirname, origin=origin, untar=True) File "/home/dell/anaconda2/envs/Py36/lib/python3.6/site-packages/keras/utils/data_utils.py", line 224, in get_file raise Exception(error_msg.format(origin, e.errno, e.reason)) Exception: URL fetch failure on https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz: None -- Internal Server Error

it seems that the file removed, I will check if i can find it somewhere and I will let you know!

SteveIb avatar Mar 21 '19 09:03 SteveIb