Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 1.33 KB

json2mask.md

File metadata and controls

32 lines (23 loc) · 1.33 KB

This function is used to convert jsons(labelme) to masks.

How to use.

from convertmask.utils.json2mask.convertWithLabel import processor

BASE_DIR = os.path.abspath(os.path.dirname(os.getcwd())) + os.sep + 'static'
imgPath = BASE_DIR + os.sep + 'multi_objs.jpg'
labelPath = BASE_DIR + os.sep + 'multi_objs.json'
yamlFilePath = BASE_DIR + os.sep + 'multi_objs.yaml'

if __name__ == "__main__":
    processor(labelPath,yamlFilePath)

If you want to test the function on your own, should change the file path.

The parameter list is like:(json_file, yaml_file, encoding='utf-8', flag=False)

Parameter 'json_file' is a labelme generated file, yaml_file is the class file like this, and is necessary in this function. Without this file, there will be some errors when converting multiple objects to masks (especially for multi files).

Parameter 'flag' is determining whether you want to save files like this

Converting jsons to masks without yaml files is not recommended. If you do want to have a try, try this function.