Skip to main content

Imagenet Image Recognition Using Tensorflow, Keras

Imagenet Dataset and Image Recognition

 

import tensorflow as tf
from tensorflow import keras
from keras.models import Sequential
from keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout
from tensorflow.keras import layers
from keras.utils import to_categorical
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
 
from keras.datasets import cifar10
(x_train, y_train),(x_test, y_test) = cifar10.load_data()
 
plt.imshow(x_train[0])
 
y_train_one_hot = to_categorical(y_train)
y_test_one_hot = to_categorical(y_test)
x_train = x_train/255
x_test = x_test/255
 
model = Sequential()
model.add(Conv2D(32,(5,5),activation='relu', input_shape=(32,32,3)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Conv2D(32,(5,5),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(1000,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(500,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(250,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.2 )
 
model.evaluate(x_test, y_test_one_hot)[1]
 
plt.plot(hist.history['accuracy'])
plt.plot(hist.history['val_accuracy'])
plt.title('Model Accuracy')
plt.xlabel('epochs')
plt.ylabel('accuracy')
plt.legend(['Train''Val'],loc='upper right')
plt.show()
 
plt.plot(hist.history['loss'])
plt.plot(hist.history['val_loss'])
plt.title('Model Loss')
plt.xlabel('epochs')
plt.ylabel('loss')
plt.legend(['Train''Val'],loc='upper right')
plt.show()
 
Imagenet Colab Link: 
 
 
 
 
 
 
 
 

 

Comments

Popular posts from this blog

Kworb.net Ranking for Youtube Videos in past 24 hours

 Most Viewed Youtube videos in Past 1 day 1. Youtube Top Video Ranks by Viewers Kworb is the popular and most famous website like Alexa ranks the youtube videos. For example, today as of writing this article the most viewed youtube video is  Maluma Album    which is viewed my nearly 1 crore viewers in 1 day of posting.   2. Taaron Ke Shehar song This song reaches 16 crores Indian hearts, ranks number 1 video in India. Song is sung by Neha Nakkar and Sunnil Kaushal. Don't miss to watch this song on Youtube   Taaron Ke Shehar   3. Music for all Once upon a time to listen to this song We have to pay Rs. 100/- per album, that to available only in Metro cities. But bcoz of Video On Deman and Pay Per View model, now available in Indian towns also. I remember the days, we watched this new songs in Chitrahar, on Doordharshan II, Beta songs 'Tak Taku milnae Ragha...'  

Kancheepuram - Kamachi Amman Temple

Kanyakumari - Kothaiyar Dam, Thiruparappu Falls, Mathur, Kulachekaram, Marthandam, Nagerkovil