Allow PyTorch Hub results to display in notebooks#9825
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
…splay # Conflicts: # .github/workflows/ci-testing.yml
for more information, see https://pre-commit.ci
| import requests | ||
| import torch | ||
| import torch.nn as nn | ||
| from IPython.display import display |
There was a problem hiding this comment.
Shouldn't ipython be an optional dependency ? IMO, it would make sense to remove it for a minimal setup without "displaying" results.
There was a problem hiding this comment.
@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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
@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.
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhancements for image display checks and error handling in various environments.
📊 Key Changes
warn=Trueargument tocheck_imshowcalls when initializing webcam inclassify/predict.py,detect.py, andsegment/predict.py.CHECK_IMSHOWglobal variable inmodels/common.pyand conditional display methods based on environment compatibility.@TryExceptdecorator for image showing regardless of the environment inmodels/common.py.utils/__init__.pyandutils/autoanchor.py.is_notebookutility function inutils/general.pyto detect Jupyter notebook environments.check_imshowinutils/general.pyto consider more environment types and optionally warn if display is not supported.🎯 Purpose & Impact