Image Classification with Transfer Learning
Transfer learning is repurposing a pre-trained model for another but similar usage. This method is seen in various machine learning applications especially in situations where the dataset is relatively small.
In this project, I built an image classification model from scratch using transfer learning. When I said from scratch, the dataset was my custom dataset which I scrapped using the IDT tool with my own custom classes. You can read about this tool here.
Problem statement:
Most people tend to have issues classifying bags and carry-ons. In this project, I chose to work with 5 classes namely; Backpack, Briefcase, Duffle, Handbag and purse.
Data collection and cleaning:
Like I stated earlier, I used the IDT tool to scrape images from the web then I cleaned the data which happened to be the most tedious of all processes. In all, the dataset contained 2000 images divided into 400 images per class which I cleaned manually. I removed duplicates and images with associated keywords, but has no correlation with the intended images.
Data preprocessing:
I rescaled the images and performed a validation split of 20% before performing the image data generator function from Keras.
Then I got the class labels and indices.
Model building:
Using Tensorflow hub, I imported a pre-trained model which was the second version of mobilenet because of its scalability.
I compiled the model using Adam optimizer with learning rate of 0.001, categorical_crossentropy loss and the ‘metrics’ accuracy.
Model training:
I trained the model using 10 epochs.
Then I used matplotlib to plot the graph of the training of the model.
Model Prediction:
After I viewed the validation batch shape and prediction result shape, I visualized the model’s predictions with the correct labels in green and the incorrect labels in red.
Conclusion:
In the project folder, there are two more models done without transfer learning and looking at their graphs, they were overfitting. The project is found here and I would welcome feedbacks on this project. You can connect with me on LinkedIn. Thank you for reading