Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,9 +11,12 @@ from transformers import (
|
|
| 11 |
from huggingface_hub import snapshot_download, login
|
| 12 |
|
| 13 |
# ----------------- Hugging Face Authentication -----------------
|
| 14 |
-
HF_TOKEN = "
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# ----------------- Basic Environment Setup -----------------
|
| 19 |
print("π§ Initializing environment (CPU mode)...")
|
|
@@ -27,11 +30,8 @@ device = "cpu"
|
|
| 27 |
|
| 28 |
# ----------------- Model Download -----------------
|
| 29 |
folder_path = './xcodec_mini_infer'
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
print(f"π¦ Folder created: {folder_path}")
|
| 33 |
-
else:
|
| 34 |
-
print(f"π¦ Folder already exists: {folder_path}")
|
| 35 |
|
| 36 |
snapshot_download(
|
| 37 |
repo_id="m-a-p/xcodec_mini_infer",
|
|
@@ -47,11 +47,10 @@ from mmtokenizer import _MMSentencePieceTokenizer
|
|
| 47 |
from models.soundstream_hubert_new import SoundStream
|
| 48 |
|
| 49 |
# ----------------- Load YuE Model -----------------
|
| 50 |
-
print("π§ Loading YuE model on CPU (
|
| 51 |
-
|
| 52 |
try:
|
| 53 |
model = AutoModelForCausalLM.from_pretrained(
|
| 54 |
-
"m-a-p/YuE-s1-1B-mini-en-cot",
|
| 55 |
torch_dtype=torch.float32,
|
| 56 |
attn_implementation="eager",
|
| 57 |
low_cpu_mem_usage=True,
|
|
@@ -66,7 +65,6 @@ except Exception as e:
|
|
| 66 |
|
| 67 |
# ----------------- Load Codec -----------------
|
| 68 |
print("π§ Loading codec model...")
|
| 69 |
-
|
| 70 |
basic_model_config = './xcodec_mini_infer/final_ckpt/config.yaml'
|
| 71 |
resume_path = './xcodec_mini_infer/final_ckpt/ckpt_00100000.pth'
|
| 72 |
|
|
|
|
| 11 |
from huggingface_hub import snapshot_download, login
|
| 12 |
|
| 13 |
# ----------------- Hugging Face Authentication -----------------
|
| 14 |
+
HF_TOKEN = os.getenv("HF_TOKEN") # β
Read securely from environment variable
|
| 15 |
+
if HF_TOKEN:
|
| 16 |
+
login(token=HF_TOKEN)
|
| 17 |
+
print("π Logged into Hugging Face successfully.")
|
| 18 |
+
else:
|
| 19 |
+
print("β οΈ No Hugging Face token found. Please set it in your environment variables.")
|
| 20 |
|
| 21 |
# ----------------- Basic Environment Setup -----------------
|
| 22 |
print("π§ Initializing environment (CPU mode)...")
|
|
|
|
| 30 |
|
| 31 |
# ----------------- Model Download -----------------
|
| 32 |
folder_path = './xcodec_mini_infer'
|
| 33 |
+
os.makedirs(folder_path, exist_ok=True)
|
| 34 |
+
print(f"π¦ Folder ready: {folder_path}")
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
snapshot_download(
|
| 37 |
repo_id="m-a-p/xcodec_mini_infer",
|
|
|
|
| 47 |
from models.soundstream_hubert_new import SoundStream
|
| 48 |
|
| 49 |
# ----------------- Load YuE Model -----------------
|
| 50 |
+
print("π§ Loading YuE model on CPU (small version)...")
|
|
|
|
| 51 |
try:
|
| 52 |
model = AutoModelForCausalLM.from_pretrained(
|
| 53 |
+
"m-a-p/YuE-s1-1B-mini-en-cot",
|
| 54 |
torch_dtype=torch.float32,
|
| 55 |
attn_implementation="eager",
|
| 56 |
low_cpu_mem_usage=True,
|
|
|
|
| 65 |
|
| 66 |
# ----------------- Load Codec -----------------
|
| 67 |
print("π§ Loading codec model...")
|
|
|
|
| 68 |
basic_model_config = './xcodec_mini_infer/final_ckpt/config.yaml'
|
| 69 |
resume_path = './xcodec_mini_infer/final_ckpt/ckpt_00100000.pth'
|
| 70 |
|