Skip to content

Commit d92ce14

Browse files
committed
Add import_hook hack to work around basicsr incompatibility
Fixes #13985
1 parent b4776ea commit d92ce14

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

modules/import_hook.py

+11
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,14 @@
33
# this will break any attempt to import xformers which will prevent stability diffusion repo from trying to use it
44
if "--xformers" not in "".join(sys.argv):
55
sys.modules["xformers"] = None
6+
7+
# Hack to fix a changed import in torchvision 0.17+, which otherwise breaks
8+
# basicsr; see https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/13985
9+
try:
10+
import torchvision.transforms.functional_tensor # noqa: F401
11+
except ImportError:
12+
try:
13+
import torchvision.transforms.functional as functional
14+
sys.modules["torchvision.transforms.functional_tensor"] = functional
15+
except ImportError:
16+
pass # shrug...

0 commit comments

Comments
 (0)