Reputation: 63
This error occurred, while my original code doesn't contain 'import resnet'.
It seems like the error occurred when import tensorflow.
Traceback (most recent call last):
File "step2_training.py", line 5, in <module>
from class_coTrust import *
File "/share/scratch/manqingdong/my_filename/class_coTrust.py", line 1, in <module>
from utils import *
File "/share/scratch/manqingdong/my_filename/utils.py", line 7, in <module>
import tensorflow as tf
File "/usr/lib64/python3.6/site-packages/tensorflow/__init__.py", line 98, in <module>
from tensorflow_core import *
File "/usr/lib64/python3.6/site-packages/tensorflow_core/__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "/usr/lib64/python3.6/site-packages/tensorflow/__init__.py", line 50, in __getattr__
module = self._load()
File "/usr/lib64/python3.6/site-packages/tensorflow/__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/__init__.py", line 83, in <module>
from tensorflow.python import keras
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/__init__.py", line 26, in <module>
from tensorflow.python.keras import activations
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/__init__.py", line 27, in <module>
from tensorflow.python.keras import applications
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/applications/__init__.py", line 64, in <module>
from tensorflow.python.keras.applications.resnet import ResNet50
File "/usr/lib64/python3.6/site-packages/tensorflow_core/python/keras/applications/resnet.py", line 22, in <module>
from keras_applications import resnet
ImportError: cannot import name 'resnet'
Upvotes: 5
Views: 26038
Reputation: 65
try resnet instead of resnet50
from keras.applications import resnet
model = resnet.ResNet50
Upvotes: 2
Reputation: 2403
the solution for tensorflow 2.4.0 is
from tensorflow.keras.applications import ResNet50
Upvotes: 8
Reputation: 151
I encounter the same situation after installing Keras-Applications==1.0.6
and
Keras-Preprocessing==1.0.5
. Removing these two pip packages and reinstalling tensorflow
solves the problem.
Upvotes: 0
Reputation: 1220
Instead of
from tensorflow.python.keras.applications.resnet import ResNet50
try this
from tensorflow.python.keras.applications.resnet50 import ResNet50
Upvotes: 1
Reputation: 167
This is because resnet
is not install. Could you try to install it using pip?
pip3 install resnet
Upvotes: 0