+91-7834999925       contact@tacthub.in

Machine learning based Image classification system

Image classification is a supervised learning problem, It define as a set of target classes (objects to identify in images), and train a model to recognize them using labeled example photos. Early computer vision models relied on raw pixel data as the input to the model.


Image Classification is a systematic arrangement in groups and categories based on its features. Image classification came into existence for decreasing the gap between the computer vision and human vision by training the computer with the data. The image classification is achieved by differentiating the image into the prescribed category based on the content of the vision. Motivation by , in this project we explore the study of image classification using deep learning. The conventional methods used for image classifying is part and piece of the field of artificial intelligence (AI) formally called as machine learning. The machine learning consists of feature extraction module that extracts the important features such as edges, textures etc and a classification module that classify based on the features extracted. The main limitation of machine learning is, while separating, it can only extract certain set of features on images and unable to extract differentiating features from the training set of data. This disadvantage is rectified by using the deep learning . Deep learning (DL) is a sub field to the machine learning, capable of learning through its own method of computing. A deep learning model is introduced to persistently break down information with a homogeneous structure like how a human would make determinations. To accomplish this, deep learning utilizes a layered structure of several algorithms expressed as an artificial neural system (ANN). The architecture of an ANN is simulated with the help of the biological neural network of the human brain. This makes the deep learning most capable than the standard machine learning models.

Install the dependencies / packages.

pip install tensorflow 
pip install keras
pip install numpy 
pip install skimage 
pip install matplotlib

coding-

#Load the data

fromkeras.datasetsimportcifar10

(x_train, y_train), (x_test, y_test) =cifar10.load_data()

 

print(type(x_train))

print(type(y_train))

print(type(x_test))

print(type(y_test))

 

#Get the shape of x_train

print('x_train shape:', x_train.shape)

print('y_train shape:', y_train.shape)

print('x_test shape:', x_test.shape)

print('y_test shape:', y_test.shape)

 

x_train[0]

importmatplotlib.pyplotasplt

print('The label is:', y_train[0])

fromkeras.utilsimportto_categorical

y_train_one_hot =to_categorical(y_train)

y_test_one_hot =to_categorical(y_test)

 

 

print(y_train_one_hot)

 

print('The one hot label is:', y_train_one_hot[0])

 

x_train =x_train /255

x_test =x_test /255

In [12]:

fromkeras.modelsimportSequential

fromkeras.layersimportDense, Flatten, Conv2D, MaxPooling2D

 

model.add(Conv2D(32, (5, 5), activation='relu', input_shape=(32,32,3)

model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Conv2D(64, (5, 5), activation='relu'))

model.add(MaxPooling2D(pool_size=(2, 2)))

model.add(Flatten())

model.add(Dense(1000, activation='relu'))

model.add(Dense(10, activation='softmax'))

 

model.compile(loss='categorical_crossentropy',

              optimizer='adam',

              metrics=['accuracy'])

hist =model.fit(x_train, y_train_one_hot,

           batch_size=256, epochs=10, validation_split=0.3)

 

model.evaluate(x_test, y_test_one_hot)

plt.plot(hist.history['acc'])

plt.plot(hist.history['val_acc'])

plt.title('Model accuracy')

plt.ylabel('Accuracy')

plt.xlabel('Epoch')

plt.legend(['Train', 'Val'], loc='upper left')

plt.show()

       

plt.plot(hist.history['loss'])

plt.plot(hist.history['val_loss'])

plt.title('Model loss')

plt.ylabel('Loss')

plt.xlabel('Epoch')

plt.legend(['Train', 'Val'], loc='upper right')

plt.show()

 

 

my_image =plt.imread("cat.4014.jpg")

img =plt.imshow(my_image)

 

fromskimage.transformimportresize

my_image_resized =resize(my_image, (32,32,3))

img =plt.imshow(my_image_resized)

Price: 7000 INR

Buy Now