mysome commited on
Commit
16c1169
Β·
verified Β·
1 Parent(s): 934674c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -8,7 +8,12 @@ from transformers import (
8
  AutoTokenizer, AutoModelForCausalLM,
9
  LogitsProcessor, LogitsProcessorList
10
  )
11
- from huggingface_hub import snapshot_download
 
 
 
 
 
12
 
13
  # ----------------- Basic Environment Setup -----------------
14
  print("πŸ”§ Initializing environment (CPU mode)...")
@@ -31,6 +36,7 @@ else:
31
  snapshot_download(
32
  repo_id="m-a-p/xcodec_mini_infer",
33
  local_dir="./xcodec_mini_infer",
 
34
  )
35
 
36
  sys.path.append(os.path.join(os.path.dirname(__file__), 'xcodec_mini_infer'))
@@ -45,14 +51,13 @@ print("🧠 Loading YuE model on CPU (8-bit)...")
45
 
46
  try:
47
  model = AutoModelForCausalLM.from_pretrained(
48
- "m-a-p/YuE-s1-1B-mini-en-cot", # βœ… smaller model
49
- torch_dtype=torch.float32,
50
- attn_implementation="eager",
51
- low_cpu_mem_usage=True,
52
- device_map={"": "cpu"}
 
53
  )
54
-
55
-
56
  model.eval()
57
  print("βœ… YuE model loaded successfully.")
58
  except Exception as e:
@@ -63,7 +68,7 @@ except Exception as e:
63
  print("🎧 Loading codec model...")
64
 
65
  basic_model_config = './xcodec_mini_infer/final_ckpt/config.yaml'
66
- resume_path = './xcodec_mini_infer/final_ckpt/ckpt_00100000.pth' # smaller ckpt
67
 
68
  mmtokenizer = _MMSentencePieceTokenizer("./mm_tokenizer_v0.2_hf/tokenizer.model")
69
  codectool = CodecManipulator("xcodec", 0, 1)
 
8
  AutoTokenizer, AutoModelForCausalLM,
9
  LogitsProcessor, LogitsProcessorList
10
  )
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)...")
 
36
  snapshot_download(
37
  repo_id="m-a-p/xcodec_mini_infer",
38
  local_dir="./xcodec_mini_infer",
39
+ token=HF_TOKEN
40
  )
41
 
42
  sys.path.append(os.path.join(os.path.dirname(__file__), 'xcodec_mini_infer'))
 
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,
58
+ device_map={"": "cpu"},
59
+ token=HF_TOKEN
60
  )
 
 
61
  model.eval()
62
  print("βœ… YuE model loaded successfully.")
63
  except Exception as e:
 
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
 
73
  mmtokenizer = _MMSentencePieceTokenizer("./mm_tokenizer_v0.2_hf/tokenizer.model")
74
  codectool = CodecManipulator("xcodec", 0, 1)