This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import os | |
from matplotlib import pyplot as plt | |
from sklearn.utils import shuffle | |
from sklearn.model_selection import train_test_split | |
from imgaug import augmenters as aug | |
import matplotlib.image as mpimg | |
import cv2 | |
import random |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def balanceBiased(data, display=True): | |
nBins = 31 | |
samplesPerBin = 1000 | |
hist, bins = np.histogram(data['Steering'],nBins) | |
if display: | |
center = (bins[:-1] + bins[1:])*0.5 | |
plt.bar(center, hist, width = 0.06) | |
plt.plot((-1,1), (samplesPerBin, samplesPerBin)) | |
plt.show() | |
removeIndex = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def augmentImage(imgPath, steering): | |
img = mpimg.imread(imgPath) | |
if np.random.rand() < 0.5: | |
pan = aug.Affine(translate_percent={'x': (-0.1,0.1),'y': (-0.1,0.1)}) | |
img = pan.augment_image(img) | |
if np.random.rand() < 0.5: | |
zoom = aug.Affine(scale=(1,1.2)) | |
img = zoom.augment_image(img) | |
if np.random.rand() < 0.5: | |
brightness = aug.Multiply((0.4,1.2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def preProcessing(img): | |
img = img[60:135,:,:] | |
img = cv2.cvtColor(img, cv2.COLOR_RGB2YUV) | |
img = cv2.GaussianBlur(img, (3,3),0) | |
img = cv2.resize(img, (200,68)) | |
img = img / 255 | |
return img |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = Sequential() | |
model.add(Conv2D(24,(5,5),(2,2), input_shape=(66,200,3), activation="elu")) | |
model.add(BatchNormalization()) | |
model.add(Conv2D(36,(5,5),(2,2) ,activation="elu")) | |
model.add(BatchNormalization()) | |
model.add(Conv2D(48,(5,5), activation="elu")) | |
model.add(BatchNormalization()) | |
model.add(Conv2D(64,(3,3), activation="elu")) | |
model.add(BatchNormalization()) | |
model.add(Conv2D(64,(3,3), activation="elu")) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer