mysome commited on
Commit
720d9d0
Β·
verified Β·
1 Parent(s): 16c1169

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -12
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 = "YOUR_HUGGINGFACE_TOKEN_HERE" # πŸ” Replace with your real token
15
- login(token=HF_TOKEN)
16
- print("πŸ”‘ Logged into Hugging Face successfully.")
 
 
 
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
- if not os.path.exists(folder_path):
31
- os.mkdir(folder_path)
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 (8-bit)...")
51
-
52
  try:
53
  model = AutoModelForCausalLM.from_pretrained(
54
- "m-a-p/YuE-s1-1B-mini-en-cot", # βœ… smaller model for CPU
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