2

When I run

from keras_vggface.vggface import VGGFace

# Based on VGG16 architecture -> old paper(2015)
vggface = VGGFace(model='vgg16') # or VGGFace() as default

# Based on RESNET50 architecture -> new paper(2017)
vggface = VGGFace(model='resnet50')

# Based on SENET50 architecture -> new paper(2017)
vggface = VGGFace(model='senet50')

in instructions.

I got this error

ImportError: cannot import name '_obtain_input_shape'

I follow the instructions in install the keras_vggface. And here is a list info of my packages.

# packages in environment at /Users/lzq/anaconda3/envs/py36_faceRec:
#
# Name                    Version                   Build  Channel
bleach                    1.5.0                     <pip>
ca-certificates           2018.03.07                    0  
certifi                   2018.10.15               py36_0  
enum34                    1.1.6                     <pip>
h5py                      2.8.0                     <pip>
html5lib                  0.9999999                 <pip>
Keras                     2.1.1                     <pip>
keras-vggface             0.5                       <pip>
libcxx                    4.0.1                hcfea43d_1  
libcxxabi                 4.0.1                hcfea43d_1  
libedit                   3.1.20170329         hb402a30_2  
libffi                    3.2.1                h475c297_4  
Markdown                  3.0.1                     <pip>
ncurses                   6.1                  h0a44026_0  
numpy                     1.15.4                    <pip>
openssl                   1.1.1                h1de35cc_0  
Pillow                    5.3.0                     <pip>
pip                       18.1                     py36_0  
protobuf                  3.6.1                     <pip>
python                    3.6.7                haf84260_0  
PyYAML                    3.13                      <pip>
readline                  7.0                  h1de35cc_5  
scipy                     1.1.0                     <pip>
setuptools                40.5.0                   py36_0  
six                       1.11.0                    <pip>
sqlite                    3.25.2               ha441bb4_0  
tensorflow                1.4.0                     <pip>
tensorflow-tensorboard    0.4.0                     <pip>
tk                        8.6.8                ha441bb4_0  
Werkzeug                  0.14.1                    <pip>
wheel                     0.32.2                   py36_0  
xz                        5.2.4                h1de35cc_4  
zlib                      1.2.11               hf3cbc9b_2 
Pengfei Li
  • 21
  • 1
  • 3
  • What research have you done? Show what steps you have taken to solve this in the question with an [edit]. For example, how is https://stackoverflow.com/q/49113140/1531971 not a duplicate issue? –  Nov 13 '18 at 16:00
  • It is not a duplicate. I did not run "from keras.applications.imagenet_utils import _obtain_input_shape", I just tried to study the package and run some simple codes in the link I provided – Pengfei Li Nov 13 '18 at 16:07
  • You need to prove that all the advice in that link does not apply here. What versions are you trying to use? Have you proven the assertion that the version(s) you think you have are being used? There is a lot of info in that related link, and it is your responsibility to tell us how none of it applies. The fact is that `_obtain_input_shape` does not exist in your version of this dependency, and this is _required_ to import the dependency. Find out why. –  Nov 13 '18 at 16:10
  • I modified my questions. Hope it makes sense now. – Pengfei Li Nov 13 '18 at 16:12

1 Answers1

2

The VGGFace package you're using is configured for an older version of Keras. The easiest solution for you is to edit the keras-vggface/keras_vggface/models.py file inside the vvgface directory and change line 15 from:

from keras.applications.imagenet_utils import _obtain_input_shape

to

from keras_applications.imagenet_utils import _obtain_input_shape

Alternatively you can also just downgrade Keras to 2.2.0 if you find that easier

Tadej Magajna
  • 2,765
  • 1
  • 25
  • 41