fix: restore compatible runtime dependency install
Browse files- app.py +17 -3
- requirements.txt +3 -7
app.py
CHANGED
|
@@ -1,12 +1,26 @@
|
|
| 1 |
-
import sys, os, tempfile
|
| 2 |
from threading import Thread
|
| 3 |
from typing import Iterator
|
| 4 |
import queue
|
| 5 |
import threading
|
| 6 |
|
| 7 |
|
| 8 |
-
# Runtime
|
| 9 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
import torch
|
| 11 |
from transformers import AutoModel, AutoTokenizer, TextIteratorStreamer
|
| 12 |
from gradio import Server
|
|
|
|
| 1 |
+
import subprocess, sys, os, tempfile
|
| 2 |
from threading import Thread
|
| 3 |
from typing import Iterator
|
| 4 |
import queue
|
| 5 |
import threading
|
| 6 |
|
| 7 |
|
| 8 |
+
# Runtime install of exact model-required versions. This cannot live in
|
| 9 |
+
# requirements.txt because Gradio 6.19 requires huggingface-hub >=1.2 while
|
| 10 |
+
# Transformers 4.x requires huggingface-hub <1.0.
|
| 11 |
+
_RUNTIME_PKGS = [
|
| 12 |
+
"torch==2.10.0",
|
| 13 |
+
"torchvision==0.25.0",
|
| 14 |
+
"transformers>=4.48.0,<5.0.0",
|
| 15 |
+
]
|
| 16 |
+
|
| 17 |
+
print("Installing pinned runtime dependencies...")
|
| 18 |
+
subprocess.run(
|
| 19 |
+
[sys.executable, "-m", "pip", "install", "--quiet", "--no-cache-dir", "--force-reinstall"] + _RUNTIME_PKGS,
|
| 20 |
+
check=True,
|
| 21 |
+
)
|
| 22 |
+
print("Runtime deps installed.")
|
| 23 |
+
|
| 24 |
import torch
|
| 25 |
from transformers import AutoModel, AutoTokenizer, TextIteratorStreamer
|
| 26 |
from gradio import Server
|
requirements.txt
CHANGED
|
@@ -1,11 +1,7 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
| 3 |
-
#
|
| 4 |
-
# is_torch_fx_available, which was removed in v5.
|
| 5 |
huggingface-hub>=1.2.0
|
| 6 |
-
torch==2.10.0
|
| 7 |
-
torchvision==0.25.0
|
| 8 |
-
transformers>=4.48.0,<5.0.0
|
| 9 |
matplotlib>=3.7.0
|
| 10 |
einops>=0.8.0
|
| 11 |
addict>=2.4.0
|
|
|
|
| 1 |
+
# Build-time deps only - gradio-compatible.
|
| 2 |
+
# huggingface-hub pinned here because the Space base image ships 0.36.x
|
| 3 |
+
# which is too old for gradio 6.19.0 (needs >=1.2.0).
|
|
|
|
| 4 |
huggingface-hub>=1.2.0
|
|
|
|
|
|
|
|
|
|
| 5 |
matplotlib>=3.7.0
|
| 6 |
einops>=0.8.0
|
| 7 |
addict>=2.4.0
|