Nevertree commited on
Commit
46ed1d5
·
verified ·
1 Parent(s): f301da4

Upload 3 files

Browse files
Files changed (3) hide show
  1. config.py +106 -0
  2. hubert_base.pt +3 -0
  3. rmvpe.pt +3 -0
config.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ########################硬件参数########################
2
+
3
+ # 填写cuda:x, cpu 或 mps, x指代第几张卡,只支持 N卡 / Apple Silicon 加速
4
+ device = "cuda:0"
5
+
6
+ # 9-10-20-30-40系显卡无脑True,不影响质量,>=20显卡开启有加速
7
+ is_half = True
8
+
9
+ # 默认0用上所有线程,写数字限制CPU资源使用
10
+ n_cpu = 0
11
+
12
+ ########################硬件参数########################
13
+
14
+
15
+ ##################下为参数处理逻辑,勿动##################
16
+
17
+ ########################命令行参数########################
18
+ import argparse
19
+
20
+ parser = argparse.ArgumentParser()
21
+ parser.add_argument("--port", type=int, default=7865, help="Listen port")
22
+ parser.add_argument("--pycmd", type=str, default="python", help="Python command")
23
+ parser.add_argument("--colab", action="store_true", help="Launch in colab")
24
+ parser.add_argument(
25
+ "--noparallel", action="store_true", help="Disable parallel processing"
26
+ )
27
+ parser.add_argument(
28
+ "--noautoopen", action="store_true", help="Do not open in browser automatically"
29
+ )
30
+ cmd_opts = parser.parse_args()
31
+
32
+ python_cmd = cmd_opts.pycmd
33
+ listen_port = cmd_opts.port if 0 <= cmd_opts.port <= 65535 else 7865
34
+ iscolab = cmd_opts.colab
35
+ noparallel = cmd_opts.noparallel
36
+ noautoopen = cmd_opts.noautoopen
37
+ ########################命令行参数########################
38
+
39
+ import sys
40
+ import torch
41
+
42
+
43
+ # has_mps is only available in nightly pytorch (for now) and MasOS 12.3+.
44
+ # check `getattr` and try it for compatibility
45
+ def has_mps() -> bool:
46
+ if sys.platform != "darwin":
47
+ return False
48
+ else:
49
+ if not getattr(torch, "has_mps", False):
50
+ return False
51
+ try:
52
+ torch.zeros(1).to(torch.device("mps"))
53
+ return True
54
+ except Exception:
55
+ return False
56
+
57
+
58
+ if not torch.cuda.is_available():
59
+ if has_mps():
60
+ print("没有发现支持的N卡, 使用MPS进行推理")
61
+ device = "mps"
62
+ else:
63
+ print("没有发现支持的N卡, 使用CPU进行推理")
64
+ device = "cpu"
65
+ is_half = False
66
+
67
+ gpu_mem=None
68
+ if device not in ["cpu", "mps"]:
69
+ i_device=int(device.split(":")[-1])
70
+ gpu_name = torch.cuda.get_device_name(i_device)
71
+ if "16" in gpu_name or "P40"in gpu_name.upper() or "1070"in gpu_name or "1080"in gpu_name:
72
+ print("16系显卡强制单精度")
73
+ is_half = False
74
+ with open("configs/32k.json","r")as f:strr=f.read().replace("true","false")
75
+ with open("configs/32k.json","w")as f:f.write(strr)
76
+ with open("configs/40k.json","r")as f:strr=f.read().replace("true","false")
77
+ with open("configs/40k.json","w")as f:f.write(strr)
78
+ with open("configs/48k.json","r")as f:strr=f.read().replace("true","false")
79
+ with open("configs/48k.json","w")as f:f.write(strr)
80
+ with open("trainset_preprocess_pipeline_print.py","r")as f:strr=f.read().replace("3.7","3.0")
81
+ with open("trainset_preprocess_pipeline_print.py","w")as f:f.write(strr)
82
+ gpu_mem=int(torch.cuda.get_device_properties(i_device).total_memory/1024/1024/1024+0.4)
83
+ if(gpu_mem<=4):
84
+ with open("trainset_preprocess_pipeline_print.py","r")as f:strr=f.read().replace("3.7","3.0")
85
+ with open("trainset_preprocess_pipeline_print.py","w")as f:f.write(strr)
86
+ from multiprocessing import cpu_count
87
+
88
+ if n_cpu == 0:
89
+ n_cpu = cpu_count()
90
+ if is_half:
91
+ # 6G显存配置
92
+ x_pad = 3
93
+ x_query = 10
94
+ x_center = 60
95
+ x_max = 65
96
+ else:
97
+ # 5G显存配置
98
+ x_pad = 1
99
+ x_query = 6
100
+ x_center = 38
101
+ x_max = 41
102
+ if(gpu_mem!=None and gpu_mem<=4):
103
+ x_pad = 1
104
+ x_query = 5
105
+ x_center = 30
106
+ x_max = 32
hubert_base.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f54b40fd2802423a5643779c4861af1e9ee9c1564dc9d32f54f20b5ffba7db96
3
+ size 189507909
rmvpe.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d62215f4306e3ca278246188607209f09af3dc77ed4232efdd069798c4ec193
3
+ size 181184272