Spaces:
Running on Zero
Running on Zero
Update scripts_infer/anidoc_inference.py
Browse files
scripts_infer/anidoc_inference.py
CHANGED
|
@@ -1,18 +1,23 @@
|
|
| 1 |
import sys
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
from pyparsing import col
|
| 5 |
sys.path.insert(0, ".")
|
| 6 |
|
| 7 |
-
# --- compatibility
|
| 8 |
import huggingface_hub
|
| 9 |
-
|
| 10 |
if not hasattr(huggingface_hub, "cached_download"):
|
| 11 |
-
# For this project, the symbol is mainly needed so old diffusers can import.
|
| 12 |
-
# In AniDoc's normal path, hf_hub_download is the closest modern equivalent.
|
| 13 |
from huggingface_hub import hf_hub_download
|
| 14 |
huggingface_hub.cached_download = hf_hub_download
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
import argparse
|
| 18 |
from packaging import version
|
|
|
|
| 1 |
import sys
|
| 2 |
import os
|
| 3 |
+
import types
|
| 4 |
|
| 5 |
from pyparsing import col
|
| 6 |
sys.path.insert(0, ".")
|
| 7 |
|
| 8 |
+
# ---- huggingface_hub compatibility for old diffusers ----
|
| 9 |
import huggingface_hub
|
|
|
|
| 10 |
if not hasattr(huggingface_hub, "cached_download"):
|
|
|
|
|
|
|
| 11 |
from huggingface_hub import hf_hub_download
|
| 12 |
huggingface_hub.cached_download = hf_hub_download
|
| 13 |
+
|
| 14 |
+
# ---- torchvision compatibility for old basicsr ----
|
| 15 |
+
import torchvision.transforms.functional as TVF
|
| 16 |
+
if "torchvision.transforms.functional_tensor" not in sys.modules:
|
| 17 |
+
functional_tensor = types.ModuleType("torchvision.transforms.functional_tensor")
|
| 18 |
+
functional_tensor.rgb_to_grayscale = TVF.rgb_to_grayscale
|
| 19 |
+
sys.modules["torchvision.transforms.functional_tensor"] = functional_tensor
|
| 20 |
+
# ---------------------------------------------------------
|
| 21 |
|
| 22 |
import argparse
|
| 23 |
from packaging import version
|