"src/git@developer.sourcefind.cn:one/TransferBench.git" did not exist on "633e3b914c4e113bd756dc60e69a671b38adc571"
Unverified Commit 42e7f1f0 authored by James Thewlis's avatar James Thewlis Committed by GitHub
Browse files

Warn if torchvision imported from repo root (#2759)

* Warn if torchvision imported from repo root

This is likely to fail as mentioned in #2239

* Only warn if ops are missing
parent 039c9288
import warnings import warnings
import os
from .extension import _HAS_OPS from .extension import _HAS_OPS
...@@ -16,6 +17,14 @@ try: ...@@ -16,6 +17,14 @@ try:
except ImportError: except ImportError:
pass pass
# Check if torchvision is being imported within the root folder
if (not _HAS_OPS and os.path.dirname(os.path.realpath(__file__)) ==
os.path.join(os.path.realpath(os.getcwd()), 'torchvision')):
message = ('You are importing torchvision within its own root folder ({}). '
'This is not expected to work and may give errors. Please exit the '
'torchvision project source and relaunch your python interpreter.')
warnings.warn(message.format(os.getcwd()))
_image_backend = 'PIL' _image_backend = 'PIL'
_video_backend = "pyav" _video_backend = "pyav"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment