Hello Everyone in this blog we have to create an object classifier program and use a pre-trained module that helps us to use it that was trained using 1000+ images of real-world just I use this module and use as per need & in this blog we have to use Google Colab that is cloud-based Application used and also support GPU feasility . so let's start and connect with us
In This blog, we have three sections in the first section we have to import all the needed libraries and make them usable in our project, further, we have to fetch all the datasets from pre-trained module and make them usable in our own drive and finally we implement it as input and get results
Source Code
#import all desier libraries like tensorflow keras and preprocessing and much more as
#i have mention bellow you can see this
from tensorflow.keras.preprocessing.image import load_img
#to convert image to array form as we know that image are the collection of pixel
#so hear we can convert into arry form
from tensorflow.keras.preprocessing.image import img_to_array
#In this section we import resnet that is pre prianed module contain 1000+ image
#use multi layers. and we import all the required module of resnet50.
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.resnet50 import preprocess_input
from tensorflow.keras.applications.resnet50 import decode_predictions
#pre tranind module classification hear we prove the input image path like
# i have use banana.jpg image as input and define it target size
mymodel=ResNet50()
#load image
myimg=load_img('banana.jpg',target_size=(224,224))
#myimg
myimg=img_to_array(myimg)
#reshap the image
myimg=myimg.reshape((1,224,224,3))
#Preprocess the image
#hear i am usng pre processing technique for output
myimg=preprocess_input(myimg)
#run the model to pridect
myresult=mymodel.predict(myimg)
#decode the image
mylabel=decode_predictions(myresult)
#Display image
mylabel=mylabel[0][0]
#print imagelabel
print('this is a:'+mylabel[1])
The end
hope you all are enjoying this blog further source file click on the given bellow link
Link:- https://colab.research.google.com/drive/1Ah-MkQfruDk2ihcRoOvLk_xhNQTAPwK1?usp=sharing


0 Comments