Search code examples
kerasresnetpre-trained-model

ResNet50v2 in Keras


I want to load pre-trained ResNet50v2 model in Keras. I tried

keras.applications.resnet_v2.ResNet50V2()

This gave an error

Traceback (most recent call last):
  File "<input>", line 1, in <module>
AttributeError: module 'keras.applications' has no attribute 'resnet_v2'

On searching that error, this answer suggested to use keras_applications package. So I tried

keras_applications.resnet_v2.ResNet50V2()

This gives the error

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/nagabhushan/.local/lib/python3.6/site-packages/keras_applications/resnet_common.py", line 495, in ResNet50V2
    **kwargs)
  File "/home/nagabhushan/.local/lib/python3.6/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'

On searching that error, this answer suggests to use keras.applications package. I'm confused. How can I load ResNetv2 model?

Note: I was able to load ResNet50. Only ResNet50v2 is giving problems

from keras.applications.resnet50 import ResNet50

Solution

  • import keras
    
    keras.applications.resnet_v2.ResNet50V2()
    The above code is executed in the jupyter notebook
    Before installing Keras, please install one of its backend engines TensorFlow

    • pip install tensorflow
    • pip install keras

    enter image description here