Armand Assault
Armand Assault

Reputation: 29

ImportError: No module named tensorflow.keras.applications

I would like to solve my error about some tensorflow packages I've already installed bu I don't understand what doesn't work. Please help.

from tensorflow.keras.applications import ResNet50
from tensorflow.keras.applications import InceptionV3
from tensorflow.keras.applications import Xception # TensorFlow ONLY
from tensorflow.keras.applications import VGG16
from tensorflow.keras.applications import VGG19
from tensorflow.keras.applications import imagenet_utils
from tensorflow.keras.applications.inception_v3 import preprocess_input
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.preprocessing.image import load_img
import numpy as np
import argparse
import cv2

And here's my error

from tensorflow.keras.applications import ResNet50
ImportError: No module named tensorflow.keras.applications

And here are my packages' versions

>>> import tensorflow
>>> tensorflow.__version__
'2.9.1'

>>> import tensorflow as tf
>>> print(tf.keras.__version__)
'2.9.0'

Upvotes: 1

Views: 4035

Answers (2)

Adam De-Nyangos
Adam De-Nyangos

Reputation: 123

I think the problem is the structure of the Tensorflow package has changed and those modules are no longer where they used to be. I ran into a similar issue when I was following a tutorial that was developed for older versions of Tensorflow and Keras.

I was able to find the missing modules in the Keras package. Try downloading the Keras packages and importing what you need from here:

import keras._tf_keras.keras

Upvotes: 0

user18419583
user18419583

Reputation:

try from tensorflow.keras.applications import resnet

or try downgrading to tensorflow 2.7

!pip uninstall tensorflow

!pip install tensorflow==2.7

Upvotes: 1

Related Questions