In this section, you will:
⚠️ WARNING:
You will only run the initial steps of model training in the Jupyter development environment.
The full training will be executed outside of Jupyter via a Pipeline to avoid an OOM Killed error (insufficient memory).
If an error occurs, your pod will be automatically deleted and recreated. Nothing serious, but your development environment will be temporarily unavailable for a few minutes.
You have previously cloned a Git repository. In the file browser on the left, you should see a folder named after the Git project: workshop-model-training.
Click on labeling-extraction.ipynb and explore the Notebook content.
Run the entire Notebook using the double-arrow icon ▶▶ in the toolbar at the top:

Click Restart when prompted:
You may have noticed that these scripts created a dataset directory. This directory contains two subfolders: images and labels, which hold the images and their corresponding annotations respectively.
In the same Notebook, scroll down to the section Select a random image and display its bounding boxes. Then, re-run the first cell just below by clicking on it, and then clicking the arrow icon ▶ in the toolbar at the top.
This cell selects a random image from the dataset/images folder and overlays the corresponding bounding boxes from dataset/labels, i.e. rectangles indicating the coordinates of the objects detected in the image.
Open the Notebook synthetic-data.ipynb.
This Notebook generates synthetic data, i.e. artificial data used to enrich the model’s training dataset.
To do this, we take photos of the tracks from the train’s point of view and randomly overlay cut-out traffic signs, simulating the various real-world conditions the train might encounter.
Run the entire Notebook as explained previously. Take time to review the code and observe the visualization examples.
You can rerun the visualization step to display other examples of synthetic data.
⚠️ Do not run this Notebook! Executing it would crash your environment, as the RAM available for each participant is limited.
Simply open the transfer-learning.ipynb Notebook and review the code to understand its functionality.
⚠️ Do not run this Notebook! Executing it would crash your environment, as the RAM available for each participant is limited.
Simply open the comparison.ipynb Notebook and review the code to understand its functionality.
In this step, you will prepare the Data Science Pipeline to run outside of the Jupyter development environment and to use a GPU to accelerate model training. In our cluster, a few small shared GPUs have already been deployed and will be used to run this Pipeline.
Open the Pipeline traffic-signs.pipeline.
You will see the Elyra graphical interface, which allows you to create and run Data Science Pipelines. Our Pipeline was built by dragging and dropping the Notebooks from the file explorer on the left.
This Pipeline currently has 4 steps and only 2 connections, so there is a missing link between the third step (transfer-learning.ipynb) and the fourth (comparison.ipynb).
To create this connection, click on the black dot on the right side of the third step (transfer-learning.ipynb).
Hold and drag it to the black dot on the left side of the fourth step (comparison.ipynb).
You should then have the complete Pipeline as shown below:

Right-click on the second step of the Pipeline (synthetic-data.ipynb).
In the menu that appears, click Open Properties. The properties will be displayed in the panel on the right.
Scroll down to view the main properties:
At the top of the properties panel, you will also find two additional tabs besides Node Properties: Pipeline Properties and Pipeline Parameters. Feel free to explore them to discover the different available settings.
Close the properties panel of the previous step.

Now modify the third step of the Pipeline (transfer-learning.ipynb). Do not touch the previous step.
Right-click the third step (transfer-learning.ipynb) and select Open Properties. Properties appear in the right panel.
Locate the GPU property and enter 1 to request a GPU for model training.

Scroll to the bottom of the configuration panel.
Nodes with GPUs have taints, which by default prevent containers from running on them. To allow this step to use a GPU, add a toleration:
Click Add under Kubernetes Tolerations and fill in the fields as follows:
nvidia.com/gpu
Now it’s time to run the Pipeline on OpenShift AI.
Click the Run Pipeline button shaped like an arrow ▷ in the toolbar at the top:

If a popup appears warning you that the Pipeline has not been saved, click Save and Submit.

In the Pipeline configuration, set the value 10 for the epochs parameter.

An epoch corresponds to one full pass of the algorithm over the training dataset.
Choosing the number of epochs is crucial for good performance:

If you missed the shortcut in the Elyra popup, follow these steps to locate your Pipeline execution info. Otherwise, skip to the next step.
1a. Go back to the OpenShift AI dashboard:
https://rhods-dashboard-redhat-ods-applications.apps.crazy-train.sandbox1781.opentlc.com
1b. In the left menu, click Experiments, then Experiments and runs.
Select the experiment associated with your Pipeline.
If you kept the default name, it is called traffic-signs and appears first.

Click the current run to view the execution status. It usually appears first in the list, with the same name as the Pipeline followed by a number.
Clicking a Pipeline step opens a side panel on the right showing details, including logs in the Logs tab.
Select main from the dropdown to see the logs from the main container for that step.

Wait until all Pipeline steps are complete and marked in green.
You should get a result similar to this:

All Pipeline outputs are saved in MinIO object storage.
Click this link to the MinIO console: https://minio-console-minio.apps.crazy-train.sandbox1781.opentlc.com.
Log in using the username that was assigned to you at the start of the workshop. The password is minio123.
You should see several buckets. Click the one matching your username:
Open this folder. You will find HTML files, Notebooks (.ipynb), and archives.
Click the comparison.html file. A menu will appear on the right. Click Download and open the file locally in your browser.


Compare the base model results with the new model. In this example, we lost some accuracy on classical traffic signs in the original dataset, but the new model can now detect LEGO signs that were previously unrecognized.