The whole process will be done in 4 steps :

1. Download the model from tensorflow repository.

Go to the tensorflow repository link and download the thing on your computer and extract it in root folder and since I’m using Windows I’ll extract it in “C:” drive.

Now name the folder “models”.

2. Command line

Open the Command prompt (as Admin).

Now, we need to run the classify_image.py file which is in “models>tutorials>imagenet>classify_image.py” type the following commands and press Enter.

Fig: Running the classifier file

This will download a 200mb model which will help you in recognising your image.

If everything worked perfectly you will see in your command prompt:

giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.88493)

indri, indris, Indri indri, Indri brevicaudatus (score = 0.00878)

lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00317)

custard apple (score = 0.00149)

earthstar (score = 0.00127)

Now just to make sure that we understand how to use this properly we will do this twice. Once keeping the image file in the “models>tutorials>imagenet>” directory and second keeping the image in different directory or drive 😏

3. Download the image in the directory

Feel free to use any image from the internet or anywhere else and paste it in the “models>tutorials>imagenet>images.png” directory with the classify_image.py and then we’ll paste it in “D:\images.png” or whatever directory you want to, just don’t forget to keep in mind to type the correct address in the command prompt.The image I used is below.

Fig: images.png

4. Use Command prompt to perform recognition

To perform this you need to just edit the “ — image_file” argument like this.

a) For the image in the same directory as the classify_image.py file. After coming in the imagenet directory, open the command prompt and type…

python classify_image.py --image_file images.png

Fig: images.png is the same directory

b) For image in the different directory type by pointing towards the directory where your image is placed.

python classify_image.py --image_file D:/images.png

Fig: images.png in different directory

Result

Now, obviously results for both the Images were same which is given as below.

Fig Result for images.png

As you can see the score is pretty accurate i.e. 98.028% for mobile phone.