thoughtworksarts / EmoPy

A deep neural net toolkit for emotion analysis via Facial Expression Recognition (FER)
https://thoughtworksarts.io/blog/emopy-emotional-expression-toolkit/
GNU Affero General Public License v3.0
923 stars 264 forks source link

AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph' #44

Closed ucsky closed 4 years ago

ucsky commented 5 years ago

Hello,

Trying to install it on Ubuntu Bionic LTS 18 I got the following error when running the unit test:

Using TensorFlow backend. Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "/usr/lib/python3.6/unittest/__main__.py", line 18, in <module> main(module=None) File "/usr/lib/python3.6/unittest/main.py", line 94, in __init__ self.parseArgs(argv) File "/usr/lib/python3.6/unittest/main.py", line 141, in parseArgs self.createTests() File "/usr/lib/python3.6/unittest/main.py", line 148, in createTests self.module) File "/usr/lib/python3.6/unittest/loader.py", line 219, in loadTestsFromNames suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python3.6/unittest/loader.py", line 219, in <listcomp> suites = [self.loadTestsFromName(name, module) for name in names] File "/usr/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName module = __import__(module_name) File "/mnt/host/sf_bob/Documents/test/EmoPy-github-master/EmoPy/__init__.py", line 1, in <module> from .src.fermodel import FERModel File "/mnt/host/sf_bob/Documents/test/EmoPy-github-master/EmoPy/src/fermodel.py", line 1, in <module> from keras.models import load_model File "/home/bob/Envs/emopy-github-master/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module> from . import utils File "/home/bob/Envs/emopy-github-master/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module> from . import conv_utils File "/home/bob/Envs/emopy-github-master/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module> from .. import backend as K File "/home/bob/Envs/emopy-github-master/lib/python3.6/site-packages/keras/backend/__init__.py", line 1, in <module> from .load_backend import epsilon File "/home/bob/Envs/emopy-github-master/lib/python3.6/site-packages/keras/backend/load_backend.py", line 90, in <module> from .tensorflow_backend import * File "/home/bob/Envs/emopy-github-master/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 54, in <module> get_graph = tf_keras_backend.get_graph AttributeError: module 'tensorflow.python.keras.backend' has no attribute 'get_graph'

ucsky commented 5 years ago

I edited setup.py: setting keras==2.2.4 and tensorflow==1.13.1 and now all tests pass and examples runs.

alanTorresAlv commented 4 years ago

hello, which setup.by had you edited?? I have the same issue

farhanc4kra commented 4 years ago

just replacing from keras import backend with: from tensorflow.keras import backend

Raikori commented 4 years ago

where is the setup.py?

ucsky commented 4 years ago

Hi, this setup.py here https://github.com/thoughtworksarts/EmoPy/blob/master/setup.py


with open("README.md","r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="EmoPy",
    version="0.0.5",
    author="ThoughtWorks Arts",
    author_email="info@thoughtworksarts.io",
    description="A deep neural net toolkit for emotion analysis via Facial Expression Recognition (FER)",
    long_description=long_description,
    long_description_content_type = "text/markdown",
    url="https://github.com/thoughtworksarts/EmoPy",
    packages=setuptools.find_packages(),
    include_package_data=True,
    classifiers=[
        "Programming Language :: Python :: 3.6",
        "Operating System :: MacOS :: MacOS X"
    ],
    python_requires='>=3.6.3',
    install_requires=[
       'coverage==4.5.3',
       'keras==2.2.4',
       'lasagne',
       'pytest',
       'matplotlib>2.1.0',
       'numpy<=1.14.5,>=1.13.3',
       'scikit-image>=0.13.1',
       'scikit-learn>=0.19.1',
       'scikit-neuralnetwork>=0.7',
       'scipy==1.0.0',
       'tensorflow==1.13.1',
       'opencv-python',
       'h5py',
       'pydot',
       'graphviz',
    ]
)