将CVAT XML文件中的注释提取到Python中的遮罩文件中

The Computer Vision Annotation Tool (CVAT) is a well-known image annotation tool. The results of the data labelers work can be imported in XML file. This XML file contains all the necessary information about the markup. However, for image segmentation task it is necessary to have masks in the form of image files (JPEG, GIF, PNG, etc.). In other words, having the markup coordinates in the CVAT XML file, you need to draw the corresponding masks.

计算机视觉注释工具(CVAT)是众所周知的图像注释工具。 数据标记器工作的结果可以导入XML文件中。 该XML文件包含有关标记的所有必要信息。 但是,对于图像分割任务,必须具有图像文件形式的蒙版(JPEG,GIF,PNG等)。 换句话说,在CVAT XML文件中具有标记坐标,您需要绘制相应的蒙版。

If the data labelers worked with images in a higher resolution than it is supposed to be used for training, then the task will become more complicated. It is necessary to take into account the influence of the image compression factor on the numerical values of the cue points presented in the XML file.

如果数据标签处理器使用的图像分辨率比用于训练的分辨率高,那么任务将变得更加复杂。 有必要考虑图像压缩因子对XML文件中提示点的数值的影响。

All code for extracting annotations is implemented as a script in Python. The lxml library is used for parsing XML. It is a fast and flexible solution for handling XML and HTML markup The lxml package has XPath and XSLT support, including an API for SAX and an API for compatibility with C modules.

用于提取注释的所有代码均在Python中作为脚本实现。 lxml库用于解析XML。 这是用于处理XML和HTML标记的快速,灵活的解决方案。lxml软件包具有XPath和XSLT支持,包括用于SAX的API和与C模块兼容的API。

The tqdm package is used as a progress bar to illustrate the processing of a large number of files.

tqdm程序包用作进度条,以说明处理大量文件的过程。

Let’s take a closer look. Import libraries:

让我们仔细看看。 导入库:

import os
import cv2
import argparse
import shutil
import numpy as np
from lxml import etree
from tqdm import tqdm

A useful function for creating a new directory and recursively deleting the contents of an existing one:

创建新目录并递归删除现有目录内容的有用功能:

def dir_create(path):
if (os.path.exists(path)) and (os.listdir(path) !&#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值