Oreobird / tf-keras-deep-head-pose

A tensorflow & keras implementation of Deep Head Pose
70 stars 33 forks source link

Not using eager execution gives me an error. #3

Open aniruddha-matroid opened 5 years ago

aniruddha-matroid commented 5 years ago
Traceback (most recent call last):
  File "head_pose_single_frame.py", line 38, in <module>
  File "/mnt/gaze-estimation/tf-keras-deep-head-pose/models.py", line 23, in __init__
    self.model = self.__create_model()
  File "/mnt/gaze-estimation/tf-keras-deep-head-pose/models.py", line 65, in __create_model
    loss=losses)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/training/checkpointable/base.py", line 474, in _method_wrapper
    method(self, *args, **kwargs)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 617, in compile
    output_loss = weighted_loss(y_true, y_pred, sample_weight, mask)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_utils.py", line 598, in weighted
    score_array = fn(y_true, y_pred)
  File "/mnt/gaze-estimation/tf-keras-deep-head-pose/models.py", line 29, in __loss_angle
    cls_loss = tf.losses.softmax_cross_entropy(onehot_labels=tf.keras.utils.to_categorical(bin_true, 66), logits=y_pred)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/keras/utils/np_utils.py", line 39, in to_categorical
    y = np.array(y, dtype='int')
ValueError: setting an array element with a sequence.

Can you tell me what's wrong?

ariyapour commented 5 years ago

I get the same error! Couldn't find any solution.

Dockyin commented 5 years ago

same error...

ekbae commented 5 years ago

same error....

vaibhavgupta-hike commented 4 years ago

I am getting the same error. Did anyone find a solution for it?

endobot commented 4 years ago

After try to step up tensorflow version one by one. The correct tensorflow version must be 1.12 only. All error will be disappear.

gilad207 commented 4 years ago

After try to step up tensorflow version one by one. The correct tensorflow version must be 1.12 only. All error will be disappear.

did you install tf1.12.0 ? i try it and still get the error "setting an array element with a sequence"

gilad207 commented 4 years ago
Traceback (most recent call last):
  File "head_pose_single_frame.py", line 38, in <module>
  File "/mnt/gaze-estimation/tf-keras-deep-head-pose/models.py", line 23, in __init__
    self.model = self.__create_model()
  File "/mnt/gaze-estimation/tf-keras-deep-head-pose/models.py", line 65, in __create_model
    loss=losses)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/training/checkpointable/base.py", line 474, in _method_wrapper
    method(self, *args, **kwargs)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 617, in compile
    output_loss = weighted_loss(y_true, y_pred, sample_weight, mask)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_utils.py", line 598, in weighted
    score_array = fn(y_true, y_pred)
  File "/mnt/gaze-estimation/tf-keras-deep-head-pose/models.py", line 29, in __loss_angle
    cls_loss = tf.losses.softmax_cross_entropy(onehot_labels=tf.keras.utils.to_categorical(bin_true, 66), logits=y_pred)
  File "/home/aniruddha/anaconda3/envs/tf-1.12/lib/python3.6/site-packages/tensorflow/python/keras/utils/np_utils.py", line 39, in to_categorical
    y = np.array(y, dtype='int')
ValueError: setting an array element with a sequence.

Can you tell me what's wrong?

FINALLY!!! FOUND A SOLUTION! you need to change this line self.idx_tensor = tfe.Variable(np.array(self.idx_tensor, dtype=np.float32))