JustinShenk/fer

TensorFlow 2.0 has no attribute 'ConfigProto'; fix proposed

etjones opened this issue · 3 comments

Nice project! Thanks for putting it together!

I found a breaking issue today, with a simple fix. The versioning strings ask for TensorFlow >=1.14, but there's some internal code that relies on a TF configuration object that was changed in TF2.0. A workaround is to change the tensorflow requirement strings in setup.py and requirements.txt from "tensorflow>=1.14", to "tensorflow>=1.14,<2.0",

I did a pip install fer in a new virtualenv and then started following the usage instructions. Here's a session dump:

In [1]: import tensorflow    
In [2]: tensorflow.__version__  
Out[2]: '2.0.0'
In [3]: from fer import FER   
In [4]: detector = FER()      
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-a308cfd708c0> in <module>
----> 1 detector = FER()

~/td_venv/lib/python3.7/site-packages/fer/fer.py in __init__(self, cascade_file, mtcnn, emotion_model, scale_factor, min_face_size, min_neighbors, offsets, compile)
    110                 "fer", "data/emotion_model.hdf5"
    111             )
--> 112             self.config = tf.ConfigProto(log_device_placement=False)
    113             self.config.gpu_options.allow_growth = True
    114 

AttributeError: module 'tensorflow' has no attribute 'ConfigProto'

Here's a workaround for TF1/TF2 compatibility that I think would also resolve things.

I'll send a PR later on if I can get something working smoothly. Cheers!

Hi @JustinShenk I started using fer and had this issue. I did install from pip3 as I have python 3.6
Finally to get the fix from master i cloned this repo manually and that let me start.

No idea why pip isn't picking the right one, just wanted to let you know error still showed then

Fixed in v20.0.0 with dc46da3. Now works with pip install -U fer.