Skip to content

Instantly share code, notes, and snippets.

@aishwarya-singh25
aishwarya-singh25 / bounding_boxes.py
Created Jul 31, 2020
Non max suppression implementation
View bounding_boxes.py
import matplotlib.pyplot as plt
import matplotlib.patches as patches
image = plt.imread('index.jpg')
# draw emtpy figure
fig = plt.figure()
# define axis
ax = fig.add_axes([0, 0, 1, 1])
@aishwarya-singh25
aishwarya-singh25 / backprop_convolv.py
Last active Apr 15, 2022
CNN from scratch using numpy
View backprop_convolv.py
filter_update = []
for i in range(f.shape[2]):
for j in range(f.shape[0]):
for k in range(f.shape[1]):
temp = 0
spos_row = j
spos_col = k
epos_row = spos_row + s_row
epos_col = spos_col + s_col
for l in range(X.shape[2]):
View data_info.py
#loading data
import pandas as pd
data = pd.read_csv('train_LZdllcl.csv')
#data summary
data.info()
View changing_dtype.py
import pandas as pd
data = pd.read_csv('Train_SU63ISt.csv')
data['Datetime'] = pd.to_datetime(data['Datetime'],format='%d-%m-%Y %H:%M')
data.dtypes
@aishwarya-singh25
aishwarya-singh25 / building_kmeans.py
Created Oct 25, 2019
Gaussian Mixture Models Implementation
View building_kmeans.py
#training k-means model
from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=4)
kmeans.fit(data)
#predictions from kmeans
pred = kmeans.predict(data)
frame = pd.DataFrame(data)
frame['cluster'] = pred
frame.columns = ['Weight', 'Height', 'cluster']
View feature_matching.py
import cv2
import matplotlib.pyplot as plt
%matplotlib inline
# read images
img1 = cv2.imread('eiffel_2.jpeg')
img2 = cv2.imread('eiffel_1.jpg')
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
@aishwarya-singh25
aishwarya-singh25 / adjust_gamma.py
Last active Sep 14, 2021
Preprocessing Techniques
View adjust_gamma.py
from skimage import exposure
#adjusting brightness
image = imread('images.jpeg')
image_bright = exposure.adjust_gamma(image, gamma=0.5,gain=1)
image_dark = exposure.adjust_gamma(image, gamma=1.5,gain=1)
# plotting images
plt.subplot(131), imshow(image)
plt.title('Original Image')
@aishwarya-singh25
aishwarya-singh25 / hog.py
Created Aug 29, 2019
HOG feature Descriptor
View hog.py
#creating hog features
fd, hog_image = hog(resized_img, orientations=9, pixels_per_cell=(8, 8),
cells_per_block=(2, 2), visualize=True, multichannel=True)
View edge_features
#importing the required libraries
import numpy as np
from skimage.io import imread, imshow
from skimage.filters import prewitt_h,prewitt_v
import matplotlib.pyplot as plt
%matplotlib inline
#reading the image
image = imread('puppy.jpeg',as_gray=True)