Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -4,10 +4,16 @@ os.environ.setdefault("PYTORCH_CUDA_ALLOC_CONF", "expandable_segments:True")
|
|
| 4 |
import spaces # MUST come before any torch/CUDA-touching import
|
| 5 |
import torch
|
| 6 |
import torchvision
|
|
|
|
|
|
|
|
|
|
| 7 |
# Compatibility shim: torchvision >= 0.21 removed functional_tensor, which pytorchvideo still imports
|
| 8 |
if not hasattr(torchvision.transforms, 'functional_tensor'):
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
| 11 |
import gradio as gr
|
| 12 |
import numpy as np
|
| 13 |
import tempfile
|
|
|
|
| 4 |
import spaces # MUST come before any torch/CUDA-touching import
|
| 5 |
import torch
|
| 6 |
import torchvision
|
| 7 |
+
import torchvision.transforms.functional as _F
|
| 8 |
+
import sys
|
| 9 |
+
import types
|
| 10 |
# Compatibility shim: torchvision >= 0.21 removed functional_tensor, which pytorchvideo still imports
|
| 11 |
if not hasattr(torchvision.transforms, 'functional_tensor'):
|
| 12 |
+
_mod = types.ModuleType('torchvision.transforms.functional_tensor')
|
| 13 |
+
for _name in dir(_F):
|
| 14 |
+
setattr(_mod, _name, getattr(_F, _name))
|
| 15 |
+
sys.modules['torchvision.transforms.functional_tensor'] = _mod
|
| 16 |
+
torchvision.transforms.functional_tensor = _mod
|
| 17 |
import gradio as gr
|
| 18 |
import numpy as np
|
| 19 |
import tempfile
|