This repository provides a Jupyter Notebook for fine-tuning the ResNet-50 model on the CIFAR-100 dataset using the Hugging Face Transformers library. The goal is to fine-tune a pre-trained model to classify images into 100 different categories.
ResNet-50 is a deep residual network that has shown excellent performance in various image classification tasks. In this project, a pre-trained ResNet-50 model is fine-tuned on the CIFAR-100 dataset in order to improve its accuracy in classifying images into 100 categories.
The CIFAR-100 dataset is used for training and evaluation. It consists of 60,000 color images in 100 classes, with 600 images per class. The dataset is divided into 50,000 training images and 10,000 test images.
- Python 3.7 or higher
- streamlit
- torch
- numpy
- torchvision
- torchaudio
- transformers
- datasets
- accelerate
-
Clone the repository:
git clone https://github.com/youzaina001/Fine_tuning_microsoft_resnet_50_using_hugging_face.git cd Fine_tuning_microsoft_resnet_50_using_hugging_face
-
Install the required packages:
pip install -r requirements.txt
-
Launch the Jupyter Notebook:
jupyter notebook
-
Open the
vision.ipynb
notebook and run the cells in sequence to start the training process.
The training script is set up to:
-
Load the CIFAR-100 dataset:
- Uses the
datasets
library to load the CIFAR-100 dataset.
- Uses the
-
Preprocess the dataset:
- Converts the images to PyTorch tensors.
-
Fine-tune the ResNet-50 model:
- The model is initialized with weights pre-trained on ImageNet.
- The number of output labels is set to 100 to match the CIFAR-100 dataset.
-
Configure Training Parameters:
- Uses the
Trainer
API from Hugging Face Transformers to define training arguments such as learning rate, batch size, and the number of epochs.
- Uses the
-
Start Training:
- The model is trained on a GPU (if available) or a CPU.
After training, the model is evaluated on the test dataset to calculate accuracy and loss. The results are printed in the notebook.