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

Draft: Switch to image_file_name as the standard key for cache and other dictionaries. #77

Conversation

Abdul-Mukit
Copy link
Contributor

@Abdul-Mukit Abdul-Mukit commented Aug 15, 2024

Summary:

This MR attempts to establish "image file names" (e.g. 000123_xyz_.jpg) as the consistent key when creating image_info or annotation_info dictionaries or saving cache like train.cache / val.cache.
In the current behaviour, "image paths" are used as keys for data cache. image_id read from coco json files are used as keys in some dictionaries. In some other functions, image_id is being derived from image file names based on the incorrect assumption that image file names will always be int convertible. In some cases, image files names without extension is used as keys.
Due to not following a standard/uniform convention throughout this code base, several problems are arising: #67 and #72.

This is creating friction and has to be improved. I think it would be best to settle on a uniform/standard key for all/most of the workflow. This MR attempts to make the codebase more predictable and thus easier to debug.

Please note that, using image file name as the standard key will allow for:

  • Allow for moving the COCO/YOLO data around after cache creation. As we already have dataset path, phase_name. The folder "images" is already consistent between COCO and yolo format.
  • Doesn't force us to derive image_id from paths. "image_id": int(Path(img_path).stem) in predicts_to_json(). The assumption that image file name is int convertible and will be equal to image_id defined in the json file is inaccurate. Often industrial applications have image file names like <time>_<date>_<location>.jpg to be able to track performance/incidents.

To address these issues, this MR will try to switch all necessary keys to just the image file names, including the extentions.
This is a WIP. I am publishing it to gain feedback from others. Once I successfully train a model after these changes I'll remove the Draft.

Any thoughts are welcome.

…_dict and image_info_dict with image file name as key to ensure uniform key accross the code base.

refactor: dataset_utils.map_annotations_to_image_names returns annotations list mapped to image file names instead of image_id.

refactor: several variable names made more descriptive.

docs: docstrings updated.
…stead of image_path as the key.

refactor: annotations_index renamed to annotations_dict.
@Abdul-Mukit
Copy link
Contributor Author

@henrytsui000 I would like your initial opinion about this matter before I invest more time in this MR. I appreciate your time. Thank you.

Please let me know what you like, or don't like. Does switching to image_file_name as a common key acceptable?

@Abdul-Mukit Abdul-Mukit marked this pull request as draft August 15, 2024 19:17
@Abdul-Mukit
Copy link
Contributor Author

Working on it more.

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

Successfully merging this pull request may close these issues.

1 participant