HumanSignal / label-studio-converter

Tools for converting Label Studio annotations into common dataset formats
https://labelstud.io/
255 stars 132 forks source link

The iter_from_dir that uses`json.load` in method convert_to_voc does not open the json file. #241

Open keithleungwork opened 1 year ago

keithleungwork commented 1 year ago

As the title stated, the method iter_from_json_file (link) is using the json_file string directly. It caused error because json.load is expecting a file object.

# one task
if data_type == 'dict':
    data = json.load(json_file)
    for item in self.annotation_result_from_task(data):
        yield item

If you scroll down a bit, you will see another block using the json_file correctly

# many tasks
elif data_type == 'list':
    with io.open(json_file, 'rb') as f:
        logger.debug(f'ijson backend in use: {ijson.backend}')
        data = ijson.items(
            f, 'item', use_float=True
        )  # 'item' means to read array of dicts

Should I open create a PR and fix this ? because I am using this library for conversion task. Otherwise I have to manually clone all the code to create my own version...