Skip to content

aknroshn/Image-Classification-Using-Transfer-Learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Image-Classification-Using-Transfer-Learning

Image classification model using a pre-trained InceptionV3 network with transfer learning

Project Description This project demonstrates how to build an image classification model using transfer learning with the InceptionV3 architecture. The goal is to classify images into different categories by leveraging the pre-trained weights of a model trained on a large dataset (ImageNet) and adapting it to a new, smaller dataset.

Importance Image classification is a fundamental task in computer vision with numerous applications, including:

Object recognition Medical image analysis Autonomous driving Content moderation Image search Using transfer learning allows us to build high-performing models on relatively small datasets without requiring massive computational resources for training from scratch. This makes it a practical approach for many real-world image classification problems.

Model Details The project utilizes the InceptionV3 convolutional neural network architecture. InceptionV3 is known for its efficiency and accuracy in image classification tasks.

We employ transfer learning by using a pre-trained InceptionV3 model on the ImageNet dataset. The model's convolutional base, which has learned to extract powerful features from images, is reused. We then add custom layers on top of this base to adapt the model for our specific classification task.

The custom layers include:

GlobalAveragePooling2D: Reduces the spatial dimensions of the feature maps. Dense layers: Fully connected layers that learn to classify the features extracted by the InceptionV3 base. A softmax activation function is used in the final output layer to provide class probabilities. Dataset (Describe your dataset here. For example: "The dataset used for this project consists of images of [mention your classes, e.g., 'cats and dogs']. It is split into training and testing sets stored in the /content/drive/MyDrive/Train and /content/drive/MyDrive/Test directories respectively.")

Training Process The training process involves two phases:

Feature Extraction (Frozen Layers): Initially, the convolutional base of the InceptionV3 model is frozen, meaning its weights are not updated during training. Only the weights of the newly added custom layers are trained. This allows the custom layers to learn how to map the pre-extracted features to the new classes. The model is compiled with the rmsprop optimizer and trained for a few epochs.

Fine-tuning (Unfrozen Layers): After the initial training, some of the top layers of the InceptionV3 base are unfrozen. This allows the model to fine-tune these layers and adapt the pre-trained features more specifically to the target dataset. The model is recompiled with the SGD optimizer and a lower learning rate to avoid disrupting the pre-trained weights significantly. Training continues for additional epochs in this phase.

Data augmentation techniques such as rescaling, shearing, zooming, and horizontal flipping are applied to the training data using ImageDataGenerator to improve the model's robustness and generalization.

Output Explanation The model's output for a given image is a prediction of the class it belongs to and the probability of that prediction.

Predicted Label: This is the index of the class that the model predicts the image belongs to. Probability: This is the confidence score (between 0 and 1) that the model has in its prediction for the predicted class. A higher probability indicates greater confidence. The code includes a mapping from the predicted label (index) to the actual class name based on the directory names in your training set.

How to Use (Provide instructions on how to use your trained model. For example: "To use the trained model to predict the class of a new image, you can use the predict_image function. Provide the path to your image file and the trained model as arguments.")

About

Image classification model using a pre-trained InceptionV3 network with transfer learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published