Posts

Kernal implementaion Exp-7

import numpy as np import cv2 import matplotlib . pyplot as plt img = cv2 .imread( 'butterfly.jpg' ) gray = cv2 .cvtColor( img , cv2 .COLOR_BGR2GRAY) blur = cv2 .GaussianBlur( gray , ( 5 , 5 ), 0 ) # Robert Edge Detection kernelxx = np .array([[ 1 , 0 ], [ 0 , - 1 ]]) kernelyy = np .array([[ 0 , 1 ], [- 1 , 0 ]]) img_robertx = cv2 .filter2D( img , - 1 , kernelxx ) img_roberty = cv2 .filter2D( img , - 1 , kernelyy ) grad = cv2 .addWeighted( img_robertx , 0.5 , img_roberty , 0.5 , 0 ) plt . imshow ( grad , cmap = 'gray' ) plt . title ( "Robert Edge Detection" ) plt . axis ( 'off' ) # Laplacian laplacian = cv2 .Laplacian( img , cv2 .CV_64F) sobelx = cv2 .Sobel( src = blur , ddepth = cv2 .CV_64F, dx = 1 , dy = 0 , ksize = 3 ) sobely = cv2 .Sobel( src = blur , ddepth = cv2 .CV_64F, dx = 0 , dy = 1 , ksize = 3 ) fig , axs = plt . subplots ( 2 , 2 ) titles = [ 'Original' , 'Sobel along X-axis' , 'Sobel along Y-axis...

Edge Dedection Exp-6

import cv2 import matplotlib . pyplot as plt import numpy as np # Canny img = cv2 .imread( 'butterfly.jpg' ) # converting the image to grayscale gray = cv2 .cvtColor( img , cv2 .COLOR_BGR2GRAY) blur = cv2 .GaussianBlur( gray , ( 5 , 5 ), 0 ) # the second parm is the size of the kernel # wider the threshold range, more the edges canny = cv2 .Canny( img , threshold1 = 180 , threshold2 = 200 ) fig , axs = plt . subplots ( 2 , 2 ) titles = [ 'Original' , 'Grayscale' , 'Gaussian Blur' , 'Canny' ] axs [ 0 , 0 ].imshow( cv2 .cvtColor( img , cv2 .COLOR_BGR2RGB)) axs [ 0 , 0 ].set_title( titles [ 0 ]) axs [ 0 , 0 ].axis( 'off' ) axs [ 0 , 1 ].imshow( cv2 .cvtColor( gray , None )) axs [ 0 , 1 ].set_title( titles [ 1 ]) axs [ 0 , 1 ].axis( 'off' ) axs [ 1 , 0 ].imshow( cv2 .cvtColor( blur , None )) axs [ 1 , 0 ].set_title( titles [ 2 ]) axs [ 1 , 0 ].axis( 'off' ) axs [ 1 , 1 ].imshow( cv2 .cvtColor( canny , None )) axs...

MLP Exp-5

 import tensorflow as tf import numpy as np from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Flatten from tensorflow.keras.layers import Dense from tensorflow.keras.layers import Activation import matplotlib.pyplot as plt (x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data() # Cast the records into float values x_train = x_train.astype('float32') x_test = x_test.astype('float32')    # normalize image pixel values by dividing  # by 255 gray_scale = 255 x_train /= gray_scale x_test /= gray_scale print("Feature matrix:", x_train.shape) print("Target matrix:", x_test.shape) print("Feature matrix:", y_train.shape) print("Target matrix:", y_test.shape) fig, ax = plt.subplots(10, 10) k = 0 for i in range(10):     for j in range(10):         ax[i][j].imshow(x_train[k].reshape(28, 28),                          aspect='auto') ...

SLP EXP-4

from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras.activations import hard_sigmoid import matplotlib.pyplot as plt from keras.callbacks import History import pandas as pd import numpy as np history=History() if _name_ == "_main_":     # Load the Pima diabetes dataset from CSV     # and convert into a NumPy matrix suitable for     # extraction into X, y format needed for TensorFlow     diabetes = pd.read_csv('/home/user/Downloads/diabetes.csv').values     # Extract the feature columns and outcome response     # into appropriate variables     X = diabetes[:, 0:8].astype(np.float32)     y = diabetes[:, 8].astype(np.float32)     # Create the 'Perceptron' using the Keras API     model = Sequential()     model.add(Dense(1, input_shape=(8,), activation=hard_sigmoid, kernel_initializer='glorot_uniform'))     model.com...

LINEAR RESGRESSION EXP-2

Ex2 import numpy as np import tensorflow.compat.v1 as tf import matplotlib.pyplot as plt tf.disable_v2_behavior() #fixing seeds np.random.seed(101) tf.set_random_seed(101) # Generating random linear data x = np.linspace(0, 50, 50) y = np.linspace(0, 50, 50) # Adding noise to the random linear data x += np.random.uniform(-4, 4, 50) y += np.random.uniform(-4, 4, 50) n = len(x) # Plot of Training Data plt.scatter(x, y) plt.xlabel('x') plt.ylabel('y') plt.title("Training Data") plt.show() X = tf.placeholder("float") Y = tf.placeholder("float") #defining weights and bias W = tf.Variable(np.random.randn(), name = "W") b = tf.Variable(np.random.randn(), name = "b") #hyperparameters lr = 0.01 epochs = 100 # Hypothesis y_pred = tf.add(tf.multiply(X, W), b) # Mean Squared Error Cost Function cost = tf.reduce_sum(tf.pow(y_pred-Y, 2)) / (2 * n) # Gradient Descent Optimizer optimizer = tf.train.GradientDescentOptimizer(lr).minimize(c...

IOT based Home automation Project Controlled by Google Assistant--Product Creation

Image
 Home Automation is controlling lighting, climate, entertainment systems, and appliances without a manual switch. It may also include home security such as access control and alarm systems. When connected and controlled with the Internet, home devices are an important constituent of the Internet of Things (“IoT”). NodeMCU is very popular in Home Automation. It’s WiFi capabilities and Arduino IDE support making it easier for IoT Applications. It is very tiny and has many Digital I/O pins, Serial Communication and I2C Communication. NodeMCU has a micro USB port to program it using your existing mobile cable (no additional programmer needed). There is a successor called ESP32 Development board which has more Analog pins and Digital pins.  Using Blynk is a mobile application which has its own server to process user requests. It is an open source application and anybody can use it in their Home Automation to control devices, monitor sensor data and get a notification by some trigge...

Naturally Simulated Prosthetic Arm With Electro Myo Grapy(EMG)-Robotic Arm (Product Creation):

Image
       In today’s society a hand amputee can expect a replacement hand that replicates a normal hand functions. However due to the cost constraints, the automated prosthetic arms are still out of the reach of needy people. So we made a naturally simulated prosthetic arm at cheap rate.  We used 3-D printer to print the parts of the arm and used servo motors to actuate the fingers, wrist and elbow. Electro Myo Graphy(EMG) sensor is used to get the signals from the muscle and controls the servo motors.  Graphic(EMG) sensor is used to get the signals from the muscle and controls the servo motor using Arduino. Structural View   Full assembly Servo assemble Servo reassembled for our application Designing Part Designing Part Main board and vibrating sensor for user alerts because when the user will touch Heat, Over weight Lifting the sensor will vibrate and give the sense. Labeling  Used connectors easy to maintenance Used connectors easy to maintenanc...