← Back to Projects

Transfer Learning Vision API

advancedPhase 04 · DL ArchitecturesPythonPyTorchGradioTorchvision

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

  1. Collect or download a custom image dataset with 3–5 specific classes (e.g., detecting defects in manufacturing parts, or classifying dog breeds).
  2. Use torchvision to load a pre-trained ResNet18 or MobileNet.
  3. Freeze the convolutional base layers (requires_grad = False).
  4. Replace the final fully connected layer to match your number of classes.
  5. Train the model using PyTorch, saving the best weights based on validation accuracy.
  6. Write an inference script that loads the weights and predicts the class of a new image.
  7. Wrap the inference script in a Gradio web interface where users can upload an image and see the predicted class and confidence scores.

← Back to the roadmap