Search code examples
pythonmachine-learningkerasgoogle-colaboratoryresnet

ModuleNotFoundError: No module named 'keras.applications.resnet50 on google colab


I am trying to run an image-based project on colab. I found the project on github. Everything runs fine till I reached the cell with the following code:

import keras
from keras.preprocessing.image import ImageDataGenerator
from keras.applications.resnet50 import preprocess_input, ResNet50
from keras.models import Model
from keras.layers import Dense, MaxPool2D, Conv2D

When I run it, the following output is observed:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-24-173cbce466d6> in <module>()
      1 import keras
      2 from keras.preprocessing.image import ImageDataGenerator
----> 3 from keras.applications.resnet50 import preprocess_input, ResNet50
      4 from keras.models import Model
      5 from keras.layers import Dense, MaxPool2D, Conv2D

ModuleNotFoundError: No module named 'keras.applications.resnet50'

---------------------------------------------------------------------------

It's running 2.7.0 keras, connected to a TPU runtime. I tried !pip installing the said module but no use. I even tried running a demo resnet50 project too but got the same error. Can anyone please help me solve the error?


Solution

  • from tensorflow.keras.applications.resnet50 import ResNet50