profgabrielramos commited on
Commit
34c8478
·
verified ·
1 Parent(s): dd10800

fix: restore compatible runtime dependency install

Browse files
Files changed (2) hide show
  1. app.py +17 -3
  2. 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 packages are pinned in requirements.txt so imports can happen as
9
- # soon as the container starts.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- # Keep model runtime dependencies in the image so the app server can start
2
- # immediately instead of reinstalling large wheels on every container boot.
3
- # transformers stays below v5 because the model's custom code imports
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