Python plays GTA San Andreas error while test_model.py with model
Code is written in Python 3.5.X
Please try to make the answer simple for a 3rd year Computer Science Student
The output files from train_model.py seems to be a model.meta file but the test_model.py is asking for a .model file. The tutorial user has a .model file as well I can't seem to understand why i am getting a file with .model.meta
I am trying to play GTA San Andreas through Python or more precisely the car in GTA is driven by the model. It takes screen frames as Input and recorded the key i Input during training. This training data is used to train the model.
Training of Model completed sucessfully with EPOCHS 8 and 15 and return files are:- pygta_sa-car-0.001-alexnetv2-15-epochs.model.data-00000-of-00001 pygta_sa-car-0.001-alexnetv2-15-epochs.model.index pygta_sa-car-0.001-alexnetv2-15-epochs.model.meta
import numpy as np import cv2 import time from grabscreen import grab_screen from getkeys import key_check from directkeys import PressKey, ReleaseKey, W, A, S, D from alexnet import alexnet
# p pauses game and can get annoying. if 'T' in keys: if paused: paused = False time.sleep(1) else: paused = True ReleaseKey(A) ReleaseKey(W) ReleaseKey(D) time.sleep(1)
main()
The Error Message on running test_model.py
Traceback (most recent call last): File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1039, in _do_call return fn(*args) File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1021, in _run_fn status, run_metadata) File "C:Program FilesPython35libcontextlib.py", line 66, in __exit__ next(self.gen) File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkerrors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for F:play_gta_sapygta_sa-car-0.001-alexnetv2-8-epochs.model [[Node: save_1/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2/tensor_names, save_1/RestoreV2/shape_and_slices)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "F:play_gta_satest_model.py", line 33, in <module> model.load(MODEL_NAME) File "C:Program FilesPython35libsite-packagestflearnmodelsdnn.py", line 282, in load self.trainer.restore(model_file, weights_only, **optargs) File "C:Program FilesPython35libsite-packagestflearnhelperstrainer.py", line 452, in restore self.restorer.restore(self.session, model_file) File "C:Program FilesPython35libsite-packagestensorflowpythontrainingsaver.py", line 1457, in restore {self.saver_def.filename_tensor_name: save_path}) File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 778, in run run_metadata_ptr) File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 982, in _run feed_dict_string, options, run_metadata) File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1032, in _do_run target_list, options, run_metadata) File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1052, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.NotFoundError: Unsuccessful TensorSliceReader constructor: Failed to find any matching files for F:play_gta_sapygta_sa-car-0.001-alexnetv2-8-epochs.model [[Node: save_1/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2/tensor_names, save_1/RestoreV2/shape_and_slices)]]
Caused by op 'save_1/RestoreV2', defined at: File "<string>", line 1, in <module> File "C:Program FilesPython35libidlelibrun.py", line 124, in main ret = method(*args, **kwargs) File "C:Program FilesPython35libidlelibrun.py", line 351, in runcode exec(code, self.locals) File "F:play_gta_satest_model.py", line 32, in <module> model = alexnet(WIDTH, HEIGHT, LR) File "F:play_gta_saalexnet.py", line 40, in alexnet max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log') File "C:Program FilesPython35libsite-packagestflearnmodelsdnn.py", line 64, in __init__ best_val_accuracy=best_val_accuracy) File "C:Program FilesPython35libsite-packagestflearnhelperstrainer.py", line 147, in __init__ allow_empty=True) File "C:Program FilesPython35libsite-packagestensorflowpythontrainingsaver.py", line 1056, in __init__ self.build() File "C:Program FilesPython35libsite-packagestensorflowpythontrainingsaver.py", line 1086, in build restore_sequentially=self._restore_sequentially) File "C:Program FilesPython35libsite-packagestensorflowpythontrainingsaver.py", line 691, in build restore_sequentially, reshape) File "C:Program FilesPython35libsite-packagestensorflowpythontrainingsaver.py", line 407, in _AddRestoreOps tensors = self.restore_op(filename_tensor, saveable, preferred_shard) File "C:Program FilesPython35libsite-packagestensorflowpythontrainingsaver.py", line 247, in restore_op [spec.tensor.dtype])[0]) File "C:Program FilesPython35libsite-packagestensorflowpythonopsgen_io_ops.py", line 669, in restore_v2 dtypes=dtypes, name=name) File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkop_def_library.py", line 768, in apply_op op_def=op_def) File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkops.py", line 2336, in create_op original_op=self._default_original_op, op_def=op_def) File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkops.py", line 1228, in __init__ self._traceback = _extract_stack()
NotFoundError (see above for traceback): Unsuccessful TensorSliceReader constructor: Failed to find any matching files for F:play_gta_sapygta_sa-car-0.001-alexnetv2-8-epochs.model [[Node: save_1/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT], _device="/job:localhost/replica:0/task:0/cpu:0"](_recv_save_1/Const_0, save_1/RestoreV2/tensor_names, save_1/RestoreV2/shape_and_slices)]]
I am not getting a file with only .model extension so, what seems to be the problem.
You must be logged in to post. Please login or register an account.