Detailed use of Roboflow for deep learning (10): dataset annotation, training and download

Roboflow detailed explanation: dataset labeling, training and downloading

This article has been modified on the basis of using the Roboflow tool recommended by YOLOv8 to train your own data set

  • Introduce how to download open source datasets from the website
  • Introduce in detail how to use roboflow to label data sets and automatically convert them into data formats that can be directly trained

Get open source datasets

  • Jump to find the open source page
    insert image description here

  • Search for the desired dataset
    insert image description here

  • After searching, some data set project names will appear, choose the one you want and click to download
    insert image description here

  • Select the corresponding model
    insert image description here

  • According to the command in Jupyter format, convert it to a cmd command and download it
    insert image description here

  • for example:
    insert image description here

YOLOv8 is the latest version of the YOLO target detection and image segmentation model developed by Ultralytics . Compared with the previous version, YOLOv8 can identify and locate objects in images more quickly and efficiently, and classify them more accurately.

As a deep learning technique, YOLOv8 requires a large amount of training data to achieve the best performance. In order for YOLOv8 to effectively recognize objects in their own applications, developers need to prepare a large amount of training data, and building a custom data set is a very time-consuming process, often collecting images, labeling them and exporting them in the correct format It may take dozens or even hundreds of hours. In order to solve this problem, YOLOv8 recommended a powerful open source tool —— Roboflow in the official tutorial .

Introduction to Roboflow

Roboflow is an automated training data tool designed for YOLOv8, which provides a more convenient and faster way to prepare training data for YOLOv8. It can automatically extract the required information from the raw image data provided by the developer and convert it into a format that YOLOv8 can use directly . Roboflow also provides a unique labeling method that makes it easier for developers to set labels for objects in images so that YOLOv8 can recognize them more effectively. This article will introduce how to use Roboflow to train YOLOv8 custom data sets.

Create your own dataset

First, we organize the pictures we want to train into a folder, and set the size and format of the pictures to be unified.

Next, create a dataset using Roboflow. Go to the Roboflow official website and click the upper right corner to register an account, then use Roboflow to annotate the custom data set and export it directly to YOLOv8 for training. The specific operation steps are as follows:

 

After importing the target folder, double-click any picture to enter the annotation. Here we take the first picture as an example. The operation steps are shown in the figure:

 

After the picture is marked, click on the upper right to save it after returning. Select "Split Images Between Train/Vaild/Test" to automatically divide the training set, verification set and test set according to the system recommendation, and finally export the compressed file to the computer.

training dataset

Decompress the obtained dataset compression package to the main path of the warehouse. In order to facilitate subsequent calls to CLI commands, here we rename the dataset to "flyerdata".

Then copy the data set to the path shown in the figure below (YOLOv8 will find data from this path by default when training the data set).

Open the "data.yaml" in the self-created dataset in "pycharm" and modify the path in the file.

After modifying and saving, enter in the terminal under the yolov8 environment:

yolo task=detect mode=train model=yolov8n.pt data=flyerdata/data.yaml epochs=100 imgsz=640 workers=4 batch=4
   
   
    
    

At the same time, modify the "data=" suffix to the path of your own data set, and press Enter to start training. After the training is complete, the result will be saved in the path indicated by the last line.

predict new data

After the training is complete, you will get a training set model that belongs to you.

Modify the following code according to the location of your dataset training result model to complete model verification:

yolo task=detect mode=val model=runs/detect/train5/weights/best.pt data=flyerdata/data.yaml
   
   
    
    

Predictions on new data

To use the verified training set model to predict new data, we need to collect the same type of pictures related to our data set and make a new folder. The size and format of the pictures should be consistent with the previous data set pictures. Here we will use the new The images folder is named "images" and placed in the repository's main path.

Next, modify the following code according to the location of the training result model of the dataset. "source" refers to the location of the new image folder. Since we have placed the folder in the main path of the warehouse, we can directly modify it to "source=images" , and start predicting.

yolo detect mode=predict model=runs/detect/train5/weights/best.pt source=images
   
   
    
    

If you need to use the dataset model obtained after training to train videos, put the video you want to train on the main path of the warehouse, and then use the following code (change the "source=" suffix to the path of the video) to call:

yolo detect mode=predict model=runs/detect/train5/weights/best.pt source=video/1.mp4
   
   
    
    

After the prediction is completed, the prediction result is also automatically saved in the path specified in the last line.

Summarize

All in all, Roboflow is a very useful tool that provides a simple way to adjust the training data so that it can better adapt to the requirements of YOLOv8, helping us prepare the training data required for YOLO v8 more easily. It is also possible to automatically convert and label images, as well as set specific training parameters for different training data sets, ensuring that YOLOv8 can recognize objects more effectively, so that YOLOv8 can learn more effectively.

Related resource links

[1] Roboflow official website: https://roboflow.com/?ref=ultralytics

[2] YOLOv8 project address: https://github.com/ultralytics/ultralytics

[3] YOLOv8 official tutorial: https://blog.roboflow.com/how-to-train-yolov8-on-a-custom-dataset/#preparing-a-custom-dataset-for-yolov8

- END -

 Amu Lab provides open source software and hardware tools and course services for robot research and development, making research and development more efficient!

YOLOv8 is the latest version of the YOLO target detection and image segmentation model developed by Ultralytics . Compared with the previous version, YOLOv8 can identify and locate objects in images more quickly and efficiently, and classify them more accurately.

As a deep learning technique, YOLOv8 requires a large amount of training data to achieve the best performance. In order for YOLOv8 to effectively recognize objects in their own applications, developers need to prepare a large amount of training data, and building a custom data set is a very time-consuming process, often collecting images, labeling them and exporting them in the correct format It may take dozens or even hundreds of hours. In order to solve this problem, YOLOv8 recommended a powerful open source tool —— Roboflow in the official tutorial .

Introduction to Roboflow

Roboflow is an automated training data tool designed for YOLOv8, which provides a more convenient and faster way to prepare training data for YOLOv8. It can automatically extract the required information from the raw image data provided by the developer and convert it into a format that YOLOv8 can use directly . Roboflow also provides a unique labeling method that makes it easier for developers to set labels for objects in images so that YOLOv8 can recognize them more effectively. This article will introduce how to use Roboflow to train YOLOv8 custom data sets.

Create your own dataset

First, we organize the pictures we want to train into a folder, and set the size and format of the pictures to be unified.

Next, create a dataset using Roboflow. Go to the Roboflow official website and click the upper right corner to register an account, then use Roboflow to annotate the custom data set and export it directly to YOLOv8 for training. The specific operation steps are as follows:

 

After importing the target folder, double-click any picture to enter the annotation. Here we take the first picture as an example. The operation steps are shown in the figure:

 

After the picture is marked, click on the upper right to save it after returning. Select "Split Images Between Train/Vaild/Test" to automatically divide the training set, verification set and test set according to the system recommendation, and finally export the compressed file to the computer.

training dataset

Decompress the obtained dataset compression package to the main path of the warehouse. In order to facilitate subsequent calls to CLI commands, here we rename the dataset to "flyerdata".

Then copy the data set to the path shown in the figure below (YOLOv8 will find data from this path by default when training the data set).

Open the "data.yaml" in the self-created dataset in "pycharm" and modify the path in the file.

After modifying and saving, enter in the terminal under the yolov8 environment:

yolo task=detect mode=train model=yolov8n.pt data=flyerdata/data.yaml epochs=100 imgsz=640 workers=4 batch=4
   
   
  
  

At the same time, modify the "data=" suffix to the path of your own data set, and press Enter to start training. After the training is complete, the result will be saved in the path indicated by the last line.

predict new data

After the training is complete, you will get a training set model that belongs to you.

Modify the following code according to the location of your dataset training result model to complete model verification:

yolo task=detect mode=val model=runs/detect/train5/weights/best.pt data=flyerdata/data.yaml
   
   
  
  

Predictions on new data

To use the verified training set model to predict new data, we need to collect the same type of pictures related to our data set and make a new folder. The size and format of the pictures should be consistent with the previous data set pictures. Here we will use the new The images folder is named "images" and placed in the repository's main path.

Next, modify the following code according to the location of the training result model of the dataset. "source" refers to the location of the new image folder. Since we have placed the folder in the main path of the warehouse, we can directly modify it to "source=images" , and start predicting.

yolo detect mode=predict model=runs/detect/train5/weights/best.pt source=images
   
   
  
  

If you need to use the dataset model obtained after training to train videos, put the video you want to train on the main path of the warehouse, and then use the following code (change the "source=" suffix to the path of the video) to call:

yolo detect mode=predict model=runs/detect/train5/weights/best.pt source=video/1.mp4
   
   
  
  

After the prediction is completed, the prediction result is also automatically saved in the path specified in the last line.

Summarize

All in all, Roboflow is a very useful tool that provides a simple way to adjust the training data so that it can better adapt to the requirements of YOLOv8, helping us prepare the training data required for YOLO v8 more easily. It is also possible to automatically convert and label images, as well as set specific training parameters for different training data sets, ensuring that YOLOv8 can recognize objects more effectively, so that YOLOv8 can learn more effectively.

Related resource links

[1] Roboflow official website: https://roboflow.com/?ref=ultralytics

[2] YOLOv8 project address: https://github.com/ultralytics/ultralytics

[3] YOLOv8 official tutorial: https://blog.roboflow.com/how-to-train-yolov8-on-a-custom-dataset/#preparing-a-custom-dataset-for-yolov8

- END -

 Amu Lab provides open source software and hardware tools and course services for robot research and development, making research and development more efficient!

Guess you like

Origin blog.csdn.net/yohnyang/article/details/131353572