marcogdepinto / emotion-classification-from-audio-files

Understanding emotions from audio files using neural networks and multiple datasets.
GNU General Public License v3.0
408 stars 134 forks source link

numpy.AxisError in "live_predictions.py" #24

Closed DinghaoXi closed 3 years ago

DinghaoXi commented 3 years ago

When i run “python live_predictions.py” , there comes the axis error :

Traceback (most recent call last): File "live_predictions.py", line 61, in live_prediction.make_predictions() File "live_predictions.py", line 32, in make_predictions x = np.expand_dims(mfccs, axis=2) File "<__array_function__ internals>", line 5, in expand_dims File "/home/anaconda3/envs/tf/lib/python3.8/site-packages/numpy/lib/shape_base.py", line 597, in expand_dims axis = normalize_axis_tuple(axis, out_ndim) File "/home/anaconda3/envs/tf/lib/python3.8/site-packages/numpy/core/numeric.py", line 1358, in normalize_axis_tuple axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis]) File "/home/anaconda3/envs/tf/lib/python3.8/site-packages/numpy/core/numeric.py", line 1358, in axis = tuple([normalize_axis_index(ax, ndim, argname) for ax in axis]) numpy.AxisError: axis 2 is out of bounds for array of dimension 2

Could you please teach me how to fix this error? Thank you!

DinghaoXi commented 3 years ago

I wonder if i change "x = np.expand_dims(mfccs, axis=2)" into "x = np.expand_dims(mfccs, axis=1)" is right?

larsaars commented 3 years ago

I'm having the same error, but it is making terrible predictions when I change that. When I tried it with the original files, it did not work as well.

LigangSun commented 3 years ago

I wonder if i change "x = np.expand_dims(mfccs, axis=2)" into "x = np.expand_dims(mfccs, axis=1)" is right?

I make change like this, it works now, but the prediction result is terrible.

codejoey commented 3 years ago

Same error, followed the 'fix' but how much worse are you all getting from the accuracy drop now?

marcogdepinto commented 3 years ago

Hey all,

I am pretty sure this is due to the fact you are using an environment that is different from mine. I am not reproducing this error using an environment with the libraries versions provided into the requirements.txt https://github.com/marcogdepinto/emotion-classification-from-audio-files/blob/master/requirements.txt .

On a general note, I am not updating this project since last year and have no plan to do so in the short term. I do not plan to make it work with recent tensorflow/numpy version.

Closing this issue as, again, I do not think it is an issue. Please use the recommended libraries and reopen if you have same requirements and are still experiencing the error.

marcogdepinto commented 3 years ago

To complete the above comment: my output is raising a deprecation warning and not an error, but the model is working. This is confirming my theory that you are using a more recent numpy version and not following the project requirements.

C:/Users/Marco/PycharmProjects/Emotion-Classification-Ravdess/live_predictions.py:32: DeprecationWarning: Both axis > a.ndim and axis < -a.ndim - 1 are deprecated and will raise an AxisError in the future. x = np.expand_dims(mfccs, axis=2) Prediction is calm C:/Users/Marco/PycharmProjects/Emotion-Classification-Ravdess/live_predictions.py:32: DeprecationWarning: Both axis > a.ndim and axis < -a.ndim - 1 are deprecated and will raise an AxisError in the future. x = np.expand_dims(mfccs, axis=2) Prediction is disgust