AI Notebooks - Tutorial - Use ResNet for image classification

How to use an existing model to do Transfer Learning?

Last updated 1st September, 2022.


This tutorial will allow you to use Transfer Learning to train an existing model on a custom dataset thanks to OVHcloud AI Notebooks.

To show how Transfer Learning can be useful, ResNet50 will be trained on a custom dataset.

USE CASE: Flower Classification

To classify flower images, the Flower Classification dataset will be used. It is available on Kaggle.

Contains information from Flower Classification, which is made available here under the CC0: Public Domain.


Transfer learning

In Machine Learning, the aim of Transfer Learning is to use the knowledge already acquired to solve a completely new, but related problem. In other words, the technique is to transfer the notions learned on a source dataset to be more efficient in the processing of a new target dataset.

For this tutorial, the goal is to do image classification. An existing model is used: ResNet50.

ResNet50 model

ResNet is a Residual neural Network structure. It is an innovative neural network created for image classification.

The ResNet model architecture allows the training error to be reduced with a deeper network through connection skip.

Residual neural networks ignore some connections and make double or triple layer jumps that contain non-linearities (ReLU).


With this method, performance is generally improved.

ResNet has many variants that work on the same concept but have different numbers of layers. Resnet50 is used to refer to the variant that can work with fifty neural network layers. It was trained on more than a million images from the ImageNet database.



First, you have to create 2 object containers in your OVHcloud Object Storage.

  • The first one contains the non-pre-processed data (base images).
  • The second object container is empty. It is intended to receive the data once processed and split for training.

To know more about how to push your data to Object Storage, please refer to the dedicated documentation.

Then, you can launch your notebook from the OVHcloud Control Panel or via the ovhai CLI.

Launching a Jupyter notebook with "Miniconda" via UI

To launch your notebook from the OVHcloud Control Panel, refer to the following steps.

Code editor

Choose the Jupyterlab code editor.


In this tutorial, the TensorFlow framework is used.

For this tutorial, you can use the following TensorFlow framework version: tf2.4-py38-cuda11.0-v22-4.


You can choose the number of CPUs or GPUs you want.

Here, using 1 GPU is sufficient.

Attach a Git container or repository

  1. Attach the object container (from the Object Storage) that contains your dataset for image classification.
  • Mount directory: /workspace/data
  • Permission: read only (RO)
  1. Attach an empty object container to store your data, once it has been processed and split for training, validation and test.
  • Mount directory: /workspace/data-split
  • Permission: read write (RW)
  1. Attach an empty object container to store your model after training.
  • Mount directory: /workspace/saved_model
  • Permission: read write (RW)

To learn more about how to use and manage your data in a notebook with UI, check this documentation.

Launching a Jupyter notebook with TensorFlow via CLI

If you want to launch it with the CLI, choose the jupyterlab editor and the tensorflow framework.

For this tutorial, you can use the following TensorFlow framework version: tf2.4-py38-cuda11.0-v22-4.

To know more about how to use and manage your data in a notebook with the CLI, refer to this documentation.

Choose the number of GPUs (<nb-gpus>) to use in your notebook and use the following command.

ovhai notebook run tensorflow jupyterlab \
        --name <notebook-name> \
        --framework-version tf2.4-py38-cuda11.0-v22-4 \
        --volume <my-data>@<region>/:/workspace/data:RO:cache \
        --volume <my-model>@<region>/:/workspace/saved_model:RW \
        --gpu <nb-gpus>

You can then reach your notebook’s URL once the notebook is running.

Accessing the notebook

Once the repository has been cloned, find your notebook by following this path: ai-training-examples > notebooks > computer-vision > image-classification > tensorflow > notebook-resnet-transfer-learning-image-classification.ipynb.

A preview of this notebook can be found on GitHub here.

Go further

  • If you want to deploy a Gradio app for Image classification or Sketch recognition, check out this documentation.
  • If you are interested in Computer Vision, familiarise yourself with Object Detection by following this tutorial.


Please send us your questions, feedback and suggestions to improve the service:

Questa documentazione ti è stata utile?

Prima di inviare la valutazione, proponici dei suggerimenti per migliorare la documentazione.

Immagini, contenuti, struttura... Spiegaci perché, così possiamo migliorarla insieme!

Le richieste di assistenza non sono gestite con questo form. Se ti serve supporto, utilizza il form "Crea un ticket" .

Grazie per averci inviato il tuo feedback.

Potrebbero interessarti anche...

OVHcloud Community

Accedi al tuo spazio nella Community Fai domande, cerca informazioni, pubblica contenuti e interagisci con gli altri membri della Community OVHcloud

Discuss with the OVHcloud community

Conformemente alla Direttiva 2006/112/CE e successive modifiche, a partire dal 01/01/2015 i prezzi IVA inclusa possono variare in base al Paese di residenza del cliente
(i prezzi IVA inclusa pubblicati includono di default l'aliquota IVA attualmente in vigore in Italia).