diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-12-03 19:58:53 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-03 19:58:53 +0300 |
commit | 334298d47326686e5640b12b2b17e8897dacac8d (patch) | |
tree | 8ddaa9368868d32057b2dd2a759eb4929af50f03 /modules | |
parent | 2d5507fce5fa088053fbe5bacaf458397845660c (diff) | |
parent | d92ce145bba714c5b257b9853aa22681233651b8 (diff) |
Merge pull request #14186 from akx/torchvision-basicsr-hack
Add import_hook hack to work around basicsr/torchvision incompatibility
Diffstat (limited to 'modules')
-rw-r--r-- | modules/import_hook.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/import_hook.py b/modules/import_hook.py index 28c67dfa..eba9a372 100644 --- a/modules/import_hook.py +++ b/modules/import_hook.py @@ -3,3 +3,14 @@ import sys # this will break any attempt to import xformers which will prevent stability diffusion repo from trying to use it if "--xformers" not in "".join(sys.argv): sys.modules["xformers"] = None + +# Hack to fix a changed import in torchvision 0.17+, which otherwise breaks +# basicsr; see https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13985 +try: + import torchvision.transforms.functional_tensor # noqa: F401 +except ImportError: + try: + import torchvision.transforms.functional as functional + sys.modules["torchvision.transforms.functional_tensor"] = functional + except ImportError: + pass # shrug... |