guchengxi1994 / mask2json Goto Github PK
View Code? Open in Web Editor NEWa small tool for image augmentation, including mask files to json/xml files , image augmentation(flip,rotation,noise,...) and so on
License: Apache License 2.0
a small tool for image augmentation, including mask files to json/xml files , image augmentation(flip,rotation,noise,...) and so on
License: Apache License 2.0
when runing json2mask.py using my sample data.zip
(d2) home@home-desktop:~/0/vision_data_tools-master/data$ python json2mask.py
[WARNING] shape:labelme_shapes_to_label:80 - labelme_shapes_to_label is deprecated, so please use shapes_to_label.
Traceback (most recent call last):
File "json2mask.py", line 95, in <module>
singleFile('./5.json')
File "json2mask.py", line 67, in singleFile
lbl_viz = utils.draw_label(lbl, img, captions)
AttributeError: module 'labelme.utils' has no attribute 'draw_label'
All requirements were successfully installed but when yolo2xml converter is imported it throws the following error related to skimage package.
from convertmask.utils.yolo2xml.yolo2xml import y2xConvert
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 from convertmask.utils.yolo2xml.yolo2xml import y2xConvert
File E:\PXR\DATASETS\NAEMURALAB2015\BIRD_v200_1_1\convertmask\utils\yolo2xml\yolo2xml.py:17, in <module>
15 from convertmask.utils.methods.logger import logger
16 from convertmask.utils.xml2yolo.xml2yolo import readLabels
---> 17 from skimage import io
18 from tqdm import tqdm
21 def y2xConvert(txtPath, imgPath, labelPath):
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\__init__.py:15, in <module>
11 from ._io import *
12 from ._image_stack import *
---> 15 reset_plugins()
17 WRAP_LEN = 73
20 def _separator(char, lengths):
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\manage_plugins.py:87, in reset_plugins()
85 def reset_plugins():
86 _clear_plugins()
---> 87 _load_preferred_plugins()
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\manage_plugins.py:67, in _load_preferred_plugins()
64 io_types = ['imsave', 'imshow', 'imread_collection', 'imshow_collection',
65 'imread']
66 for p_type in io_types:
---> 67 _set_plugin(p_type, preferred_plugins['all'])
69 plugin_types = (p for p in preferred_plugins.keys() if p != 'all')
70 for p_type in plugin_types:
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\manage_plugins.py:79, in _set_plugin(plugin_type, plugin_list)
77 continue
78 try:
---> 79 use_plugin(plugin, kind=plugin_type)
80 break
81 except (ImportError, RuntimeError, OSError):
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\manage_plugins.py:250, in use_plugin(name, kind)
247 else:
248 kind = [kind]
--> 250 _load(name)
252 for k in kind:
253 if k not in plugin_store:
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\manage_plugins.py:293, in _load(plugin)
291 else:
292 modname = plugin_module_name[plugin]
--> 293 plugin_module = __import__('skimage.io._plugins.' + modname,
294 fromlist=[modname])
296 provides = plugin_provides[plugin]
297 for p in provides:
File ~\.conda\envs\pxr\lib\site-packages\skimage\io\_plugins\matplotlib_plugin.py:3, in <module>
1 from collections import namedtuple
2 import numpy as np
----> 3 from mpl_toolkits.axes_grid1 import make_axes_locatable
4 import matplotlib.image
5 from ...util import dtype as dtypes
File ~\.conda\envs\pxr\lib\site-packages\mpl_toolkits\axes_grid1\__init__.py:3, in <module>
1 from . import axes_size as Size
2 from .axes_divider import Divider, SubplotDivider, make_axes_locatable
----> 3 from .axes_grid import Grid, ImageGrid, AxesGrid
5 from .parasite_axes import host_subplot, host_axes
File ~\.conda\envs\pxr\lib\site-packages\mpl_toolkits\axes_grid1\axes_grid.py:32, in <module>
28 ax.axis["bottom"].toggle(ticklabels=bottom_off, label=bottom_off)
29 ax.axis["left"].toggle(ticklabels=left_off, label=left_off)
---> 32 class CbarAxesBase:
34 @cbook._rename_parameter("3.2", "locator", "ticks")
35 def colorbar(self, mappable, *, ticks=None, **kwargs):
37 if self.orientation in ["top", "bottom"]:
File ~\.conda\envs\pxr\lib\site-packages\mpl_toolkits\axes_grid1\axes_grid.py:34, in CbarAxesBase()
32 class CbarAxesBase:
---> 34 @cbook._rename_parameter("3.2", "locator", "ticks")
35 def colorbar(self, mappable, *, ticks=None, **kwargs):
37 if self.orientation in ["top", "bottom"]:
38 orientation = "horizontal"
AttributeError: module 'matplotlib.cbook' has no attribute '_rename_parameter'
sometimes i convert a img to a binary image , the boundray of each area is not binary(see https://github.com/guchengxi1994/mask2json/blob/test/static/issue.png),which will result in some errors when convert masks to xmls .
code can be found here:
https://github.com/guchengxi1994/mask2json/blob/test/convertmask/utils/xml2mask/x2m.py line 117
io.imsave(parent_path+os.sep+'mask_'+os.sep+fileName+'.jpg',np.array(mask_img/np.max(mask_img)*255,dtype=np.uint8))
Thank you for your source code
very nice
It's very helpful
But I have a problem
Labels class0
And the original labels name
atypism
class0
class0(null)
test_imgAug.py
Labels class0
python mask2json.py
Traceback (most recent call last):
File "mask2json.py", line 15, in
getMultiShapes.getMultiShapes(imgPath, maskPath, savePath) # without yaml
File "C:\Users\Siwal\AppData\Local\Programs\Python\Python37\lib\site-packages\convertmask\utils\getMultiShapes.py", line 229, in getMultiShapes
raise FileNotFoundError('mask/labeled image not found')
FileNotFoundError: mask/labeled image not found
我的数据有多个标签,通过mask2json并不能把所有标签都转化为json
I always get an error when I use pip install -r requests.txt, what is the version of Python you are using?
test_imgAug.py
How to cycle catalog pictures
Now it can only be read one by one
How to batch read folder directory pictures
I found the name fixed
mask2json\convertmask\utils\auglib\imgAug.py
Simple modification
fileName = str(''.join(random.sample(string.ascii_letters + string.digits, 8)))
It should be more reasonable
@guchengxi1994
when running json2mask i get no output mask.
note the i modified: D:\\testALg\\mask2json\\mask2json\\static\\
to ./static
there is no mask created
@guchengxi1994 hi,
i have a task dealing with masks,
are you available for freelancing?
what is your email so i can discuss in more detail
Does it support multiple objects?
python test_imgAug.py
ERROR argument should be a bytes-like object or ASCII string, not 'NoneType' (convert.py:102)
imgEncode is deprecated under 0.5.3.
WARNING rotation may cause salt-and-pepper noise. in order to solve this issue, small objects may be missing! (imgAug.py:464)
ERROR argument should be a bytes-like object or ASCII string, not 'NoneType' (convert.py:102)
Traceback (most recent call last):
File "test_imgAug.py", line 37, in <module>
imgRotation(imgPath, labelPath)
File "..\convertmask\utils\auglib\imgAug.py", line 495, in imgRotation
affedMask = cv2.warpAffine(mask, mat, (imgShape[1], imgShape[0]))
cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\imgwarp.cpp:2595: error: (-215:Assertion failed) src.cols > 0 && src.rows > 0 in function 'cv::warpAffine'
labelme\examples\instance_segmentation\data_annotated\2011_000003.jpg
labelme\examples\instance_segmentation\data_annotated\2011_000003.json
This repo was written with python 3.6 and numpy 1.18, currently, python has a new version of 3.10(3.11 is coming soon) ,numpy,scipy,skimage and other dependencies also have changed a lot. I was doing a refactor in a new repo https://github.com/guchengxi1994/simple-tools-for-machine-learning when my flutter works are done.
Hi, thanks for the code.
I have a mask (binary file) and original image.
How can I change it to JSON file ? I tried run the script in ur guide. But it's failed to get the information of area value 1 in mask file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.