Beispiel #1
0
def load_model(ckpt_weights_file, model, learning_rate):
    adam = Adagrad(lr=learning_rate, epsilon=1e-08, decay=0.0, clipnorm=1.)
    model.compile(metrics=[], optimizer=adam)
    model.load_model_weights(ckpt_weights_file)
    kb.release_key('D')
    kb.release_key('S')


def nothing():
    kb.release_key('W')
    kb.release_key('A')
    kb.release_key('D')
    kb.release_key('S')


key_press = {'W': forward, 'S': backward, 'A': left, 'D': right, '.': nothing}

if __name__ == '__main__':

    model = load_model_weights('v1_nfs_ai')

    print("Starting !!!")
    time.sleep(1)
    print("1")
    time.sleep(1)
    print("2")
    time.sleep(1)
    print("3")
    time.sleep(1)
    print("4")
    print("GO go go go !!!!")

    while (True):
        current_view = grab_screen([0, 0, 800, 600])
        reduced_view = cv2.resize(current_view, (shape[1], shape[0]),
Beispiel #3
0
@author: RAJAT
"""

import numpy as np
import cv2
from time import time
from keras.models import Sequential, Model
from keras.layers import *
from keras.callbacks import TensorBoard
from model import load_model_weights
from datacollect import load_train_data, shape, margin
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

model = load_model_weights("v4_nfs_iteration2_ai")
layer_dict = dict([(layer.name, layer) for layer in model.layers])
X_train, Y_train = load_train_data('third_batch')

model.summary()

test = Sequential()
test.add(layer_dict['right_input'])
test.add(layer_dict['conv2d_1'])
test.add(layer_dict['conv2d_2'])
#test.add(layer_dict['conv2d_3'])
#test.add(layer_dict['conv2d_4'])
#test.add(layer_dict['conv2d_5'])
side = 1

res = test.predict(X_train[side, :, :, :, :])
    elif move == 'D':
        kb.release_key('W')
        kb.release_key('S')
        kb.release_key('A')
        kb.press_key('D')

    else:
        kb.release_key('W')
        kb.release_key('S')
        kb.release_key('A')
        kb.release_key('D')


if __name__ == '__main__':

    model = load_model_weights('v4_nfs_iteration2_ai')

    print("Starting !!!")
    time.sleep(1)
    print("1")
    time.sleep(1)
    print("2")
    time.sleep(1)
    print("3")
    time.sleep(1)
    print("4")
    print("GO go go go !!!!")

    while (True):
        current_view = grab_screen([0, 0, 800, 600])
        reduced_view = cv2.resize(current_view, (shape[1], shape[0]),
Created on Mon Feb  5 20:23:46 2018

@author: RAJAT
"""

import numpy as np
from time import time
from keras.models import Sequential, Model
from keras.layers import *
from keras.callbacks import TensorBoard
from model import load_model_weights
from datacollect import load_train_data, shape, margin
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

model = load_model_weights("v3_nfs_ai")
layer_dict = dict([(layer.name, layer) for layer in model.layers])
X_train, Y_train = load_train_data('second_batch')

model.summary()

test = Sequential()
test.add(layer_dict['right_input'])
test.add(layer_dict['conv2d_1'])
test.add(layer_dict['conv2d_2'])
#test.add(layer_dict['conv2d_3'])
#test.add(layer_dict['conv2d_4'])
#test.add(layer_dict['conv2d_5'])
img_no = 8000
side = 0
plt.imshow(X_train[side, img_no, :, :, 0], cmap='gray')