ginipick commited on
Commit
265ca80
ยท
verified ยท
1 Parent(s): 88b7daa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -64
app.py CHANGED
@@ -199,78 +199,36 @@ def install_flash_attn():
199
  logging.warning(f"Failed to install flash-attn: {e}")
200
  return False
201
 
 
202
  def initialize_system():
203
  optimize_gpu_settings()
204
 
205
- try:
206
- # ๊ธฐ๋ณธ ๋””๋ ‰ํ† ๋ฆฌ ๊ตฌ์กฐ ์ƒ์„ฑ
207
- base_dir = os.path.abspath("./inference")
208
- os.makedirs(base_dir, exist_ok=True)
209
- os.makedirs(os.path.join(base_dir, "models"), exist_ok=True)
210
-
211
- # ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ ๋ณ€๊ฒฝ
212
- os.chdir(base_dir)
213
- logging.info(f"Working directory changed to: {os.getcwd()}")
214
 
215
- from huggingface_hub import snapshot_download, hf_hub_download
216
 
217
- # xcodec_mini_infer ๋‹ค์šด๋กœ๋“œ
218
- xcodec_dir = "xcodec_mini_infer"
219
- os.makedirs(xcodec_dir, exist_ok=True)
220
 
221
- # ํ•„์ˆ˜ ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ
222
- snapshot_download(
223
- repo_id="m-a-p/xcodec_mini_infer",
224
- local_dir=xcodec_dir,
225
- force_download=True
226
- )
227
-
228
- # infer.py ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ
229
- infer_script = hf_hub_download(
230
  repo_id="m-a-p/xcodec_mini_infer",
231
- filename="infer.py",
232
- force_download=True
233
- )
234
-
235
- # infer.py ํŒŒ์ผ์„ ํ˜„์žฌ ๋””๋ ‰ํ† ๋ฆฌ๋กœ ๋ณต์‚ฌ
236
- shutil.copy2(infer_script, "infer.py")
237
-
238
- # YuE ๋ชจ๋ธ๋“ค ๋‹ค์šด๋กœ๋“œ
239
- models = [
240
- "m-a-p/YuE-s1-7B-anneal-jp-kr-cot",
241
- "m-a-p/YuE-s1-7B-anneal-en-cot",
242
- "m-a-p/YuE-s1-7B-anneal-zh-cot",
243
- "m-a-p/YuE-s2-1B-general"
244
- ]
245
-
246
- for model in models:
247
- model_name = model.split('/')[-1]
248
- model_path = os.path.join("models", model_name)
249
- snapshot_download(
250
- repo_id=model,
251
- local_dir=model_path,
252
- force_download=True
253
- )
254
-
255
- # ํ•„์š”ํ•œ ํŒŒ์ผ๋“ค ์กด์žฌ ํ™•์ธ
256
- required_files = [
257
- "infer.py",
258
- os.path.join(xcodec_dir, "config.json"),
259
- os.path.join(xcodec_dir, "vocal_decoder.pth"),
260
- os.path.join(xcodec_dir, "inst_decoder.pth")
261
- ]
262
-
263
- for file_path in required_files:
264
- if not os.path.exists(file_path):
265
- raise FileNotFoundError(f"Required file not found: {file_path}")
266
- else:
267
- file_size = os.path.getsize(file_path)
268
- logging.info(f"Verified {file_path}: {file_size} bytes")
269
 
270
- logging.info("System initialization completed successfully")
271
-
272
- except Exception as e:
273
- logging.error(f"Initialization error: {e}")
 
 
 
 
274
  raise
275
 
276
  @lru_cache(maxsize=100)
 
199
  logging.warning(f"Failed to install flash-attn: {e}")
200
  return False
201
 
202
+
203
  def initialize_system():
204
  optimize_gpu_settings()
205
 
206
+ with ThreadPoolExecutor(max_workers=4) as executor:
207
+ futures = []
 
 
 
 
 
 
 
208
 
209
+ futures.append(executor.submit(install_flash_attn))
210
 
211
+ from huggingface_hub import snapshot_download
 
 
212
 
213
+ folder_path = './inference/xcodec_mini_infer'
214
+ os.makedirs(folder_path, exist_ok=True)
215
+ logging.info(f"Created folder at: {folder_path}")
216
+
217
+ futures.append(executor.submit(
218
+ snapshot_download,
 
 
 
219
  repo_id="m-a-p/xcodec_mini_infer",
220
+ local_dir="./inference/xcodec_mini_infer",
221
+ resume_download=True
222
+ ))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
+ for future in futures:
225
+ future.result()
226
+
227
+ try:
228
+ os.chdir("./inference")
229
+ logging.info(f"Working directory changed to: {os.getcwd()}")
230
+ except FileNotFoundError as e:
231
+ logging.error(f"Directory error: {e}")
232
  raise
233
 
234
  @lru_cache(maxsize=100)