Skip to main content

Fine-Tuning a TorchVision Model using Keras

A comprehensive guide to fine-tuning a pre-trained model from TorchVision using Keras.
Created on September 17|Last edited on September 19

🎬 Introduction

TorchVision is a library part of the PyTorch project that consists of popular datasets, model architectures, and common image transformations for computer vision. In this report, we'll learn how we can fine-tune a pre-trained backbone model from TorchVision on the Imagenette dataset using KerasCore for image classification. We will also demonstrate the compatibility of KerasCore with an input system consisting of Torch Datasets and Dataloaders.
If you'd like to follow along with interactive code, just click the Colab link below and we've got you covered.
Let's get started.




Table of Contents



🎥 Initial Setup


Setup
0


💿 Creating the Input Pipeline


Creating the input pipeline
0


🤖 The Image Classification Model


The Image Classification Model
0


🏋️‍♀️ Training the Image Classification Model


Training the Image Classification Model
1


🦾 Evaluation and Inference


Evaluation and Inference
12


🏁 Conclusion

In this report, we explore the following...
  • We explore how we can use an input pipeline consisting of torch datasets and dataloaders for a training workflow in KerasCore.
  • We explore how we can fine-tune a pre-trained TorchVision module using KerasCore with the Torch backend.
  • We explore how we can manage and track our experiments using the backend-agnostic Keras callbacks from wandb-addons.
  • We explore how we can fetch the best weights from Weights & Biases artifacts and use them for evaluation and inference.
  • We also explore how we can visualize and explore model predictions using WandB Tables.
This report uses the following resources as reference:

Iterate on AI agents and models faster. Try Weights & Biases today.