前提・実現したいこと
predict.pyという名前のファイルでtensorflowを用いた予測メゾッドを実行させるコードを書いています.実行させるとモジュールに関するエラーが発生しました.
発生している問題・エラーメッセージ
Trying to restore last checkpoint ...
./data/tensorflow_sessions/myo_armband/-48000
INFO:tensorflow:Restoring parameters from ./data/tensorflow_sessions/myo_armband/-48000
Failed to restore checkpoint. Initializing variables instead.
Traceback (most recent call last):
File "C:\Users\名前\Desktop\myo-python-1.0.4\myo-armband-nn-master\タイトル無し9.py", line 69, in <module>
myo.init()
File "C:\Users\名前\anaconda3\envs\Myo-ANN\lib\site-packages\myo\lowlevel\ctyping.py", line 119, in init
self._lib = ctypes.cdll.LoadLibrary(lib_name)
File "C:\Users\名前\anaconda3\envs\Myo-ANN\lib\ctypes_init_.py", line 442, in LoadLibrary
return self._dlltype(name)
File "C:\Users\名前\anaconda3\envs\Myo-ANN\lib\ctypes_init_.py", line 364, in init
self._handle = _dlopen(self._name, mode)
[WinError 126] 指定されたモジュールが見つかりません。
### 該当のソースコード
from
1#import collections 2import myo 3from threading import Lock 4import time 5import numpy as np 6import tensorflow as tf 7from include.model import model 8 9 10x, y, output, global_step, y_pred_cls = model() 11 12saver = tf.train.Saver() 13_SAVE_PATH = "./data/tensorflow_sessions/myo_armband/" 14sess = tf.Session() 15 16 17try: 18 print("Trying to restore last checkpoint ...") 19 last_chk_path = tf.train.latest_checkpoint(checkpoint_dir=_SAVE_PATH) 20 print(last_chk_path) 21 saver.restore(sess, save_path=last_chk_path) 22 print("Restored checkpoint from:", last_chk_path) 23except: 24 print("Failed to restore checkpoint. Initializing variables instead.") 25 sess.run(tf.global_variables_initializer()) 26 27 28class ApiDeviceListener(myo.DeviceListener): 29 30 def __init__(self, queue_size=8): 31 #self.lock = threading.Lock() 32 self.lock = Lock() 33 #self.emg_data_queue = collections.deque(maxlen=queue_size) 34 self.emg_data_queue = deque(maxlen=queue_size) 35 self.orientation_data_queue = deque(maxlen=queue_size) 36 self.acceleration_data_queue = deque(maxlen=queue_size) 37 self.gyroscope_data_queue = deque(maxlen=queue_size) 38 self.rssi_data_queue = deque(maxlen=100) 39 def on_connect(self, device, timestamp, firmware_version, event): 40 device.set_stream_emg(myo.StreamEmg.enabled) 41 self.device = event.device # sauvegarde de l'instance au myo arm 42 event.device.unlock() # demande de desappareiller 43 event.device.lock() # demande d'appareiller (génère des vibrations) 44 event.device.stream_emg(True) # lance l'acquisition des emg 45 self.connected = True # mise à jour du flag de connection du myo 46 self.device_name = event.device_name # on récupère le petit nom du myo 47 # on récupère également le numéro du firmware (non exploité dans l'UI) 48 self.myo_firmware = '.'.join(map(str, event.firmware_version[:-1])) 49 def on_emg_data(self, device, timestamp, emg_data, event): 50 with self.lock: 51 self.emg_data_queue.append((timestamp, emg_data)) 52 with self.lock: 53 self.emg_data_queue.append((event.timestamp, 54 event.emg)) 55 def get_emg_data(self): 56 with self.lock: 57 return list(self.emg_data_queue) 58 with self.lock: 59 return list(self.emg_data_queue) 60 61 62myo.init() ☚ ここではないかと 63hub = myo.Hub() 64start = time.time() 65listener = ApiDeviceListener() 66temp = [] 67 68try: 69 listener = ApiDeviceListener() 70 hub.run(listener, 2000) 71 while True: 72 data = listener.get_emg_data() 73 if time.time() - start >= 1: 74 response = np.argmax(np.bincount(temp)) 75 print("Predicted gesture: {0}".format(response)) 76 temp = [] 77 start = time.time() 78 if len(data) > 0: 79 tmp = [] 80 for v in listener.get_emg_data(): 81 tmp.append(v[1]) 82 tmp = list(np.stack(tmp).flatten()) 83 if len(tmp) >= 64: 84 pred = sess.run(y_pred_cls, feed_dict={x: np.array([tmp])}) 85 temp.append(pred[0]) 86 time.sleep(0.01) 87finally: 88 #hub.shutdown() 89 sess.close()
補足情報(FW/ツールのバージョンなど)
69行目の myo.init()のあたりなのかなと思うのですが,なんのモジュールが指定されていないのかわからないです.
python tensorflow spyder
![guest](/img/icon/icnUserSample.jpg)
あなたの回答
tips
プレビュー