Use of LabelImg annotation tool (obtaining annotated image data set)

1 Installation and use

1.1 Installation

Win+ REnter cmdto enter the terminal interface

LabelImgInstallation command:

pip install labelimg

If the domestic pip source is not configured, please see ⇒ \Rightarrow

  1. Temporary workaround: add the source at the end of the above command, such as
pip install labelimg -i https://pypi.tuna.tsinghua.edu.cn/simple
  1. Permanent solution: You can refer to 5 of my blog Configuring the python environment on Centos7 to change the pip source (including two methods of windows system and centos system)

1.2 Use

LabelImgAfter successful installation

Call command:

labelimg

Then the program pops out and the interface is as follows:

Insert image description here

We can also use the following calling command:

labelimg JPEGImages classes.txt

Open the folder LabelImgwhile opening the tool , and initialize the classes defined in it (so we don't need to manually enter tags when annotating pictures)JPEGImageclasses.txt

In addition, in order to more conveniently label images, we first need to set the following items in LabelImgthe Tools viewtab:

Insert image description here

2 Annotation format

LabelImgIt is an open source data annotation tool that can annotate three formats:

  1. PascalVOCLabel format, save as xmlfile

The form is as follows:

<?xml version='1.0' encoding='us-ascii'?>
<annotation>
	<folder>hat01</folder>
	<filename>000000.jpg</filename>
	<path>D:\dataset\hat01\000000.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>947</width>
		<height>1421</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>hat</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>60</xmin>
			<ymin>66</ymin>
			<xmax>910</xmax>
			<ymax>1108</ymax>
		</bndbox>
	</object>
</annotation>
  1. YOLOLabel format, save as txtfile

The form is as follows:

0 0.512143611404435 0.4130893736805067 0.8975712777191129 0.733286418015482

Separated by spaces, respectively represent 类别(starting from 0), normalized frame x_center, normalized frame, normalized y_centerframe w, normalized frameh

  • Normalized coordinates are a method of describing object positions and dimensions as relative image sizes, commonly used in object detection and computer vision tasks. Under normalized coordinates, the object position and size become values ​​between 0 and 1 , which is convenient for neural network processing. If these values ​​are passed directly to the neural network, it will be difficult for the model to handle due to the differences in different image sizes and object sizes.
  • Therefore , we need to convert these values ​​into normalized coordinates by dividing x_center, y_center, by the width or height of the image , respectively, that is , , ,whwidthheightx_center/widthy_center/heightw/widthh/height
  1. CreateMLLabel format, save as jsonformat

The form is as follows:

[{
    
    "image": "000000.jpg", "annotations": [{
    
    "label": "hat", "coordinates": {
    
    "x": 490.3947368421052, "y": 593.5526315789473, "width": 832.0, "height": 1023.9999999999999}}]}]

Guess you like

Origin blog.csdn.net/hu_wei123/article/details/131876440