[YOLO] Semantic segmentation and instance segmentation (4)

0 YOLO series notes

1 Introduction

  In the previous practice, I summarized how to use YOLOv5 for target recognition, from setting up the environment to training your own data set, and then deploying the trained model using OpenCV. This article mainly expands the application field-semantic segmentation. , or focus on getting started with applications.

2 Basic concepts

  Before starting, you might as well understand what semantic segmentation and instance segmentation are. Refer to this article . Simply put, semantic segmentation assigns a category to each pixel of the image, but objects in the same category are not distinguished. of. Instance segmentation only classifies specific objects, which is very similar to target recognition. In fact, I think it can be understood as "refined target recognition" , that is, the boundary is no longer limited to a box, but an irregular boundary. You can use the following picture to show it [the picture is also from the above article]

Insert image description here

3 data sets

  Like target recognition, the training data set structure for segmentation problem is also as follows.

├───images
│   ├───train
│   └───val
└───labels
│    ├───train
│    └───val
└───data.yaml

Among them, yamlthe file format and target recognition are also the same, and will not be repeated here.

  The other is the style of labels in the data set. Just like target recognition, the label format must be converted to YOLO format before training the data, as shown below.

Insert image description here

Among them, the leftmost side is the target category, and the right side is 2*Na floating point number between 0 and 1, which represents the N point coordinates of the target outline , all of which are normalized values.

4 training

  Just like the previous training target recognition, if you do not need to change the parameters, you can directly run the python file under the yolo project. segmentThere is a folder under the project , and the code inside is the program for training semantic segmentation.
Insert image description here

Similarly, the usage method is also clearly written in the comments before the file:

Insert image description here

5 Data annotation

  What if you still need to create the data set and label yourself? There seems to be annotation software similar to labelImg, called labelme . The installation method is the same as labelImg. It can be installed directly through pip:

pip install labelme

It is also relatively simple to use and you can get started quickly. Here is a link to use it .

Guess you like

Origin blog.csdn.net/ZHOU_YONG915/article/details/132004567