api handle for data transform
Project description
Auchor
- 西安燧仓科技有限公司 三重像素
- @PIPIPINoBrain
- 联系方式:PIPIPINoBrain@163.com
Mtripix.Mutils.Mtrans(usage)
安装方式
pip install Mtripix
使用示例
import Mtripix.Mutils.Mtrans as Mt
idxs = [1,2,3]
labels = ["dog", "cat", "person"]
d = Mt.labels2dict(labels, idxs)
path_xml = "C:\Users\18829\Desktop\MTP\A.xml"
path_txt = "C:\Users\18829\Desktop\MTP\A1.txt"
Mt.xml2yoloobb(path_xml, path_txt, d)
updata
- 0.0.7
- 增加了语义分割的标签图像转换
- 增加了文件夹中标签的统计
- 0.0.8
- 增加了文件夹图片计算均值和方差的代码
- 修复了yolo2voc中空目标转换的bug,修复了未引用math的bug
Environment
- import json
- import os.path
- import PIL
- import imgviz
- import numpy as np
- import cv2
- import lxml.etree as ET
- import math
- from lxml.etree import Element, SubElement, tostring, ElementTree
Mtripix Function
Mtripix.Mutils(lists)
Mtripix.Mutils.Mtrans(lists)
- Mtripix.Mutils.Mtrans.labels2dict(labels, idxs) 功能: 生成namedict,标签与类别对应的字典
- Mtripix.Mutils.Mtrans.voc2yolo(path_xml, path_txt, namedict) 功能: labelme标注的xml格式转yolo格式(label, xc, yc, w, h)————相对值
- Mtripix.Mutils.Mtrans.json2yolo(path_json, path_txt, namedict, mode) 功能: labelimg标注的json格式转yolo检测格式(label, xc, yc, w, h)和分割格式(label, xy, xy, xy, xy)————相对值
- Mtripix.Mutils.Mtrans.voc2dotaobb(path_xml, path_txt)功能: rolabelme和labelme标注的xml格式转DOTA数据格式,(xy,xy,xy,xy,label,difficulty)————绝对值
- Mtripix.Mutils.Mtrans.voc2yoloobb(path_xml, path_txt, namedict)功能: rolabelme和labelme标注的xml格式转yoloobb数据格式,(label, xy, xy, xy, xy)————相对值
- Mtripix.Mutils.Mtrans.yolo2voc(path_img, path_txt, path_xml, namedict) 功能: 转yolo格式(label, xc, yc, w, h)转labelme标注的xml格式————绝对值**
- Mtripix.Mutils.Mtrans.labelsCheck(path, format) 功能: 计算当前标签文件夹中,各个标签的个数**
- Mtripix.Mutils.Mtrans.json2mask_sem(path_json, path_mask, namedict) 功能: labelme标注的json文件转化为分割图像标签,返回标签灰度图像**
- Mtripix.Mutils.Mtrans.compute_mean_and_std(path, format) 功能: 计算文件夹下的所有图像的均值方差**
Mtripix.Mutils.Mtrans(intrudction)
Mtripix.Mutils.Mtrans.labels2dict(labels, idxs)
@input:
- labels(list/tuple): 标签名 里边都是str
- idxs(list/tuple): 类别名 里边都是str
@return:
- namedict(dict) 标签与类别对应的字典
Mtripix.Mutils.Mtrans.voc2yolo(path_xml, path_txt, namedict)
@input:
- path_xml(str): xml文件地址
- path_txt(str): 生成的yolo的txt地址
- namedict(dict): 标签和类别对应的字典
@return:
- 0
Mtripix.Mutils.Mtrans.json2yolo(path_json, path_txt, namedict, mode)
@input:
- path_json(str): json文件地址
- path_txt(str): 生成的yolo的txt地址
- namedict(dict): 标签和类别对应的字典
- mode(str): 一共可填两种模式“detection”和“segmentation”, 分别对应yolo检测和分割的文件,默认是“detection”
@return:
- 0
Mtripix.Mutils.Mtrans.voc2dotaobb(path_xml, path_txt)
@input:
- pathxml(str): xml文件地址
- path_txt(str): 生成的DOTA的txt地址
@return:
- 0
Mtripix.Mutils.Mtrans.voc2yoloobb(path_xml, path_txt, namedict)
@input:
- path_xml(str): xml文件地址
- path_txt(str): 生成的yoloobb的txt地址
- namedict(dict): 标签和类别对应的字典
@return:
- 0
Mtripix.Mutils.Mtrans.yolo2voc(path_img, path_txt, path_xml, namedict)
@input:
- path_img(str): 图像地址
- path_txt(str): 图像的yolo格式txt地址
- path_xml(str): 生成的xml地址
- namedict(dict): 类别和标签对应的字典
@return:
- 0
Mtripix.Mutils.Mtrans.labelsCheck(path, format)
@input:
- path(str): 当前的标签的文件夹地址
- format: 需要统计的数据格式,有"voc","yolo"和”data“三种格式
@return:
- count()输出字典, keys是当前的类别, value是当前文件夹中各类别出现的次数
Mtripix.Mutils.Mtrans.json2mask_sem(path_json, path_mask, namedict)
@input:
- path_json(str): labelme标注的语义分割json文件
- path_txt(str): 需要保存的8位标签伪图像,png格式
- namedict(dict): 类别和标签对应的字典
@return:
- img(array): 原图灰度图大小的分类特征图,类别为像素值,背景为0
Mtripix.Mutils.Mtrans.compute_mean_and_std(path, format=1)
@input:
- path(str): 图像存放的文件夹路径
- format(int): 图片的类型 1 代表RGB, 2代表灰度图
@return:
- 返回两个参数,文件夹下图片的均值,方差(量化后)
- mean: 文件夹下图片的均值(量化后)
- std: 文件夹下图片的方差(量化后)
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
Mtripix-0.1.0.tar.gz
(7.7 kB
view details)
Built Distribution
File details
Details for the file Mtripix-0.1.0.tar.gz
.
File metadata
- Download URL: Mtripix-0.1.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 241df001f80714f7fff6291baf15831a4bb3dea383cc69fd87e5bb33a0162f06 |
|
MD5 | 8674caadac6c81390732f00ddf367fbc |
|
BLAKE2b-256 | 7f008c8520dad28a2ace78ca6ea52fe152c64d03d03e6790f4c38452fbabde62 |
Provenance
File details
Details for the file Mtripix-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: Mtripix-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ae660a459eeadd2cb9103405af25b457588daf6902e6b682c55205ebb6ffd56 |
|
MD5 | b1eb03283fefa45c819aad9aad38401f |
|
BLAKE2b-256 | 7db334662b3d70d5d133ad1fbc5cd616899de878f3b10a05def373c4e30a1ea5 |