Skip to content

Commit

Permalink
Create readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Aggrathon committed Sep 9, 2017
1 parent 9088525 commit 767fa02
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DrivingAI/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand 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
Expand Down
29 changes: 29 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 767fa02

Please sign in to comment.