AI Notebooks - Tutorial - Use ResNet for image classification
How to use an existing model to do Transfer Learning?
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.
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.
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.
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.
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.
To launch your notebook from the OVHcloud Control Panel, refer to the following steps.
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.
/workspace/data
read only
(RO)/workspace/data-split
read write
(RW)/workspace/saved_model
read write
(RW)To learn more about how to use and manage your data in a notebook with UI, check this documentation.
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.
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.
Please send us your questions, feedback and suggestions to improve the service:
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.
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