pytorch / pytorch/vision

torchvision.io: don't warn about missing image libraries unless necessary

Open
#8,192 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🐛 Describe the bug

If no image libraries are installed, the following will warn:

>>> import torchvision
UserWarning: Failed to load image Python extension: 

I propose we only warn when importing torchvision.io or when using a specific function that requires one of these image libraries.

Related to #7151

Versions
Collecting environment information...
Traceback (most recent call last):
  File "/Users/Adam/Downloads/collect_env.py", line 624, in <module>
    main()
  File "/Users/Adam/Downloads/collect_env.py", line 607, in main
    output = get_pretty_env_info()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/Downloads/collect_env.py", line 602, in get_pretty_env_info
    return pretty_str(get_env_info())
                      ^^^^^^^^^^^^^^
  File "/Users/Adam/Downloads/collect_env.py", line 438, in get_env_info
    pip_version, pip_list_output = get_pip_packages(run_lambda)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/Downloads/collect_env.py", line 410, in get_pip_packages
    out = run_with_pip([sys.executable, '-mpip'])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/Adam/Downloads/collect_env.py", line 405, in run_with_pip
    for line in out.splitlines()
                ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'splitlines'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the warning by importing torchvision with no image libraries installed, then inspect the import paths for torchvision and torchvision.io. Verify which image-dependent functions require those libraries. Done means importing torchvision is quiet while importing torchvision.io or calling a dependent function still warns when appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.