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 cv2 | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
import pickle | |
# Read in an image and grayscale it | |
image = mpimg.imread('signs_vehicles_xygrad.png') |
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 cv2 | |
import matplotlib.pyplot as plt | |
import matplotlib.image as mpimg | |
import pickle | |
# Read in an image | |
image = mpimg.imread('signs_vehicles_xygrad.png') |
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 cv2 | |
import matplotlib | |
matplotlib.image.imread() #RGB image, | |
cv2.imread() # BGR image. | |
hls = cv2.cvtColor(im, cv2.COLOR_RGB2HLS) #HLS |
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 matplotlib.pyplot as plt | |
f, (ax1, ax2) = plt.subplots(ncols=1, nrows=2, figsize=(24, 9)) | |
f.tight_layout() | |
ax1.imshow(gradx, cmap='gray') | |
ax1.set_title('Gradx', fontsize=50) | |
ax2.imshow(grady, cmap='gray') | |
ax2.set_title('Grady', fontsize=50) | |
plt.subplots_adjust(left=0., right=1, top=0.9, bottom=0.) | |
f.savefig('grads.png') # save the figure to file | |
plt.close(f) |
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 matplotlib.image as mpimg | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import cv2 | |
import glob | |
from skimage.feature import hog | |
# Read in our vehicles and non-vehicles | |
images = glob.glob('*.jpeg') | |
cars = [] |
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 argparse | |
arg_parser = argparse.ArgumentParser() | |
arg_parser.add_argument("-p", "--path", required=True, help="Path of the files") | |
args = vars(arg_parser.parse_args()) |
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 sklearn.model_selection import train_test_split | |
X_train, X_test, y_train, y_test = train_test_split(boston_housing.data, boston_housing.target, test_size=0.2, random_state=0) | |
model = LinearRegression() | |
model.fit(X_train, y_train) |
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 skl2onnx import convert_sklearn | |
from skl2onnx.common.data_types import FloatTensorType | |
initial_type = [('float_input', FloatTensorType([1, 10]))] | |
onx = convert_sklearn(model, initial_types=initial_type) | |
with open("boston_housing.onnx", "wb") as f: | |
f.write(onx.SerializeToString()) |
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 onnxruntime as rt | |
import numpy | |
sess = rt.InferenceSession("boston_housting.onnx") | |
input_name = sess.get_inputs()[0].name | |
label_name = sess.get_outputs()[0].name | |
prediction = sess.run([label_name], {input_name: X_test.astype(numpy.float32)})[0] |
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 pydantic import BaseModel | |
class HousingFeatures(BaseModel): | |
CRIM: float | |
ZN: float | |
INDUS: float | |
CHAS: float | |
NOX: float | |
RM: float | |
AGE: float |
OlderNewer