Open kimyoungju49 opened 2 years ago
@kimyoungju49 Could you show the full traceback of this error? Ideally, if you can share export json file (to re-import it) and the labeling config, then I can reproduce and fix this quickly.
config
<View>
<header value="$header"></header>
<Image name="image" value="$image" zoom="true"></Image>
<RectangleLabels name="box" toName="image" canRotate="false">
<Label value="OK" background="#4caf50"></Label>
<Label value="NG" background="#f44336"></Label>
</RectangleLabels>
</View>
input_data (json file) for "convert_to_coco"
[{"annotations": [{"created_at": "2021-10-27T09:57:02.131Z", "lead_time": 3.357, "result": [{"original_width": 1920, "original_height": 1080, "image_rotation": 0, "value": {"x": 13.733333333333333, "y": 45.023696682464454, "width": 18.4, "height": 27.488151658767773, "rotation": 0, "rectanglelabels": ["NG"]}, "id": "iy4eodqkvl", "from_name": "box", "to_name": "image", "type": "rectanglelabels"}]}], "data": {"image": "00001_00721.jpg", "imageSize": {"width": 1920, "height": 1080}}, "id": 0}, {"annotations": [{"created_at": "2021-10-27T09:57:10.467Z", "lead_time": 3.493, "result": [{"original_width": 425, "original_height": 566, "image_rotation": 0, "value": {"x": 16, "y": 62.36749116607774, "width": 24.470588235294116, "height": 21.554770318021202, "rotation": 0, "rectanglelabels": ["OK"]}, "id": "72PRc5_DUQ", "from_name": "box", "to_name": "image", "type": "rectanglelabels"}]}], "data": {"image": "abc.bmp", "imageSize": {"width": 425, "height": 566}}, "id": 0}]
Hi @kimyoungju49 Could you please check if fix from branch fix/gh56-parse-config solves your issue?
I tested and there are new error message like below. "Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration."
1-1. console output
Traceback (most recent call last):
File "C:\Users\yj49.kim\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "C:\Users\yj49.kim\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\yj49.kim.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\lib\python\debugpy__main.py", line 45, in
1-2. code that use to load label_config import os import json import xmltodict from label_studio_converter import Converter
def convert_from_labelstudio_to_coco(ls_config_xml, input_dir, output_dir, is_dir=True): c = Converter(ls_config_xml, None) c.convert_to_coco(input_dir, output_dir, output_image_dir=output_dir, is_dir=is_dir)
def main(): data_dir = os.path.join(os.getcwd(), 'data') config_path = os.path.join(data_dir, 'ls_config.json') input_path = os.path.join(data_dir, 'labels.json')
with open(config_path) as config_json_file: config_json = json.load(config_json_file)
config_xml = xmltodict.unparse(config_json, pretty=True)
convert_from_labelstudio_to_coco(config_xml, input_path, data_dir, False)
if name == 'main': main()
2. I load label_config as a json file and convert it to xml string. (You can check the code above) 3. config file(ls_config.json) { "View": { "header": { "@value": "$header" }, "Image": { "@name": "image", "@value": "$image", "@zoom": "true" }, "RectangleLabels": { "@name": "box", "@toName": "image", "@canRotate": "false", "Label": [ { "@value": "OK", "@background": "#4caf50" }, { "@value": "NG", "@background": "#f44336" } ] } } }
4. input_file (sample of 'labels.json') [{"annotations": [{"created_at": "2021-11-19T05:16:50.527Z", "lead_time": 5.075, "result": [{"original_width": 128, "original_height": 128, "image_rotation": 0, "value": {"x": 10.9375, "y": 21.09375, "width": 36.71875, "height": 44.53125, "rotation": 0, "rectanglelabels": ["OK"]}, "id": "SIyzo61O1e", "from_name": "box", "to_name": "image", "type": "rectanglelabels"}]}], "data": {"image": "00001_00346.bmp", "imageSize": {"width": 128, "height": 128}}, "id": 0}]
Version 0.0.31rc1 worked well , but the following error comes when I use "convert_to_coco" in the after versions. <no 'labels'>
In commit 1ea3768e046198754cd412ef74af3ba6792a01e8 , "labels |= set(info['labels'])" was added in "_get_labels( )". I guess that's the point.
Should I use tag in labelstudio config to use convert_to_coco???