Spaces:
Running on Zero
Running on Zero
koby commited on
Commit ·
f85bfad
1
Parent(s): 12f54a6
install yue2 wheel at runtime with --no-deps (build-time pins conflict with gradio6)
Browse files- app.py +25 -0
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -25,9 +25,34 @@ FEED_TTL = 30 # seconds
|
|
| 25 |
pipe = None
|
| 26 |
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
def get_pipeline():
|
| 29 |
global pipe
|
| 30 |
if pipe is None:
|
|
|
|
| 31 |
from yue2 import YuE2Pipeline
|
| 32 |
print("Loading YuE2-3B pipeline on GPU...")
|
| 33 |
pipe = YuE2Pipeline.from_pretrained(
|
|
|
|
| 25 |
pipe = None
|
| 26 |
|
| 27 |
|
| 28 |
+
def _ensure_yue2():
|
| 29 |
+
"""Install the vendored yue2-infer wheel at runtime (not build time).
|
| 30 |
+
|
| 31 |
+
It can't go in requirements.txt: it pins huggingface-hub==0.36.2 /
|
| 32 |
+
transformers==4.57.6 which conflict with Gradio 6 (hub>=1.16) and break
|
| 33 |
+
the Docker build. --no-deps sidesteps the pins; the package only needs
|
| 34 |
+
torch/transformers/hub/safetensors/tiktoken/soundfile which are present.
|
| 35 |
+
"""
|
| 36 |
+
try:
|
| 37 |
+
import yue2 # noqa: F401
|
| 38 |
+
return
|
| 39 |
+
except ImportError:
|
| 40 |
+
pass
|
| 41 |
+
import subprocess
|
| 42 |
+
import sys
|
| 43 |
+
whl = os.path.join(os.path.dirname(os.path.abspath(__file__)), "yue2_infer-0.1.5-py3-none-any.whl")
|
| 44 |
+
print(f"[yue2] installing vendored wheel: {whl}")
|
| 45 |
+
subprocess.run(
|
| 46 |
+
[sys.executable, "-m", "pip", "install", "--no-deps", whl],
|
| 47 |
+
check=True, capture_output=True, text=True,
|
| 48 |
+
)
|
| 49 |
+
print("[yue2] installed.")
|
| 50 |
+
|
| 51 |
+
|
| 52 |
def get_pipeline():
|
| 53 |
global pipe
|
| 54 |
if pipe is None:
|
| 55 |
+
_ensure_yue2()
|
| 56 |
from yue2 import YuE2Pipeline
|
| 57 |
print("Loading YuE2-3B pipeline on GPU...")
|
| 58 |
pipe = YuE2Pipeline.from_pretrained(
|
requirements.txt
CHANGED
|
@@ -5,4 +5,4 @@ transformers>=4.40.0
|
|
| 5 |
gradio
|
| 6 |
huggingface-hub
|
| 7 |
soundfile
|
| 8 |
-
|
|
|
|
| 5 |
gradio
|
| 6 |
huggingface-hub
|
| 7 |
soundfile
|
| 8 |
+
tiktoken
|