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
# 1- Generating a dataset. | |
from sklearn.datasets import make_moons | |
# X are the generated instances, an array of shape (500,2). | |
# y are the labels of X, with values of either 0 or 1. | |
X, y = make_moons(n_samples=500, noise=0.3, random_state=42) | |
# 2- Visualizing the dataset. | |
from matplotlib import pyplot as plt |
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
class Perceptron: | |
def __init__(self, input_size): | |
np.random.seed(42) | |
self.sizes = [input_size, 1] | |
self.bias = np.random.randn(1, 1) | |
self.weights = np.random.randn(1, input_size) | |
# used for plotting convergence | |
self.parameters_as_they_change = [np.concatenate((self.bias[0], self.weights.squeeze()), axis=0)] | |
print("Generated Perceptron:") |
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
!python visualize_lane.py --image-path=IMAGE_PATH | |
--save-path=SAVE_PATH | |
--method=baseline | |
--backbone=erfnet | |
--dataset=tusimple | |
--continue-from=erfnet_baseline_tusimple_20210424.pt | |
--height=360 | |
--width=640 |
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
from visualize_lane import * | |
!python visualize_lane.py --image-path=IMAGE_PATH | |
--save-path=SAVE_PATH | |
--method=baseline | |
--backbone=erfnet | |
--dataset=culane | |
--continue-from=erfnet_baseline_culane_20210204.pt | |
--height=288 | |
--width=800 |
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
!pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html | |
!pip install mmcv | |
!pip install ujson | |
!pip install filetype |
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
from google.colab import drive | |
drive.mount('/content/gdrive') | |
%cd gdrive/MyDrive/auto-drive/pytorch-auto-drive/ | |
!git clone https://github.com/voldemortX/pytorch-auto-drive.git |
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
lines = cv2.HoughLinesP(cropped_image, 2, np.pi/180, 100, np.array([]), minLineLength=40, maxLineGap=5) |
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 region_of_interest(image): | |
height = image.shape[0] | |
width = image.shape[1] | |
polygons = np.array([[(10,height), (width,height), (width,1100), (630, 670), (10, 1070)]]) | |
mask = np.zeros_like(image) | |
cv2.fillPoly(mask, polygons, 255) | |
masked_image = cv2.bitwise_and(image, mask) | |
return masked_image |
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 canny(image): | |
gray = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY) | |
blur = cv2.GaussianBlur(gray, (5, 5), 0) | |
canny = cv2.Canny(blur, 10, 30) | |
return canny |
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 inverse_scale_for(fp_cases, fn_cases): | |
# Converting to Numpy to be compatible with Sklearn | |
fp_cases = x_test[fp_indx].numpy() | |
fn_cases = x_test[fn_indx].numpy() | |
# Inverse transformation for the columns that were scaled: tea temp + internet speed | |
fp_cases_inv = std_scaler.inverse_transform(fp_cases[:,:2]) | |
fn_cases_inv = std_scaler.inverse_transform(fn_cases[:,:2]) | |
# Concatenating the now normally scaled columns with the book column |
NewerOlder