cannot import name '_obtain_input_shape'
TXien opened this issue · 7 comments
Bug reports:
File "test.py", line 3, in
import keras_vggface
File "/home/tung/.local/lib/python3.6/site-packages/keras_vggface/init.py", line 1, in
from keras_vggface.vggface import VGGFace
File "/home/tung/.local/lib/python3.6/site-packages/keras_vggface/vggface.py", line 9, in
from keras_vggface.models import RESNET50, VGG16, SENET50
File "/home/tung/.local/lib/python3.6/site-packages/keras_vggface/models.py", line 15, in
from keras.applications.imagenet_utils import _obtain_input_shape
ImportError: cannot import name '_obtain_input_shape'
Code Sample:
import keras_vggface
This issue still occurs using Google colab:
Keras==2.2.2 (or 2.2.4)
Keras-Applications==1.0.6
Keras-Preprocessing==1.0.5
keras-vggface==0.5
Complete error:
ImportError` Traceback (most recent call last)
<ipython-input-6-291987935bc9> in <module>()
11 from sklearn.model_selection import train_test_split
12 from keras.preprocessing.image import load_img
---> 13 from keras_vggface.vggface import VGGFace
14 from keras_vggface import utils
/usr/local/lib/python3.6/dist-packages/keras_vggface/__init__.py in <module>()
----> 1 from keras_vggface.vggface import VGGFace
2 from keras_vggface.version import __version__
/usr/local/lib/python3.6/dist-packages/keras_vggface/vggface.py in <module>()
7 '''
8 from __future__ import print_function
----> 9 from keras_vggface.models import RESNET50, VGG16, SENET50
10
11
/usr/local/lib/python3.6/dist-packages/keras_vggface/models.py in <module>()
13 GlobalMaxPooling2D, Activation, Conv2D, MaxPooling2D, BatchNormalization, \
14 AveragePooling2D, Reshape, Permute, multiply
---> 15 from keras.applications.imagenet_utils import _obtain_input_shape
16 from keras.utils import layer_utils
17 from keras.utils.data_utils import get_file
ImportError: cannot import name '_obtain_input_shape'
fixed here
from
from keras.applications.imagenet_utils import _obtain_input_shape
to
from keras_applications.imagenet_utils import _obtain_input_shape
I am getting this error when changing keras.applications to keras_applications
File "D:\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "D:\Anaconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/aravind/Desktop/Machine Learning/ML Mastery/First week/vggface_test.py", line 45, in
model = VGGFace(model='resnet50')
File "D:\Anaconda\lib\site-packages\keras_vggface\vggface.py", line 97, in VGGFace
classes=classes)
File "D:\Anaconda\lib\site-packages\keras_vggface\models.py", line 232, in RESNET50
name='conv1/7x7_s2')(img_input)
File "D:\Anaconda\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "D:\Anaconda\lib\site-packages\keras\layers\convolutional.py", line 473, in init
super(Conv2D, self).init(
TypeError: super(type, obj): obj must be an instance or subtype of type
This problem is already solved a long time ago. Closing it for now. Please reopen if you still have the problem.
keras_applications.imagenet_utils is deprecated
Traceback (most recent call last):
File "inception_v3.py", line 36, in
from keras_applications.imagenet_utils import _obtain_input_shape
ModuleNotFoundError: No module named 'keras_application
you still have to make sure that it is available in your system:
pip install keras_applications