UnboundLocalError: local variable 'name' referenced before assignment
bj32161 opened this issue · 2 comments
Hi,
I ran your code on ubuntu 18.04/python3.6.5 as below
python video_emotion_gender_demo.py
I got this error. Could you please advice?
(cv) kiosk@smb02:~/face_classification/src$ python video_emotion_gender_demo.py
Using TensorFlow backend.
2018-10-03 16:34:45.173705: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2
Traceback (most recent call last):
File "video_emotion_gender_demo.py", line 31, in
gender_classifier = load_model(gender_model_path, compile=False)
File "/home/kiosk/.virtualenvs/cv/lib/python3.6/site-packages/keras/engine/saving.py", line 419, in load_model
model = _deserialize_model(f, custom_objects, compile)
File "/home/kiosk/.virtualenvs/cv/lib/python3.6/site-packages/keras/engine/saving.py", line 225, in _deserialize_model
model = model_from_config(model_config, custom_objects=custom_objects)
File "/home/kiosk/.virtualenvs/cv/lib/python3.6/site-packages/keras/engine/saving.py", line 458, in model_from_config
return deserialize(config, custom_objects=custom_objects)
File "/home/kiosk/.virtualenvs/cv/lib/python3.6/site-packages/keras/layers/init.py", line 55, in deserialize
printable_module_name='layer')
File "/home/kiosk/.virtualenvs/cv/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 145, in deserialize_keras_object
list(custom_objects.items())))
File "/home/kiosk/.virtualenvs/cv/lib/python3.6/site-packages/keras/engine/sequential.py", line 294, in from_config
model = cls(name=name)
UnboundLocalError: local variable 'name' referenced before assignment
I had the same problem, I resolved by downgrading Keras and Tensorflow (not sure which one caused the problem).
Try with Keras 2.1.6 and Tensorflow 1.6.0.
sudo -H python -m pip install keras==2.1.6
sudo -H python -m pip install tensorflow==1.6.0
I had the same problem, I resolved by downgrading Keras and Tensorflow (not sure which one caused the problem).
Try with Keras 2.1.6 and Tensorflow 1.6.0.
sudo -H python -m pip install keras==2.1.6
sudo -H python -m pip install tensorflow==1.6.0
Hi Doch88,
I did try your commands but It still show same error. Any thought? how can I fix it.
Thank you.