kevinwang676 commited on
Commit
e045432
1 Parent(s): 4aa0161

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -2,6 +2,8 @@ import re, os
2
  import requests
3
  import json
4
 
 
 
5
  headers = {
6
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
7
  }
@@ -72,17 +74,18 @@ for name in os.listdir(weight_uvr5_root):
72
  uvr5_names.append(name.replace(".pth", ""))
73
 
74
  func = AudioPre
 
75
  pre_fun_hp2 = func(
76
  agg=int(10),
77
  model_path=os.path.join(weight_uvr5_root, "UVR-HP2.pth"),
78
- device="cuda",
79
  is_half=True,
80
  )
81
 
82
  pre_fun_hp5 = func(
83
  agg=int(10),
84
  model_path=os.path.join(weight_uvr5_root, "UVR-HP5.pth"),
85
- device="cuda",
86
  is_half=True,
87
  )
88
 
 
2
  import requests
3
  import json
4
 
5
+ device = 'cuda' if torch.cuda.is_available() else 'cpu'
6
+
7
  headers = {
8
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"
9
  }
 
74
  uvr5_names.append(name.replace(".pth", ""))
75
 
76
  func = AudioPre
77
+
78
  pre_fun_hp2 = func(
79
  agg=int(10),
80
  model_path=os.path.join(weight_uvr5_root, "UVR-HP2.pth"),
81
+ device=device,
82
  is_half=True,
83
  )
84
 
85
  pre_fun_hp5 = func(
86
  agg=int(10),
87
  model_path=os.path.join(weight_uvr5_root, "UVR-HP5.pth"),
88
+ device=device,
89
  is_half=True,
90
  )
91