aboutsummaryrefslogtreecommitdiff
path: root/modules/import_hook.py
diff options
context:
space:
mode:
authorfuchen.ljl <yjqqqqdx_01@163.com>2023-12-06 20:42:04 +0800
committerGitHub <noreply@github.com>2023-12-06 20:42:04 +0800
commitc2bdbb67b66de06f1163de3f10c290213cd6bdb0 (patch)
tree0fcb3010a72ad253862f317ea18fdeb46b05a322 /modules/import_hook.py
parent4d56383025f2cbd00dc6296161e31a896624ab75 (diff)
parentf92d61497a426a19818625c3ccdaae9beeb82b31 (diff)
Merge branch 'dev' into kingljl-patch-memory-leak
Diffstat (limited to 'modules/import_hook.py')
-rw-r--r--modules/import_hook.py11
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...