exelban / myo-armband-nn

Gesture recognition using myo armband via neural network (tensorflow library).
GNU General Public License v3.0
41 stars 24 forks source link

ValueError: attempt to get argmax of an empty sequence #7

Open hassanyousufx opened 6 years ago

hassanyousufx commented 6 years ago

I'm getting an error when I run predict.py

myo.init()
hub = myo.Hub()
start = time.time()
temp = []
try:
    listener = Listener()
    hub.run(listener, 2000)
    while True:
        data = listener.get_emg_data()
        if time.time() - start >= 1:
            response = np.argmax(np.bincount(temp))      -------> ERROR
            print("Predicted gesture: {0}".format(response))
            temp = []
            start = time.time()
        if len(data) > 0:
            tmp = []
            for v in listener.get_emg_data():
                tmp.append(v[1])
            tmp = list(np.stack(tmp).flatten())
            if len(tmp) >= 64:
                pred = sess.run(y_pred_cls, feed_dict={x: np.array([tmp])})
                temp.append(pred[0])
        time.sleep(0.01)
finally:
    sess.close()
marcoamm commented 6 years ago

I had the same problem. Since you changed the order of the listener and delay on the hub.run(), I assume you're using the new myo-python libs. Use the myo lib v1.0.0a21 and the myo-python lib v0.2.2. The newer versions of myo-python changed the syntax and name of some classes making the connection empty, and the emg data also empty when queried.

hassanyousufx commented 6 years ago

I downloaded the myo-python v0.2.2 and ran setup.py install, but how do I install myo lib v1.0.0a21?

exelban commented 6 years ago

@hassanyf @marcoamm I don't have myo-armband anymore. And I can't update package. If someone make PR with updates, it will be great.

hassanyousufx commented 6 years ago

Okay, then can please tell me how to install myo lib v1.0.0a21 and the myo-python lib v0.2.2. It would be of great help! I am stuck with this since 2 weeks. Thanks!

exelban commented 6 years ago

@hassanyf pip3 install myo-python==0.2.2 About myo lib, You need to check their documentation