|
Download readme.md from FatimaNoorAI/Transfer-learning-using_ResNet: direct link, hf CLI and curl.
- Browser
- Download file 3.24 kB
-
https://huggingface.co/FatimaNoorAI/Transfer-learning-using_ResNet/resolve/main/readme.md
- Command line
-
hf download hf://FatimaNoorAI/Transfer-learning-using_ResNet/readme.md
-
curl -L -o readme.md https://huggingface.co/FatimaNoorAI/Transfer-learning-using_ResNet/resolve/main/readme.md
3.24 kB
Transfer Learning using ResNet for Celebrity Recognition
Description
This project demonstrates transfer learning using a pretrained ResNet18 model. The final layer is modified to recognize 10 categories (simulating Bengali celebrities) instead of the original 1000 ImageNet categories. The model is trained on the CIFAR-10 dataset as a practice dataset β the same concept applies directly to the Bengali Celebrity Multimodal Dataset project.
What is Transfer Learning?
Transfer learning means borrowing a pretrained model that already knows edges, shapes, textures and face patterns from millions of images. We only replace the final layer to match our task. This saves months of training time and gives better results.
Pipeline
Load Pretrained ResNet18 β Replace Final Layer (1000 β 10) β
Train on CIFAR-10 β Evaluate on Test Data
Model Architecture
ResNet18 (pretrained on ImageNet)
β
βββ Conv layers 1-50 β already learned edges, shapes, patterns
β BORROWED from ImageNet training β
β
βββ Final layer β REPLACED
Original : Linear(512, 1000) β 1000 ImageNet categories
Modified : Linear(512, 10) β 10 celebrities
Results
Training Accuracy : 69.8% (after 2 epochs, 500 images)
Test Accuracy : 52.0% (on 200 unseen images)
Random Guessing : 10.0% (10 categories)
Transfer learning is 5x better than random guessing!
Two Types of Transfer Learning
- Feature Extraction β freeze all layers, train only final layer β good for small datasets
- Fine Tuning β train all layers, pretrained weights = starting point β good for large datasets (used in Bengali celebrity project)
Project Connection
This project directly simulates the Bengali Celebrity Multimodal Dataset pipeline:
- CIFAR-10 categories β simulates Bengali celebrities
- ResNet18 pretrained β borrows face pattern knowledge
- Final layer modified β Linear(512, 250) for 250 Bengali celebrities
- Training loop β same loop used for real celebrity recognition
Tech Stack
- Python
- PyTorch
- TorchVision
- ResNet18 (pretrained)
- CIFAR-10 Dataset
- Google Colab
How to Run
- Open notebook in Google Colab
- Run all cells in order
- Model downloads automatically
- CIFAR-10 dataset downloads automatically
- Training starts and shows accuracy per epoch
Requirements
pip install torch
pip install torchvision
Key PyTorch Concepts Used
models.resnet18(weights=DEFAULT)β load pretrained modelmodel.fc = nn.Linear(512, 10)β replace final layernn.CrossEntropyLoss()β loss for classificationtorch.optim.Adam()β optimizer for fine tuningmodel.eval()β switch to evaluation modetorch.no_grad()β disable gradient during testing
Author
Fatima Noor
Related Projects
- face-detection-scrfd β Face detection on images
- video-face-detection-scrfd β Face detection on videos
- audio-processing-mel-spectrogram β Audio processing