HumanSignal / HumanSignal/label-studio-sdk
decode_from_annotation not working with exported json
- Dominant language
- Python
- Stars
- 192
- Forks
- 127
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
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](https://github.com/HumanSignal/label-studio-sdk/blob/master/src/label_studio_sdk/converter/brush.py#L102) 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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.