fix: patch basicsr compatibility with torchvision 0.18+
The functional_tensor module was removed in torchvision 0.18+. Added compatibility shim to create a fake module that basicsr can import. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"""Model management for Real-ESRGAN and GFPGAN."""
|
"""Model management for Real-ESRGAN and GFPGAN."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
@@ -10,6 +11,21 @@ import requests
|
|||||||
import torch
|
import torch
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
# Patch for basicsr compatibility with torchvision 0.18+
|
||||||
|
# The functional_tensor module was removed, but basicsr still imports from it
|
||||||
|
import torchvision.transforms.functional as TF
|
||||||
|
|
||||||
|
if not hasattr(TF, "rgb_to_grayscale"):
|
||||||
|
TF.rgb_to_grayscale = TF.to_grayscale
|
||||||
|
|
||||||
|
# Create a fake module to satisfy basicsr's import
|
||||||
|
if "torchvision.transforms.functional_tensor" not in sys.modules:
|
||||||
|
|
||||||
|
class FakeFunctionalTensor:
|
||||||
|
rgb_to_grayscale = TF.rgb_to_grayscale
|
||||||
|
|
||||||
|
sys.modules["torchvision.transforms.functional_tensor"] = FakeFunctionalTensor()
|
||||||
|
|
||||||
from src.config import MODEL_REGISTRY, MODELS_DIR, ModelInfo, config
|
from src.config import MODEL_REGISTRY, MODELS_DIR, ModelInfo, config
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
Reference in New Issue
Block a user