a small tool for image augmentation, including mask files to json/xml files , image augmentation(flip,rotation,noise,...) and so on
This script is used to convert mask-labels to json files for labelme.
FIRST:
pip install -r requestments.txt [-i https://pypi.tuna.tsinghua.edu.cn/simple/]
IF ERROR, try:
pip install -r requirements.txt [-i https://pypi.tuna.tsinghua.edu.cn/simple/] --ignore-installed
AND THEN:
Json files to masks can be found on this site. Sometimes there will be an ERROR,should add this file in labelme path (mine is '../anaconda/Lib/site-packages/labelme/utils ') and add some codes in __init__.py:
from .draw import label_colormap
from .draw import _validate_colormap
from .draw import label2rgb
from .draw import draw_label
from .draw import draw_instances
Here shows an example using this script.
origin image
mask image
manually_labeled image
auto_labeled image
Also ,for labelimg,a small tool to convert results(yolo) to xml-files.
the test script can be found here
from convertmask.utils import getMultiShapes
getMultiShapes.getMultiShapes(param1,param2,param3,param4)
param1:path which saves the origin imgs
param2:path which saves the mask imgs (file names should match the origin imgs)
param3:converted json files save path
param4:can be blank (better don't), a yaml file path which saves the class information
the test script can be found here
from convertmask.utils.getMultiShapes import getMultiObjs_voc as gvoc
gvoc(param1,param2,param3)
param1:path which saves the origin imgs
param2:path which saves the mask imgs (file names should match the origin imgs)
param3:converted xml files save path
the test script can be found here
from convertmask.utils.convert import processor
processor(param1,param2)
param1:json file or folder
param2:can be blank,encoding type, default 'utf-8'
the test script can be found here
from convertmask.utils.json2xml import j2xConvert
j2xConvert(path-of-your-jsonfile)
the test script can be found here
from convertmask.utils.imgAug import imgFlip,imgNoise,imgRotation,imgTranslation,aug_labelme
imgFlip(imgPath, labelPath)
imgNoise(imgPath,labelPath)
imgRotation(imgPath,labelPath)
imgTranslation(imgPath,labelPath)
details see Here
you can try:
pip install -U convertmask
and
pip uninstall convertmask
to delete convertmask.
it is a test release. : )
convertmask -h | --help
to read the guide.
convertmask -v | --version
to show the current version
convertmask m2j
to test mask to json function(should type in some file path)
convertmask m2x
to test mask to xml function(should type in some file path)
convertmask j2m
to test json to mask function(should type in some file path)
convertmask j2x
to test json to xml function(should type in some file path)
convertmask aug
to test image augmentation function(should type in some file path)
1.image augumentation support convert yolo txts to xmls(pascal). See here
1.image augumentation support generating several annotation/images with single image/annotation(json,xml). See here
1.inspired by LabelImgTool, convert xmls to jsons is useful. Also ,i forked this repo and add some pyqt5/py3 support,see here.
examples:
script here
support convert xml files to yolo files. see here
examples:
combination of every augmentation method.
2. besides, a simple way convert json file(labelme) to xml file(labelImg) is provided. see here
2. support image augmentation methods: noise,flip,rotation. try test_imgAug.py !
here are some examples:
1. add image augmentation (image flip) test. see test_imgAug.py !
eg:
try test.py !
manually_labeled image
auto_labeled image
manually_labeled image
auto_labeled image
6. re-write main script
7. solve PyYmal installation error(currently write a script by myself. maybe failure in the end.)
if you test the json2mask.py script, you should change the path first and make sure the file is valid(maybe i have deleted :) )
Also, this script is just a reverse of mask2json, for a more COOOOOL method, see here , try convert.processor
1.objects connected to each other is not supported yet.
this may happen if you labelling multiple-object-images with only 2 labels .Or some objects are of the same type and are connected to each other(eg. a bunch of grapes,it is hard to split one to the other).
2.Image Binarization issue