Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'BrushLabels' Conversion to RLE Format Masks #186

Open
moyue358 opened this issue Jun 27, 2024 · 1 comment
Open

KeyError: 'BrushLabels' Conversion to RLE Format Masks #186

moyue358 opened this issue Jun 27, 2024 · 1 comment

Comments

@moyue358
Copy link

在LS中导出json格式标注,使用convert_to_rle_mask_coco.py转换出现错误

(rtmdet-sam) qin@user-Super-Server:~/Projects/playground/label_anything$ python tools/convert_to_rle_mask_coco.py --json_file_path ./transform-json/627test1.json --out_dir ./transform-json/rle-mask
  0%|                                                                                                           | 0/1 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/qin/Projects/playground/label_anything/tools/convert_to_rle_mask_coco.py", line 113, in format_to_coco
    category = label_rel['value']['brushlabels'][0]
KeyError: 'brushlabels'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/qin/Projects/playground/label_anything/tools/convert_to_rle_mask_coco.py", line 201, in <module>
    classes_output,args=format_to_coco(args)
  File "/home/qin/Projects/playground/label_anything/tools/convert_to_rle_mask_coco.py", line 115, in format_to_coco
    category = label_rel['value']['rectanglelabels'][0]
KeyError: 'rectanglelabels'

有人知道要如何解决吗?感谢!

@moyue358
Copy link
Author

我将114-117行修改了一下,可以正常使用了,不过我不明白这其中的原理。

                # try:
                #     category = label_rel['value']['brushlabels'][0]
                # except:
                #     category = label_rel['value']['rectanglelabels'][0]
                if 'brushlabels' in label_rel['value']:
                    category = label_rel['value']['brushlabels'][0]
                else:
                # 处理没有 brushlabels 键的情况,例如跳过或设置默认值
                    continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant