Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,11 +11,23 @@ from collections.abc import Iterator
|
|
| 11 |
from pathlib import Path
|
| 12 |
from threading import Thread
|
| 13 |
|
| 14 |
-
# Install pre-built transformers wheel
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
subprocess.check_call([sys.executable, "-m", "pip", "install", str(_whl)])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
import urllib3
|
| 21 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
| 11 |
from pathlib import Path
|
| 12 |
from threading import Thread
|
| 13 |
|
| 14 |
+
# Install pre-built transformers wheel BEFORE importing transformers
|
| 15 |
+
_app_dir = Path(__file__).parent
|
| 16 |
+
_whls = sorted(_app_dir.glob("transformers*.whl"))
|
| 17 |
+
_installed = False
|
| 18 |
+
if _whls:
|
| 19 |
+
_whl = _whls[0]
|
| 20 |
+
print(f"[BOOT] Installing wheel: {_whl.name}", flush=True)
|
| 21 |
+
try:
|
| 22 |
subprocess.check_call([sys.executable, "-m", "pip", "install", str(_whl)])
|
| 23 |
+
_installed = True
|
| 24 |
+
print("[BOOT] ✓ Wheel installed", flush=True)
|
| 25 |
+
except subprocess.CalledProcessError as e:
|
| 26 |
+
print(f"[BOOT] ⚠ Wheel install failed ({e}), falling back to PyPI", flush=True)
|
| 27 |
+
|
| 28 |
+
if not _installed:
|
| 29 |
+
print("[BOOT] Installing transformers from PyPI...", flush=True)
|
| 30 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "transformers>=4.49"])
|
| 31 |
|
| 32 |
import urllib3
|
| 33 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|