Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

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

Open
keithleungwork opened this issue Sep 5, 2023 · 0 comments

Comments

@keithleungwork
Copy link

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...

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

No branches or pull requests

1 participant