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

Fix LoadImages() with dataset YAML lists #8517

Merged
merged 6 commits into from
Jul 8, 2022

Conversation

democat3457
Copy link
Contributor

@democat3457 democat3457 commented Jul 7, 2022

When using the tflite export with a yolov5 dataset.yaml that contains a list of train/val paths rather than a single path, the tflite exporter fails with the message, Expected str, bytes or os.PathLike object, not list - this is because the return object from check_dataset(data)['train'] is a list of strings if the train entry in the dataset.yaml is a list as well.

This PR aims to correct this by allowing the input parameter path to be a list as well and simply extending the files list for subsequent paths.

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced flexibility in specifying input sources for image and video processing in YOLOv5.

πŸ“Š Key Changes

  • πŸ”„ The input path handling now supports lists or tuples of paths, rather than just a single path.
  • πŸ” Updated file existence checks to use FileNotFoundError instead of generic Exception.

🎯 Purpose & Impact

  • πŸ‘₯ Allows users to input multiple sources at once, improving usability and efficiency.
  • πŸ› οΈ Provides a more descriptive error with FileNotFoundError to better guide users when input paths are incorrect.

@glenn-jocher glenn-jocher changed the title Fix LoadImages with dataset yaml lists Fix LoadImages() with dataset YAML lists Jul 8, 2022
@glenn-jocher glenn-jocher merged commit 526e650 into ultralytics:master Jul 8, 2022
@glenn-jocher
Copy link
Member

@democat3457 PR is merged. Thank you for your contributions to YOLOv5 πŸš€ and Vision AI ⭐

@glenn-jocher
Copy link
Member

glenn-jocher commented Jul 8, 2022

@democat3457 BTW I think this expanded capability might be used in detect.py to add for example a list of inference objects (images, videos, directories, etc.)

Maybe a new Usage method could be a text file or CSV file with inference targets. Right now we reserve sources.txt for streaming sources, but we could restructure so if a file is passed streams would require a *.streams extension and *.txt and *.csv files would be parsed inside or before LoadImages, i.e.:

python detect.py --source files.txt
python detect.py --source files.csv
python detect.py --source rtsp.streams  # old usage --source streams.txt

@democat3457 democat3457 deleted the patch-1 branch July 8, 2022 16:50
@democat3457
Copy link
Contributor Author

πŸ‘€ interesting idea

one potential thing that would have to be reworked though, is that if the source argument gets a list of files as you suggest, if there are multiple videos in that file, they would (currently) all get written to the same annotated video rather than in all separate videos

@glenn-jocher
Copy link
Member

glenn-jocher commented Jul 8, 2022

@democat3457 oh no don't worry, multiple videos, and even multiple files + multiple videos are already handled automatically when pointing to a directory, i.e. this works perfectly well today:

python detect.py --source path/to/dir_with_many_videos_and_many_images/

@democat3457
Copy link
Contributor Author

democat3457 commented Jul 8, 2022

ah I see, I missed the part where the save_path changes

it feels like switching the extension from .txt to .streams would break a lot of existing setups that use streams, though?

we could also support nargs='+' for the source argument to accept multiple sources from there, but it probably wouldn't support stream files being passed in with other sources, as it would be strange to run detection on both live and offline sources simulatenously.

@glenn-jocher
Copy link
Member

@democat3457 yes, we try to avoid breaking changes when possible, though sometimes it's unavoidable and then we post a warning message on the PR to let users know.

ctjanuhowski pushed a commit to ctjanuhowski/yolov5 that referenced this pull request Sep 8, 2022
* Fix LoadImages with dataset yaml lists

* Update dataloaders.py

* Update dataloaders.py

* Simplify/refactor PR

* Update dataloaders.py

Co-authored-by: Colin Wong <noreply@brains4drones.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
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.

None yet

2 participants