Skip to content

Instantly share code, notes, and snippets.

View callmemaze's full-sized avatar

Dipesh Shrestha callmemaze

View GitHub Profile
View imports.py
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
View basied.py
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 = []
View augmentation.py
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))
View preprocess.py
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
View model.py
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"))
View import.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View reading.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View fillage.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View sibparch.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View cabin.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.