Skip to main content

一个自由转换图像标注格式的工具

Project description

图像标注格式转换器(image-annotations)

使用方法

标注文件说明

标注格式文件类型一张图片对应一个检测框对应
YOLOtxt一个txt文件txt文件中的一行
VOCxml一个xml文件xml文件中的一个object标签
COCOjsonjson文件中images的一项json文件中annotations的一项

YOLO格式

YOLO格式的目标检测标注文件通常以txt文件给出,一个txt标注文件对应一张图片,txt文件的一行对应一个目标检测框。标注格式如下:
class_id x_center/width y_center/height w/width h/height
其中,class_id表示类别ID,x_center表示标注框中心点x坐标,y_center表示标注框中心点y坐标,w表示标注框宽度,h表示标注框高度,width表示图片宽度,height表示图片高度。
txt标注文件示例如下:
2 0.079166666 0.6759259 0.090625 0.11666667
1 0.22552083 0.67314816 0.015625 0.048148148
1 0.21484375 0.6759259 0.0140625 0.04074074
1 0.1890625 0.6726852 0.016666668 0.047222223
1 0.17916666 0.67083335 0.014583333 0.049074072
1 0.15520833 0.6712963 0.015625 0.05

VOC格式

VOC格式的目标检测文件通常以xml文件给出,一个xml标注文件对应一张图片,xml文件的一个object标签对应一个目标检测框。
xml标注文件示例如下:
<annotation>
	<folder>Desktop</folder>
	<filename>test.jpg</filename>
	<path>/home/DrZon/test.jpg</path>
	<source>
		<database>Unknown</database>
	</source>
	<size>
		<width>194</width>
		<height>259</height>
		<depth>3</depth>
	</size>
	<segmented>0</segmented>
	<object>
		<name>categoryName</name>
		<pose>Unspecified</pose>
		<truncated>0</truncated>
		<difficult>0</difficult>
		<bndbox>
			<xmin>56</xmin>
			<ymin>22</ymin>
			<xmax>132</xmax>
			<ymax>229</ymax>
		</bndbox>
	</object>
</annotation>

COCO格式

COCO格式的目标检测标注文件通常以json文件给出,将所有图片的所有标注写在同一个文件里面,示例格式如下:
{
    "info": {
        "year": 2024,
        "version": "1.0",
        "description": "目标检测训练数据集",
        "contributor": "Your Name",
        "url": "",
        "date_created": "2024-06-15"
    },
    "licenses": [{
        "id": 1,
        "name": "Academic Use Only",
        "url": ""
    }],
    "images": [
        {
            "id": 1,
            "license": 1,
            "file_name": "000001.jpg",
            "height": 600,
            "width": 800,
            "date_captured": "2024-06-15 10:30:00"
        },
        {
            "id": 2,
            "license": 1,
            "file_name": "000002.jpg",
            "height": 480,
            "width": 640,
            "date_captured": "2024-06-15 10:31:00"
        }
    ],
    "annotations": [
        {
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "bbox": [120, 150, 80, 120],
            "area": 9600,
            "segmentation": [],
            "iscrowd": 0
        },
        {
            "id": 2,
            "image_id": 1,
            "category_id": 2,
            "bbox": [350, 200, 100, 60],
            "area": 6000,
            "segmentation": [],
            "iscrowd": 0
        },
        {
            "id": 3,
            "image_id": 2,
            "category_id": 1,
            "bbox": [50, 80, 60, 100],
            "area": 6000,
            "segmentation": [],
            "iscrowd": 0
        }
    ],
    "categories": [
        {
            "id": 1,
            "name": "person",
            "supercategory": "human"
        },
        {
            "id": 2,
            "name": "car",
            "supercategory": "vehicle"
        }
    ]
}

更新日志

版本更新内容更新日期
0.1.0实现YOLO、COCO、VOC三种格式的目标检测标注文件相互转换2026年1月6日
0.2.0新增获取全部类名的功能2026年1月7日

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image_annotations-0.2.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

image_annotations-0.2.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file image_annotations-0.2.0.tar.gz.

File metadata

  • Download URL: image_annotations-0.2.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for image_annotations-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b702fa1739d23c9eef31eeaab46fba653faff2c32f3bff7bc4494b06045b0d24
MD5 0cdde8f899c846143ff39a4842658dc2
BLAKE2b-256 fdebff43b7e5cb78aaf041d0229749c03addab16f893ac1f855c7d36b1294cf4

See more details on using hashes here.

File details

Details for the file image_annotations-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for image_annotations-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f9a0124f30ffd44aa78c89ecdced44bda064f814e178f73d0fd86923518c9a
MD5 8e31946ae29d2ec6b9529e828e760707
BLAKE2b-256 7b46d05432860a81a41b041565aa69662e6c2c0ae60a28b0fb8cf0254bde8d9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page