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

PyTorch Hub results.render() #1897

Merged
merged 1 commit into from
Jan 11, 2021
Merged

PyTorch Hub results.render() #1897

merged 1 commit into from
Jan 11, 2021

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Jan 11, 2021

This PR implements a new .render() method for PyTorch Hub results objects. results.render() will return a list of original images annotated with predicted bounding boxes. This fourth method adds to the existing 3: .show(), .save(), .print(), and can be used with cv2.imshow() for example.

Note that cv2 usage of the images will require a RGB to BGR conversion, i.e.:

results = model(imgs)
im_list = results.render()
im_list = [x[..., ::-1] for x in im_list]  # RGB to BGR
cv2.imshow(im_list[0])

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Enhanced image rendering, improved information display, and boosted thread management in YOLOv5.

📊 Key Changes

  • In models/common.py, a render parameter was added to display method, enabling image array updates after drawing.
  • A new render method was introduced to return modified images.
  • Color-coded hyperparameter logging was introduced in train.py using the colorstr function.
  • Logging string formatting was improved for clarity and conciseness in train.py.
  • os.environ['NUMEXPR_MAX_THREADS'] was set in utils/general.py to optimize thread usage.
  • Minor typo correction in colorstr function from 'undelrine' to 'underline'.

🎯 Purpose & Impact

  • 🖼️ Image Rendering: Users can now programmatically modify and utilize images post-processing (e.g., for further analysis or custom overlays).
  • 🎨 Visual Logging Enhancement: Improved log readability, which makes debugging and monitoring the training process easier.
  • 🚀 Thread Optimization: More efficient CPU usage, potentially improving computational performances on multi-core systems, and avoiding over-subscription of threads.
  • ✏️ Logging and Typos: Cleaner and more informative logging, and corrected function spelling offer better user and developer experience.

@glenn-jocher glenn-jocher merged commit 1d1c056 into master Jan 11, 2021
@glenn-jocher glenn-jocher deleted the render branch January 11, 2021 04:06
@Lifeng1129
Copy link

Very Good!

KMint1819 pushed a commit to KMint1819/yolov5 that referenced this pull request May 12, 2021
taicaile pushed a commit to taicaile/yolov5 that referenced this pull request Oct 12, 2021
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
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.

2 participants