From 767fa024943eff8155c8f547476f858ee9e5c806 Mon Sep 17 00:00:00 2001 From: Aggrathon Date: Sat, 9 Sep 2017 23:22:53 +0300 Subject: [PATCH] Create readme --- DrivingAI/model.py | 8 ++++---- readme.md | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 readme.md diff --git a/DrivingAI/model.py b/DrivingAI/model.py index 99df74e..b6a3694 100644 --- a/DrivingAI/model.py +++ b/DrivingAI/model.py @@ -14,21 +14,21 @@ def __init__(self, save=False, summary=False, global_step=None): os.makedirs(self.log_directory, exist_ok=True) os.makedirs(self.network_directory, exist_ok=True) self._save = save - self.saver = tf.train.Saver() + self.saver = tf.train.Saver(tf.trainable_variables()) self.global_step = global_step self.session = tf.Session() + self.session.run(tf.global_variables_initializer()) + self.session.run(tf.local_variables_initializer()) self.coord = tf.train.Coordinator() tf.train.start_queue_runners(self.session, self.coord) try: ckpt = tf.train.get_checkpoint_state(self.network_directory) if ckpt is None: - self.session.run(tf.global_variables_initializer()) print("\nCreated a new network\n") else: self.saver.restore(self.session, ckpt.model_checkpoint_path) print("\nLoaded an existing network\n") except Exception as e: - self.session.run(tf.global_variables_initializer()) print("\nCreated a new network (%s)\n"%repr(e)) if summary: self.summary_ops = tf.summary.merge_all() @@ -43,7 +43,7 @@ def save_summary(self, global_step, fd=None): def save_network(self): if self._save: - self.saver.save(self.session, self.model_file_name, self.global_step) + self.saver.save(self.session, self.model_file_name, self.global_step, write_meta_graph=False) def __enter__(self): return self diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..2e2a8ec --- /dev/null +++ b/readme.md @@ -0,0 +1,29 @@ +# Selfdriving Car AI and Simulator +This project contains a neural network for driving a car in a simulator. The simulator is also part of the project. The goal with not using a existing game/simulator is to allow more control over the data being fed to the AI, which made some experimentation possible. + +## Simulator +The simulator is made with unity. It generates random terrains in order to create varied learning situations. The simulator communicates with the AI through a local socket, this means that often both the simulator and the AI have to be started. + +## AI +The AI receives the following input: +1. A color image. +2. A grayscale image created from the depth and normal buffers (a LADAR scanner would be the real life equivalent). +3. The current speed of the car. + +The output is acceleration and turning values. + +## Download +A windows version of the simulator can be downloaded [here](https://github.com/Aggrathon/CarAiSimulator/releases). +The trained network is unfortunately too big to distribute here (maybe the fully connected layers coud be smaller). + +## Usage +Here is the normal flow for using the AI: +1. Use the simulator and the `record.py` script to to create examples of how humans drive. +2. Train the AI on the recorded examples using the `learn.py` script. +3. Improve the AI with reinforcement learning, using the simulator and the `train.py` script. +4. Let the AI drive in the simulator with the `drive.py` script. + +## Dependencies +- Python 3 +- Tensorflow +- Unity (2017.2)