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

Allow PyTorch Hub results to display in notebooks #9825

Merged
merged 20 commits into from
Oct 17, 2022
Merged

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Oct 17, 2022

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhancements for image display checks and error handling in various environments.

πŸ“Š Key Changes

  • Added warn=True argument to check_imshow calls when initializing webcam in classify/predict.py, detect.py, and segment/predict.py.
  • Introduced CHECK_IMSHOW global variable in models/common.py and conditional display methods based on environment compatibility.
  • Implemented @TryExcept decorator for image showing regardless of the environment in models/common.py.
  • Enhanced error message formatting in utils/__init__.py and utils/autoanchor.py.
  • Added is_notebook utility function in utils/general.py to detect Jupyter notebook environments.
  • Adjusted check_imshow in utils/general.py to consider more environment types and optionally warn if display is not supported.
  • Minor fixes and improvements to readability and error handling.

🎯 Purpose & Impact

  • These changes improve the compatibility of image display capabilities across different platforms like Jupyter notebooks, Docker, and SSH terminals.
  • Provide clearer, more meaningful error messages and warnings for developers and users regarding display capabilities.
  • Improve user experience by adapting the software behavior to various execution environments without interrupting workflow.
  • Non-expert users benefit from streamlined functionality, while expert developers obtain better error handling and debugging support.

@glenn-jocher glenn-jocher self-assigned this Oct 17, 2022
@glenn-jocher glenn-jocher mentioned this pull request Oct 17, 2022
2 tasks
@glenn-jocher glenn-jocher merged commit e3ff780 into master Oct 17, 2022
@glenn-jocher glenn-jocher deleted the results/display branch October 17, 2022 12:34
@glenn-jocher glenn-jocher linked an issue Oct 17, 2022 that may be closed by this pull request
2 tasks
@@ -18,16 +18,20 @@
import requests
import torch
import torch.nn as nn
from IPython.display import display
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't ipython be an optional dependency ? IMO, it would make sense to remove it for a minimal setup without "displaying" results.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vfdev-5 ipython is only used for checking if environment is notebook, clearing notebook cells and showing images in notebook cells. We have in requirements due to the popularity of your Colab notebook.

Does it conflict with anything or is it installing significant other dependencies in your environment?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the response, @glenn-jocher

Does it conflict with anything or is it installing significant other dependencies in your environment?

well, in terms of space, ipython + deps does not take much space (~1-2MB), I agree. I start to understand better all the context of this work. For demos in colab etc it totally makes sense. In terms of headless server usage (probably less frequent?), it feels weird to install ipython, matplotlib, seaborn (it is just my opinion).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vfdev-5 got it. Much of this is the difference between training support, visualization support, export support etc. We try to strike the right balance but it's impossible to please everyone.

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.

results.show() does not work
2 participants