Game-Bot
Game-Bot copied to clipboard
ValueError: 'u' is not in list, ValueError: 'arr' does not have a suitable array shape for any mode.
I seem to be getting this error when i press a key or click the mouse but not everytime
Using TensorFlow backend. down Unhandled exception in listener callback Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init_.py", line 157, in inner return f(self, *args, **kwargs) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput\keyboard_win32.py", line 240, in process self.on_press(key) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 78, in inner if f(*args) is False: File "create_dataset.py", line 61, in on_press save_event_keyboard(data_path, 1, key) File "create_dataset.py", line 25, in save_event_keyboard key = get_id(key) File "C:\tensorflow1\Bot\Game-Bot-master\game_control.py", line 13, in get_id return get_keys().index(key) ValueError: 'u' is not in list
####these errors follow shortly after the initial error above
Traceback (most recent call last):
File "create_dataset.py", line 81, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init_.py", line 157, in inner return f(self, *args, **kwargs) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 379, in _handler self._handle(code, msg, lpdata) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput\mouse_win32.py", line 190, in handle self.on_click(data.pt.x, data.pt.y, button, pressed) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 78, in inner if f(*args) is False: File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 43, in on_click save_event_mouse(data_path, x, y) File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 34, in save_event_mouse save_img(data_path, screenshot) File "C:\tensorflow1\Bot\Game-Bot-master\get_dataset.py", line 15, in save_img imsave(path, img) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc return func(*args, **kwds) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 217, in imsave im = toimage(arr, channel_axis=2) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc return func(*args, **kwds) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 327, in toimage raise ValueError("'arr' does not have a suitable array shape for " ValueError: 'arr' does not have a suitable array shape for any mode. Process Process-1: Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 375, in _handler converted = self._convert(code, msg, lpdata) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 390, in _convert raise NotImplementedError() NotImplementedError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\multiprocessing\process.py", line 297, in _bootstrap self.run() File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\multiprocessing\process.py", line 99, in run self._target(*self.args, **self.kwargs) File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 52, in listen_mouse listener.join() File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 205, in join six.reraise(exc_type, exc_value, exc_traceback) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\six.py", line 692, in reraise raise value.with_traceback(tb) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 157, in inner return f(self, *args, **kwargs) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 379, in _handler self._handle(code, msg, lpdata) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput\mouse_win32.py", line 190, in handle self.on_click(data.pt.x, data.pt.y, button, pressed) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 78, in inner if f(*args) is False: File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 43, in on_click save_event_mouse(data_path, x, y) File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 34, in save_event_mouse save_img(data_path, screenshot) File "C:\tensorflow1\Bot\Game-Bot-master\get_dataset.py", line 15, in save_img imsave(path, img) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc return func(*args, **kwds) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 217, in imsave im = toimage(arr, channel_axis=2) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc return func(*args, **kwds) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 327, in toimage raise ValueError("'arr' does not have a suitable array shape for " ValueError: 'arr' does not have a suitable array shape for any mode.
Open game_control.py and replace code of get_id() with the code given below
try: print('Key Pressed:',key.char,sep='') return get_keys().index(key.char) except AttributeError: if (str(key)+'') not in get_keys(): print((str(key)+''),' is not in list') return print('Key Pressed:',(str(key)+''),sep='') return get_keys().index((str(key)+''))
now it spits this out
`Using TensorFlow backend. Using TensorFlow backend. Unhandled exception in listener callback Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 375, in _handler converted = self._convert(code, msg, lpdata) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 390, in _convert raise NotImplementedError() NotImplementedError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1987, in save format = EXTENSION[ext] KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init_.py", line 157, in inner return f(self, *args, **kwargs) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 379, in _handler self._handle(code, msg, lpdata) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput\mouse_win32.py", line 190, in handle self.on_click(data.pt.x, data.pt.y, button, pressed) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 78, in inner if f(*args) is False: File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 43, in on_click save_event_mouse(data_path, x, y) File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 34, in save_event_mouse save_img(data_path, screenshot) File "C:\tensorflow1\Bot\Game-Bot-master\get_dataset.py", line 15, in save_img imsave(img, path) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc return func(*args, **kwds) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 219, in imsave im.save(name) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1989, in save raise ValueError('unknown file extension: {}'.format(ext)) ValueError: unknown file extension: down Process Process-1: Key Pressed:f Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 375, in _handler converted = self._convert(code, msg, lpdata) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 390, in _convert raise NotImplementedError() NotImplementedError
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1987, in save format = EXTENSION[ext] KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\multiprocessing\process.py", line 297, in _bootstrap
self.run()
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\multiprocessing\process.py", line 99, in run
self._target(*self.args, **self.kwargs)
File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 52, in listen_mouse
listener.join()
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 205, in join
six.reraise(exc_type, exc_value, exc_traceback)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\six.py", line 692, in reraise
raise value.with_traceback(tb)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 157, in inner
return f(self, *args, **kwargs)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util\win32.py", line 379, in _handler
self._handle(code, msg, lpdata)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput\mouse_win32.py", line 190, in handle
self.on_click(data.pt.x, data.pt.y, button, pressed)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 78, in inner
if f(*args) is False:
File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 43, in on_click
save_event_mouse(data_path, x, y)
File "C:\tensorflow1\Bot\Game-Bot-master\create_dataset.py", line 34, in save_event_mouse
save_img(data_path, screenshot)
File "C:\tensorflow1\Bot\Game-Bot-master\get_dataset.py", line 15, in save_img
imsave(img, path)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc
return func(*args, **kwds)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 219, in imsave
im.save(name)
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1989, in save
raise ValueError('unknown file extension: {}'.format(ext))
ValueError: unknown file extension:
create_dataset.py:21: DeprecationWarning: imresize
is deprecated!
imresize
is deprecated in SciPy 1.0.0, and will be removed in 1.3.0.
Use Pillow instead: numpy.array(Image.fromarray(arr).resize())
.
img = imresize(img, (150, 150, 3)).astype('float32')/255.
Unhandled exception in listener callback
Traceback (most recent call last):
File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1987, in save
format = EXTENSION[ext]
KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init_.py", line 157, in inner return f(self, *args, **kwargs) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput\keyboard_win32.py", line 240, in process self.on_press(key) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\pynput_util_init.py", line 78, in inner if f(*args) is False: File "create_dataset.py", line 61, in on_press save_event_keyboard(data_path, 1, key) File "create_dataset.py", line 28, in save_event_keyboard save_img(data_path, screenshot) File "C:\tensorflow1\Bot\Game-Bot-master\get_dataset.py", line 15, in save_img imsave(img, path) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\numpy\lib\utils.py", line 101, in newfunc return func(*args, **kwds) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\scipy\misc\pilutil.py", line 219, in imsave im.save(name) File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1989, in save raise ValueError('unknown file extension: {}'.format(ext)) ValueError: unknown file extension: Traceback (most recent call last): File "C:\Users\proni\Anaconda3\envs\tensorflow2\lib\site-packages\PIL\Image.py", line 1987, in save format = EXTENSION[ext] KeyError: ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "create_dataset.py", line 81, in
can you maybe update the Source code?