Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,17 @@
|
|
3 |
* 依存モデルは /data が書込可ならそこへ、それ以外は ~/.cache に保存
|
4 |
* wget を使った簡易リトライ DL
|
5 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
import os, subprocess, cv2, torch, spaces, gradio as gr, numpy as np
|
7 |
from pathlib import Path
|
8 |
from PIL import Image
|
|
|
3 |
* 依存モデルは /data が書込可ならそこへ、それ以外は ~/.cache に保存
|
4 |
* wget を使った簡易リトライ DL
|
5 |
"""
|
6 |
+
# --- ★ Monkey-Patch: torchvision 0.17+ で消えた functional_tensor を補完 ---
|
7 |
+
import types, sys
|
8 |
+
from torchvision.transforms import functional as F
|
9 |
+
|
10 |
+
mod = types.ModuleType("torchvision.transforms.functional_tensor")
|
11 |
+
# 必要なのは rgb_to_grayscale だけなのでこれだけエイリアス
|
12 |
+
mod.rgb_to_grayscale = F.rgb_to_grayscale
|
13 |
+
sys.modules["torchvision.transforms.functional_tensor"] = mod
|
14 |
+
# ---------------------------------------------------------------------------
|
15 |
+
|
16 |
+
|
17 |
import os, subprocess, cv2, torch, spaces, gradio as gr, numpy as np
|
18 |
from pathlib import Path
|
19 |
from PIL import Image
|