Skip to content

ImportError: cannot import name 'Dense' from 'keras.applications.resnet50' #10

@brayevalerien

Description

@brayevalerien

I'm trying to perform inference with your model, but I get an ImportError from the file beauty_predict.py when I try to run it:

> python inference/ldl+resnet/beauty_predict.py

Traceback (most recent call last):
  File "C:\Users\...\BeautyPredict\inference\ldl+resnet\beauty_predict.py", line 8, in <module>
    from keras.applications.resnet50 import Dense
ImportError: cannot import name 'Dense' from 'keras.applications.resnet50' (C:\Users\...\.conda\envs\...\lib\site-packages\keras\applications\resnet50\__init__.py)

I guess this is an issue with the keras and/or tensorflow version so I tried various versions of both libraries but never managed to go past this error. Adding a requirements.txt file would probably help.

Here is my pip freeze output:

> pip freeze

absl-py==2.1.0
astunparse==1.6.3
cachetools==5.3.3
certifi==2024.2.2
charset-normalizer==3.3.2
dlib==19.24.4
filelock==3.13.1
flatbuffers==24.3.25
fsspec==2024.2.0
gast==0.5.4
google-auth==2.29.0
google-auth-oauthlib==1.2.0
google-pasta==0.2.0
grpcio==1.62.2
h5py==3.11.0
idna==3.7
intel-openmp==2021.4.0
Jinja2==3.1.3
keras==2.15.0
libclang==18.1.1
Markdown==3.6
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
mkl==2021.4.0
ml-dtypes==0.2.0
mpmath==1.3.0
namex==0.0.8
networkx==3.2.1
numpy==1.26.3
oauthlib==3.2.2
opencv-python==4.9.0.80
opt-einsum==3.3.0
optree==0.11.0
packaging==24.0
pandas==2.2.2
pillow==10.2.0
protobuf==4.25.3
pyasn1==0.6.0
pyasn1_modules==0.4.0
Pygments==2.17.2
python-dateutil==2.9.0.post0
pytz==2024.1
requests==2.31.0
requests-oauthlib==2.0.0
rich==13.7.1
rsa==4.9
six==1.16.0
sympy==1.12
tbb==2021.11.0
tensorboard==2.15.2
tensorboard-data-server==0.7.2
tensorflow==2.15.0
tensorflow-estimator==2.15.0
tensorflow-intel==2.15.0
tensorflow-io-gcs-filesystem==0.31.0
termcolor==2.4.0
torch==2.3.0+cu118
torchaudio==2.3.0+cu118
torchvision==0.18.0+cu118
typing_extensions==4.9.0
tzdata==2024.1
urllib3==2.2.1
Werkzeug==3.0.2
wrapt==1.14.1

I'm using other modules in this environment so there might be extra libraries that are not needed for BeautyPredict.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions