Skip to content

Commit

Permalink
Restructured repository with new YOLO model
Browse files Browse the repository at this point in the history
Removed and added neccessary files
  • Loading branch information
rkassana committed Jun 13, 2019
1 parent 2371951 commit be3a06b
Show file tree
Hide file tree
Showing 40 changed files with 2,207 additions and 3,747 deletions.
5 changes: 2 additions & 3 deletions .idea/Tello2.iml → .idea/Tello.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

390 changes: 176 additions & 214 deletions .idea/workspace.xml

Large diffs are not rendered by default.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

248 changes: 0 additions & 248 deletions Quadcopter_Project.ipynb

This file was deleted.

2 changes: 0 additions & 2 deletions README.md

This file was deleted.

2 changes: 1 addition & 1 deletion agents/rl_drone.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, env):
self.actor.add(Dense(16))
self.actor.add(Activation('relu'))
self.actor.add(Dense(nb_actions,activation='tanh',kernel_initializer=RandomUniform()))
self.actor.add(Lambda(lambda x: x * 30.0))
self.actor.add(Lambda(lambda x: x * 60.0))
print(self.actor.summary())

action_input = Input(shape=(nb_actions,), name='action_input')
Expand Down
70 changes: 70 additions & 0 deletions callbacks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from keras.callbacks import TensorBoard, ModelCheckpoint
import tensorflow as tf
import numpy as np

class CustomTensorBoard(TensorBoard):
""" to log the loss after each batch
"""
def __init__(self, log_every=1, **kwargs):
super(CustomTensorBoard, self).__init__(**kwargs)
self.log_every = log_every
self.counter = 0

def on_batch_end(self, batch, logs=None):
self.counter+=1
if self.counter%self.log_every==0:
for name, value in logs.items():
if name in ['batch', 'size']:
continue
summary = tf.Summary()
summary_value = summary.value.add()
summary_value.simple_value = value.item()
summary_value.tag = name
self.writer.add_summary(summary, self.counter)
self.writer.flush()

super(CustomTensorBoard, self).on_batch_end(batch, logs)

class CustomModelCheckpoint(ModelCheckpoint):
""" to save the template model, not the multi-GPU model
"""
def __init__(self, model_to_save, **kwargs):
super(CustomModelCheckpoint, self).__init__(**kwargs)
self.model_to_save = model_to_save

def on_epoch_end(self, epoch, logs=None):
logs = logs or {}
self.epochs_since_last_save += 1
if self.epochs_since_last_save >= self.period:
self.epochs_since_last_save = 0
filepath = self.filepath.format(epoch=epoch + 1, **logs)
if self.save_best_only:
current = logs.get(self.monitor)
if current is None:
warnings.warn('Can save best model only with %s available, '
'skipping.' % (self.monitor), RuntimeWarning)
else:
if self.monitor_op(current, self.best):
if self.verbose > 0:
print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
' saving model to %s'
% (epoch + 1, self.monitor, self.best,
current, filepath))
self.best = current
if self.save_weights_only:
self.model_to_save.save_weights(filepath, overwrite=True)
else:
self.model_to_save.save(filepath, overwrite=True)
else:
if self.verbose > 0:
print('\nEpoch %05d: %s did not improve from %0.5f' %
(epoch + 1, self.monitor, self.best))
else:
if self.verbose > 0:
print('\nEpoch %05d: saving model to %s' % (epoch + 1, filepath))
if self.save_weights_only:
self.model_to_save.save_weights(filepath, overwrite=True)
else:
self.model_to_save.save(filepath, overwrite=True)

super(CustomModelCheckpoint, self).on_batch_end(epoch, logs)
Loading

0 comments on commit be3a06b

Please sign in to comment.