guchengxi1994 / mask2json

a small tool for image augmentation, including mask files to json/xml files , image augmentation(flip,rotation,noise,...) and so on
Apache License 2.0
57 stars 11 forks source link

test_imgAug Labels class0 #46

Closed monkeycc closed 2 years ago

monkeycc commented 2 years ago

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

guchengxi1994 commented 2 years ago

I think it is because you did not provide a yaml file when image augementation. you can try this code when convering labels/masks to jsons:

from convertmask.utils.methods import get_multi_shapes
imgPath = 'D:\\github_repo\\mask2json\\static\\multi_objs_test.jpg'
maskPath = 'D:\\github_repo\\mask2json\\static\\multi_objs_json\\label.png'
savePath = 'D:\\github_repo\\mask2json\\static\\multi_objs_json\\1025\\'
yamlPath = 'D:\\github_repo\\mask2json\\static\\multi_objs_json\\info.yaml'
get_multi_shapes.getMultiShapes(imgPath, maskPath, savePath, yamlPath)  # with yaml
monkeycc commented 2 years ago

Thank you for your reply

structure xxx.jpg xxx.json

maskPath Whether to convert to coco data png SegmentationClassPNG ?

yamlPath I don't know how to get yaml What tool should I use for conversion

guchengxi1994 commented 2 years ago

you can write your own yaml like this

label_names:
  _background_: 0
  dog: 1
  cat: 2

if you have mask files( mask files contain lables, such as number 1 represents dogs,2 represents cats ...), you should write yamls following your mask files

if you dont have mask files, you can write yamls first, and generate mask files like this.

import sys,os

sys.path.append('..')
BASE_DIR = os.path.abspath(os.path.dirname(os.getcwd())) + os.sep + 'static'

imgPath = BASE_DIR + os.sep + 'test702.jpg'
labelPath = BASE_DIR + os.sep + 'test702.json'
yamlPath = BASE_DIR + os.sep + 'test702.yaml'

from  convertmask.utils.json2mask.convert_with_label import *

processor(labelPath,yamlPath)

in this way, mask files are generated following your yaml

there is a problem mentioned in https://github.com/guchengxi1994/mask2json/issues/47#issuecomment-1172885052

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 14 days with no activity.

github-actions[bot] commented 2 years ago

This issue was closed because it has been inactive for 7 days since being marked as stale.