rcmalli / keras-vggface

VGGFace implementation with Keras Framework
MIT License
928 stars 417 forks source link

cannot import name '_obtain_input_shape' #46

Closed TXien closed 5 years ago

TXien commented 5 years ago

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

pomelyu commented 5 years ago

PR https://github.com/rcmalli/keras-vggface/pull/45 fix the issue

stevenveenma commented 5 years ago

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'
Finniu commented 5 years ago

fixed here from from keras.applications.imagenet_utils import _obtain_input_shape to from keras_applications.imagenet_utils import _obtain_input_shape

Catalyst-47 commented 5 years ago

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

rcmalli commented 5 years ago

This problem is already solved a long time ago. Closing it for now. Please reopen if you still have the problem.

mikechen66 commented 4 years ago

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

mlewan01 commented 3 years ago

you still have to make sure that it is available in your system:

pip install keras_applications