← Back to Projects
Transfer Learning Vision API
Fine-tune a pre-trained ResNet model on a custom dataset and deploy it behind a simple Gradio UI or FastAPI endpoint.
What you'll learn
- Utilizing pre-trained CNN weights (ResNet, MobileNet)
- Freezing base layers and replacing the classifier head
- Fine-tuning a model on a niche dataset
- Deploying a computer vision model with a visual UI
Architecture
Pre-trained ResNet (Torchvision)
→ Replace Final Layer (Custom Classes)
→ Fine-tune on Custom Image Dataset
→ Export Weights
→ Serve via Gradio UI for Image Uploads
Steps
- Collect or download a custom image dataset with 3–5 specific classes (e.g., detecting defects in manufacturing parts, or classifying dog breeds).
- Use
torchvisionto load a pre-trained ResNet18 or MobileNet. - Freeze the convolutional base layers (
requires_grad = False). - Replace the final fully connected layer to match your number of classes.
- Train the model using PyTorch, saving the best weights based on validation accuracy.
- Write an inference script that loads the weights and predicts the class of a new image.
- Wrap the inference script in a
Gradioweb interface where users can upload an image and see the predicted class and confidence scores.