Image Classification using Transfer Learning

Introduction

I use here VGG19 pretrained Convolutional Neural Network for the image classification which already trained on 14 million dataset images which belongs to the 1000 classes. I didn't take any custom dataset. I just import some libraries and download the weights of the VGG19 pretrained model and simple save the model using .h5 file and just test model on different images. I have also deployed this model on localhost using the python framework (Flask).

NOTE: I doesn't use a custom dataset. I only download the weights of the VGG19 model. Try to use and deploy. If you want to learn transfer learning with custom dataset So you can follow my previous blog.

Image Classification using Transfer Learning

Transfer learning is the reuse of a pre-trained model on a new problem. It's currently very popular in deep learning because it can train deep neural networks with comparatively little data.

VGG19 is a pretrained Convolutional Neural Network. This model achieves 92.7% top-5 test accuracy in ImageNet, which is a dataset of over 14 million images belonging to 1000 classes.

Architecture of the VGG19 model

VGG19 Network Architecture

Deployment

I have also deployed this model using the python framework flask. Flask is a library of python which provides tools for the web development.
You can see the testing in the below image. This is the simple GUI of our web page. Just upload the image using the choose button. And click on the button. Let's upload the image.

You can see that i upload the groom image using the upload button and you can see the result of our model. Let's test another image.

Now i upload a panda image and you can see the result.

NOTE: If you have a gpu based laptop, then you can run .ipnyb file in local system. Otherwise you can use the Google Colab which provides a faster gpu for train a model faster. And one more thing. When you run .ipnyb. So it downloads the weights of the VGG19 whose size is 549 MB. So you need to download the model after saving and use the model with flask application.

Source code and how to use:

1. Go to my github  and download code : Image Classification using Transfer Learning

2. After download, Extract the folder.

3. Then run the .ipnyb file to download the weights of 549 MB and after downloading, just save the model and use it. 

4. Then Go into the folder.

5. Open the command prompt and go to the project folder with cd command.

6. Write (python Image_classification.py) in your prompt.

7. You will get a link like (http://127.0.0.1:5000/).

8. Paste in the Chrome or any browser.

9. Now you can use the model.



2 Comments

If you have any doubts, Please let me know

Post a Comment
Previous Post Next Post