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

decode_from_annotation not working with exported json #368

Open
Samcro5C opened this issue Dec 4, 2024 · 0 comments
Open

decode_from_annotation not working with exported json #368

Samcro5C opened this issue Dec 4, 2024 · 0 comments

Comments

@Samcro5C
Copy link

Samcro5C commented Dec 4, 2024

Hi, I am trying to format the rl-encoded masks I created an exported from label-studio (as json) to numpy arrays. I could also export them directly as numpy files but then I would need to map my data to the annotations manually, requiring again the json. So I tried to use the decode_from_annotation function from label-studio-sdk/src/label_studio_sdk/converter/brush.py on the list of result dicts of the loaded json. However, my json has a different format than expected from the decode_from_annotation function. More precisely, the function expects the dictionary to contain a key 'rle' but in my case the 'rle' key is one layer below within the dict of the 'value' key.
Here an example code:

import json
from label_studio_converter.brush import decode_from_annotation

json_file = '/path/to/label-studio.json'
with open(json_file, 'r') as file:
    labels_json = json.load(file)
print(labels_json[0]['annotations'][0]['result'][0].keys())
print(labels_json[0]['annotations'][0]['result'][0]['value'].keys())
decode_from_annotation('some_name', labels_json[0]['annotations'][0]['result'])

This is what I get:

dict_keys(['original_width', 'original_height', 'image_rotation', 'value', 'id', 'from_name', 'to_name', 'type', 'origin'])
dict_keys(['format', 'rle', 'brushlabels'])
{}

I am not sure if my json format is wrong (but that is how I got it from label-studio) or if the format has changed and not been updated in this particular function. Right now I just copied the function and changed the keys and then it works.

Versions:
label-studio: v1.13.1
label-studio-sdk: v1.0.8

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