jacky3102 commited on
Commit
b5f49bb
·
verified ·
1 Parent(s): 077bb3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -4,7 +4,7 @@ import shutil
4
  import subprocess
5
  from pathlib import Path
6
 
7
- # Environment flags for Hugging Face Spaces CPU runtime
8
  os.environ["CUDA_VISIBLE_DEVICES"] = ""
9
  os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0"
10
  os.environ["GRADIO_SERVER_PORT"] = "7860"
@@ -17,7 +17,7 @@ def run(cmd, cwd=None):
17
  print(">>>", " ".join(map(str, cmd)), flush=True)
18
  subprocess.check_call(cmd, cwd=cwd)
19
 
20
- # 1. Clone repository safely (cleaning up existing empty/broken dirs if present)
21
  if not (RVC_DIR / "infer-web.py").exists():
22
  if RVC_DIR.exists():
23
  shutil.rmtree(RVC_DIR)
@@ -28,11 +28,11 @@ if not (RVC_DIR / "infer-web.py").exists():
28
  str(RVC_DIR)
29
  ])
30
 
31
- # 2. Set execution context
32
  sys.path.insert(0, str(RVC_DIR))
33
  os.chdir(RVC_DIR)
34
 
35
- # 3. Download pretrained assets if missing
36
  hubert = RVC_DIR / "assets" / "hubert" / "hubert_base.pt"
37
  rmvpe = RVC_DIR / "assets" / "rmvpe" / "rmvpe.pt"
38
 
@@ -41,10 +41,10 @@ if not hubert.exists() or not rmvpe.exists():
41
  if downloader.exists():
42
  run([sys.executable, str(downloader)], cwd=RVC_DIR)
43
 
44
- # 4. Launch RVC WebUI
45
  run([
46
  sys.executable,
47
  "infer-web.py",
48
  "--pycmd", sys.executable,
49
  "--port", "7860",
50
- ], cwd=RVC_DIR)
 
4
  import subprocess
5
  from pathlib import Path
6
 
7
+ # Hugging Face Spaces / CPU-only environment setup
8
  os.environ["CUDA_VISIBLE_DEVICES"] = ""
9
  os.environ["GRADIO_SERVER_NAME"] = "0.0.0.0"
10
  os.environ["GRADIO_SERVER_PORT"] = "7860"
 
17
  print(">>>", " ".join(map(str, cmd)), flush=True)
18
  subprocess.check_call(cmd, cwd=cwd)
19
 
20
+ # Force-clean any empty or broken /app/rvc folder before cloning
21
  if not (RVC_DIR / "infer-web.py").exists():
22
  if RVC_DIR.exists():
23
  shutil.rmtree(RVC_DIR)
 
28
  str(RVC_DIR)
29
  ])
30
 
31
+ # Set working directory to RVC root
32
  sys.path.insert(0, str(RVC_DIR))
33
  os.chdir(RVC_DIR)
34
 
35
+ # Download required model assets if missing
36
  hubert = RVC_DIR / "assets" / "hubert" / "hubert_base.pt"
37
  rmvpe = RVC_DIR / "assets" / "rmvpe" / "rmvpe.pt"
38
 
 
41
  if downloader.exists():
42
  run([sys.executable, str(downloader)], cwd=RVC_DIR)
43
 
44
+ # Launch RVC WebUI directly from the current working directory
45
  run([
46
  sys.executable,
47
  "infer-web.py",
48
  "--pycmd", sys.executable,
49
  "--port", "7860",
50
+ ])