Skip to content

Instantly share code, notes, and snippets.

View lucifermorningstar1305's full-sized avatar
👨‍💻
Always Coding

Adityam Ghosh lucifermorningstar1305

👨‍💻
Always Coding
View GitHub Profile
@lucifermorningstar1305
lucifermorningstar1305 / vgg_cifar.py
Last active January 13, 2019 16:01
vgg architecture
def convolutional_neural_network(x):
weights = {'W_conv1' : tf.Variable(tf.random_normal([3,3,3,64])),
'W_conv2' : tf.Variable(tf.random_normal([3,3,64,64])),
'W_conv3' : tf.Variable(tf.random_normal([3,3,64,128])),
'W_conv4' : tf.Variable(tf.random_normal([3,3,128,128])),
'W_conv5': tf.Variable(tf.random_normal([3,3,128,256])),
'W_conv6' : tf.Variable(tf.random_normal([3,3,256,256])),
'W_conv7' : tf.Variable(tf.random_normal([3,3,256,256])),
'W_conv8' : tf.Variable(tf.random_normal([3,3,256,512])),
'W_conv9' : tf.Variable(tf.random_normal([3,3,512,512])),
activation_function = lambda x: 1.0/(1.0 + np.exp(-x))
input = np.random.randn(3,1)
W1 = np.random.randn(None, 1)
W2 = np.random.randn(None,1)
W3 = np.random.randn(None,1)
b1 = np.zeros(1)
b2 = np.zeros(1)
b3 = np.zeros(1)
hidden_1 = activation(np.dot(W1, input) + b1)
hidden_2 = activation(np.dot(W2, W1) + b2)
@lucifermorningstar1305
lucifermorningstar1305 / mean_filter.py
Created January 4, 2020 11:10
Mean Filter algorithm
Mean_filter = np.array([[1,1,1], [1,1,1], [1,1,1]])/float(9)
Gm = scipy.signal.convolve2d(gray,Mean_filter,mode='same')
plt.imshow(Gm,cmap='gray')
plt.show()
@lucifermorningstar1305
lucifermorningstar1305 / median_filter.py
Created January 4, 2020 12:09
Median Filter Application
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Gm = cv2.medianBlur(gray,3)
imgs = np.array([gray, Gm])
labels = ['Original','Filtered']
for i in range(1, column*row+1):
ax = fig.add_subplot(row,column,i)
ax.set_title(labels[i-1])
plt.imshow(imgs[i-1], cmap='gray')
plt.show()
@lucifermorningstar1305
lucifermorningstar1305 / gaussian_filter.py
Created January 4, 2020 13:01
Gaussian Filter algorithm
Hg = np.zeros((20,20))
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
for i in range(20):
for j in range(20):
Hg[i,j] = np.exp(-((i-10) ** 2 + (j-10)**2)/10)
gaussian_blur = scipy.signal.convolve2d(gray, Hg, mode='same')
gray_high = gray - gaussian_blur
gray_enhanced = gray + 0.025 * gray_high
@lucifermorningstar1305
lucifermorningstar1305 / sobel_edge.py
Created January 4, 2020 14:38
Sobel Edge Filter Algorithm
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
Hx = np.array([[1,0,-1], [2,0,-2],[1,0,-1]], dtype=np.float32)
Hy = np.array([[-1,-2,-1],[0,0,0],[1,2,1]], dtype=np.float32)
Gx = scipy.signal.convolve2d(Gm, Hx, mode ='same')
Gy = scipy.signal.convolve2d(Gm,Hy,mode = 'same')
G = (Gx*Gx + Gy*Gy) ** 0.5
Filter Use
Mean Filter Reduce Gaussian Noise smooth the image after upsampling.
Median Filter Reduce salt and pepper noise.
Sobel Filter Detect edges in an image.
Gaussian Filter Reduce noise in an image.
Canny Filter Detect edges in an image.
Weiner Filter Reduce additive noise and blurring.
import numpy as np
from sklearn import preprocessing
features = np.array([[-500, 5],
[2, 10],
[4, 100],
[9, 10]])
# Create the MinMax Scaler
minmax_scaler = preprocessing.MinMaxScaler(feature_range=(0,1))
# Apply the MinMax Rescaling on our feature maps
scaled_feature = minmax_scaler.fit_transform(features)
import numpy as np
from sklearn import preprocessing
features = np.array([[-500, 5],
[2, 10],
[4, 100],
[9, 10]])
# Create the Standard Scaler
standard_scaler = preprocessing.StandardScaler()
# Apply the Standard Rescaling on our feature maps
scaled_feature = standard_scaler.fit_transform(features)
@lucifermorningstar1305
lucifermorningstar1305 / add_packages.jl
Created July 29, 2022 07:54
Adding packages to your Julia REPL
> ]
> activate .
> add IJulia BenchmarkTools Plots DataFrames CSV MLJ MLJModels TextAnalysis PyCall Chain Pipe Compose Gadfly Query Statistics StatsBase StableRNGs PrettyPrinting