keras-team / keras-applications

Reference implementations of popular deep learning models.
Other
2k stars 913 forks source link

Why are there applications missing? (AttributeError: module 'keras.applications' has no attribute 'ResNet101/ResNeXt50/ResNeXt101') #118

Open EmielBoss opened 5 years ago

EmielBoss commented 5 years ago

System information

Describe the current behavior
A number of documented Keras applications are missing from my (up-to-date) Keras installation and TensorFlow 1.10 Keras API installation. I import Keras' applications module as suggested and use it as follows:

from keras import applications
resnet = applications.ResNeXt101(include_top=False, weights='imagenet', input_shape=(SCALED_HEIGHT, SCALED_WIDTH, 3), pooling=None)

I also tried

resnet = applications.resnext.ResNeXt101(include_top=False, weights='imagenet', input_shape=(SCALED_HEIGHT, SCALED_WIDTH, 3), pooling=None)

But in both cases I get the same type of error:

AttributeError: module 'keras.applications' has no attribute 'ResNeXt101'

Printing help(applications) yields:

Help on package keras.applications in keras:

NAME
    keras.applications

PACKAGE CONTENTS
    densenet
    imagenet_utils
    inception_resnet_v2
    inception_v3
    mobilenet
    mobilenet_v2
    mobilenetv2
    nasnet
    resnet50
    vgg16
    vgg19
    xception

FUNCTIONS
    DenseNet121 = wrapper(*args, **kwargs)
    DenseNet169 = wrapper(*args, **kwargs)
    DenseNet201 = wrapper(*args, **kwargs)
    InceptionResNetV2 = wrapper(*args, **kwargs)
    InceptionV3 = wrapper(*args, **kwargs)
    MobileNet = wrapper(*args, **kwargs)
    MobileNetV2 = wrapper(*args, **kwargs)
    NASNetLarge = wrapper(*args, **kwargs)
    NASNetMobile = wrapper(*args, **kwargs)
    ResNet50 = wrapper(*args, **kwargs)
    VGG16 = wrapper(*args, **kwargs)
    VGG19 = wrapper(*args, **kwargs)
    Xception = wrapper(*args, **kwargs)
    keras_modules_injection(base_fun)

DATA
    absolute_import = _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0...
    division = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192...
    print_function = _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0)...

FILE
    site-packages/keras/applications/__init__.py

which shows that the models aren't present in my installation. Why not? How can I get them? They're also not packaged in the TensorFlow's Keras API.

Describe the expected behavior
All Keras applications models present in installation.

Other info / logs
I tried copying the files from the Keras applications GitHub repository and pasting them in site-packages/keras/applications/, but this results in the following stacktrace:

File "myscript.py", line 517, in get_fpn
    resnet = applications.resnext.ResNeXt101(include_top=False, weights='imagenet', input_shape=(SCALED_HEIGHT, SCALED_WIDTH, 3), pooling=None)
  File "site-packages/keras/applications/resnet_common.py", line 575, in ResNeXt101
    **kwargs)
  File "site-packages/keras/applications/resnet_common.py", line 348, in ResNet
    data_format=backend.image_data_format(),
AttributeError: 'NoneType' object has no attribute 'image_data_format'

Any idea how to fix this?

taehoonlee commented 5 years ago

@EmielBoss, The latest release 2.2.4 doesn't include the latest models. If you want to use the bleeding edge version, you can try pip install -U git+https://github.com/keras-team/keras.

EmielBoss commented 5 years ago

@taehoonlee Yeah I discovered that as well, but those models aren't compatible with TensorFlow's eager execution, unfortunately.