AI Training - Tutoriel - Entraîner YOLOv8 pour jouer à pierre papier ciseaux (EN)
Objective
The purpose of this tutorial is to show how to train YOLOv8 to play the game "rock paper scissors".
YOLOv8 is an object detection algorithm. Although closely related to image classification, object detection performs image classification on a more precise scale. Object detection locates and categorizes features in images.
It is based on the YOLOv8 open source repository.
It's strongly recommended to read the Notebook tutorial Train YOLOv8 to play to "rock paper scissors" before reading this tutorial.
Requirements
- You have access to the OVHcloud Control Panel.
- You have created a Public Cloud project.
- The ovhai CLI interface is installed on your system (find more information here).
- You have Docker installed and configured to build images.
- You have an OCI / Docker image registry available. You can use a public registry (such as Docker Hub for example) or a private registry. Refer to the Creating a private registry documentation to create a private registry based on Harbor. To make your registry compatible with AI Solutions usage, follow the Use & manage your registries guide.
- You have knowledge about building images with Dockerfile.
Instructions
Create object storage for data
To train the model you'll need data and a place where to save the trained model.
You can reuse the previous object storage used in the Notebook tutorial Train YOLOv8 to play to "rock paper scissors" or follow the step Create Object Storage containers of this same tutorial.
Train your model
All source code is available on the GitHub repository ai-training-examples.
To train the model, we will use AI Training. This powerful tool will allow you to automate your pipelines and build fine-tuning phases easily.
AI Training allows you to train models directly from your own Docker images.
First, you need to create a Python script that is in charge of doing the training.
You can copy and paste the following code in a file named train-rock-paper-scissors:
Then, create a requirements.txt file to declare the Python dependencies:
ultralytics==8.0.194
opencv-python-headless==4.8.1.78
Then, create a Dockerfile compliant with AI Training.
You can copy and paste the following code into a file named Dockerfile:
Then, build the Docker image and push it in the shared registry:
The output should be similar to this:
Warning
The shared registry should only be used for testing purposes. Please consider creating and attaching your own registry. More information about this can be found here. The images pushed to this registry are for AI Tools workloads only, and will not be accessible for external uses.
You can find the address of your shared registry by launching this command:
Then, log in on your shared registry with your usual AI Platform user credentials:
You will then be able to build and push your image on this shared registry.
Once your Docker image is created and pushed into the registry, you can directly use the ovhai command to create your model training.
You can launch the training specifying more or less GPU depending on the speed you want for your training.
If your images are stored in a private registry, please follow the documentation Registries - Use & manage your registries to add your registry.
The output should be similar to this:
You can access the execution logs of your job with the CLI:
The output should be similar to this:
For more explanations about the CLI commands for AI Training, please read this guide: CLI Reference.
Once you have your model ready, deploy the model to use it. This will be done with the AI Deploy tool.
Go further
All the source code is available on the OVHcloud GitHub organization.
To create the application using the trained model, you can follow this tutorial: Deploy an app for playing "rock paper scissors".
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.
Feedback
Please send us your questions, feedback and suggestions to improve the service:
- On the OVHcloud Discord server