一个自由转换图像标注格式的工具
Project description
图像标注格式转换器(image-annotations)
使用方法
标注文件说明
| 标注格式 | 文件类型 | 一张图片对应 | 一个检测框对应 |
|---|---|---|---|
| YOLO | txt | 一个txt文件 | txt文件中的一行 |
| VOC | xml | 一个xml文件 | xml文件中的一个object标签 |
| COCO | json | json文件中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日 |
| 0.2.1 | Updated YOLO to VOC and COCO conversion functions to iterate over image files instead of annotation files, improving robustness for various image formats. | 2026年1月11日 |
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.1.tar.gz
(22.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image_annotations-0.2.1.tar.gz.
File metadata
- Download URL: image_annotations-0.2.1.tar.gz
- Upload date:
- Size: 22.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89bc0695abd63f3796e065491c25b6e3d6af9a8ada9835cf41b17a5fd4274c69
|
|
| MD5 |
b29c79183cc71d50fb225ab965221f63
|
|
| BLAKE2b-256 |
0c26bd6514a46d91c64c1c5d41851317a608712c65af64238eec07c5486711a5
|
File details
Details for the file image_annotations-0.2.1-py3-none-any.whl.
File metadata
- Download URL: image_annotations-0.2.1-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
821d69fdedc2ff7e10906a67d38d4829de296f6ef99f3d117d4b246822051c0d
|
|
| MD5 |
bcf582a1adaf2eff00c29337d2bc6a84
|
|
| BLAKE2b-256 |
399faa9eb85436ea65c45ddbba347fed80feda9cc9378ba6e2bf74aa141e9610
|