Introduction
Deep learning has become an important part of modern artificial intelligence, especially in computer vision, medical imaging, object detection, and image classification. However, training a deep neural network from scratch can require large datasets, significant computational resources, and considerable training time.
Transfer learning offers an effective alternative. Instead of training a model entirely from the beginning, we can reuse knowledge learned by a model trained on a large dataset and adapt it to a new task.
During my internship at Valentius Kryptix, I explored transfer learning through a practical image classification project called TransferVision-ML11. The project compares feature extraction, fine-tuning, and a convolutional neural network trained from scratch using Python and PyTorch.
What Is Transfer Learning?
Transfer learning is a machine learning technique in which knowledge gained from one task is reused to solve another related task.
For example, a model trained on ImageNet learns useful visual patterns such as edges, shapes, textures, and object parts. These learned representations can help the model recognize categories in a different image dataset.
Rather than learning every visual feature from scratch, a new model can build upon these existing representations.
Transfer learning is especially useful when the target dataset is relatively small or when computational resources are limited. It can reduce training requirements and provide a strong starting point for many image classification tasks.
Project Overview: TransferVision-ML11
The objective of my project was to investigate how pretrained models perform compared with a CNN trained from scratch.
I used the Oxford-IIIT Pet dataset and selected three cat breeds:
- Abyssinian
- Bengal
- Birman
The project used 600 selected images, with 200 images per class. The dataset was divided into 420 training images, 90 validation images, and 90 test images.
Images were resized to 224 × 224 pixels. I also used ImageNet normalization and data augmentation techniques, including horizontal flipping, rotation, and color adjustments.
The project was implemented using Python and PyTorch, with Matplotlib for visualizing model performance.
Approach 1: Feature Extraction
Feature extraction is one of the simplest approaches to transfer learning.
In this experiment, I used a pretrained ResNet18 model. Its original classification layer was replaced with a new classification head designed for the three target classes.
The pretrained backbone was frozen, meaning its existing weights were not updated during training. Only the newly added classification head was trained.
This approach allowed the model to reuse previously learned visual representations while learning to distinguish the selected cat breeds.
The feature extraction experiment achieved a test accuracy of 97.78%, with a training time of approximately 47.06 seconds in the recorded experiment.

Approach 2: Fine-Tuning
Fine-tuning takes transfer learning a step further.
Instead of freezing the entire pretrained backbone, I unfroze the final ResNet18 layer group, layer4, along with the new classification head. These trainable layers were then adapted to the target dataset using a lower learning rate.
This approach allows the pretrained model to adjust some of its existing representations to the characteristics of the new dataset.
Fine-tuning achieved a best validation accuracy of 96.67% and a test accuracy of 94.44%. Its recorded training time was approximately 65.67 seconds.
These results demonstrate that fine-tuning is a useful strategy, but it does not automatically outperform feature extraction in every experiment. Performance depends on factors such as dataset size, training settings, model initialization, and the number of epochs.

Approach 3: CNN Trained from Scratch
To establish a baseline, I also trained a small custom convolutional neural network from scratch.
Unlike ResNet18, this network did not use pretrained weights. It had to learn the visual features needed for classification directly from the training images.
The scratch CNN achieved a test accuracy of 60.00%, with a recorded training time of approximately 87.57 seconds.
In this experiment, both transfer learning approaches performed substantially better than the scratch CNN. This highlights the potential value of reusing pretrained representations when working with a limited dataset.
However, these results apply to this particular experimental setup and should not be treated as a universal guarantee.

Model Performance Comparison:-

Training Time Comparison:-

Key Learnings
This project helped me understand several important concepts in deep learning.
1. Reusing pretrained knowledge: Pretrained models can provide useful visual representations and reduce the amount of learning required for a new classification task.
2. Understanding feature extraction and fine-tuning: Freezing a backbone provides a simple baseline, while unfreezing selected layers allows controlled adaptation to a target dataset.
3. Evaluating models beyond accuracy: Training time, validation performance, test accuracy, and learning curves all provide useful information about a model’s behavior. Comparing these metrics gives a more complete picture than relying on a single score.
I also gained practical experience with PyTorch, image preprocessing, data augmentation, model evaluation, and visualization of training and validation curves.
Conclusion
Transfer learning is a valuable technique for building image classification systems efficiently, particularly when the available dataset is limited.
Through TransferVision-ML11, I compared feature extraction using pretrained ResNet18, fine-tuning selected layers, and training a CNN from scratch. In my recorded experiments, feature extraction achieved the highest test accuracy, while the scratch CNN provided a useful baseline for comparison.
The project strengthened my understanding of deep learning workflows and demonstrated the importance of selecting appropriate training strategies and evaluating models carefully.
I look forward to applying these concepts to more computer vision and machine learning projects as I continue developing my technical skills.
Technologies Used: Python, PyTorch, ResNet18, CNN, Matplotlib, Jupyter Notebook.
GitHub Project:
https://github.com/student-Madhumitakhatua/TransferVision-ML11




Leave a Reply
You must be logged in to post a comment.