skytnt commited on
Commit
8fc0049
β€’
1 Parent(s): c81b94b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -55
app.py CHANGED
@@ -76,59 +76,6 @@ def create_vc_fn(model, hps, speaker_ids):
76
  return vc_fn
77
 
78
 
79
- def system_monitor():
80
- def get_size(bs, suffix="B"):
81
- """
82
- Scale bytes to its proper format
83
- e.g:
84
- 1253656 => '1.20MB'
85
- 1253656678 => '1.17GB'
86
- """
87
- factor = 1024
88
- for unit in ["", "K", "M", "G", "T", "P"]:
89
- if bs < factor:
90
- return f"{bs:.2f}{unit}{suffix}"
91
- bs /= factor
92
-
93
- def read_int(path):
94
- with open(path, "r") as f:
95
- return int(f.read())
96
-
97
- def print_sys_status():
98
- try:
99
- cpu_t1 = read_int("/sys/fs/cgroup/cpu/cpuacct.usage")
100
- t1 = time.time() * 1000000000
101
- time.sleep(1)
102
- cpu_t2 = read_int("/sys/fs/cgroup/cpu/cpuacct.usage")
103
- t2 = time.time() * 1000000000
104
- cpu_percent = (cpu_t2 - cpu_t1) / (t2 - t1) * 100
105
- mem_total = get_size(read_int("/sys/fs/cgroup/memory/memory.limit_in_bytes"))
106
- mem_usage = get_size(read_int("/sys/fs/cgroup/memory/memory.usage_in_bytes"))
107
- print("=" * 10, "CPU & Mem Information", "=" * 10)
108
- print(f"CPU: {cpu_percent}%, "
109
- f"Mem: {mem_usage}/{mem_total}")
110
- except FileNotFoundError:
111
- pass
112
-
113
- print("=" * 10, "Disk Information", "=" * 10)
114
- # get all disk partitions
115
- partitions = psutil.disk_partitions()
116
- disk_info = ""
117
- for partition in partitions:
118
- disk_info += f"{partition.mountpoint}: "
119
- try:
120
- partition_usage = psutil.disk_usage(partition.mountpoint)
121
- except PermissionError:
122
- continue
123
- disk_info += f"{partition_usage.percent}%({get_size(partition_usage.total)}), "
124
- print(disk_info)
125
-
126
- tr = Timer(60, print_sys_status)
127
- tr.start()
128
-
129
- print_sys_status()
130
-
131
-
132
  css = """
133
  #advanced-btn {
134
  color: white;
@@ -148,8 +95,6 @@ css = """
148
  """
149
 
150
  if __name__ == '__main__':
151
- if os.getenv("SYSTEM") == "spaces":
152
- system_monitor() # debug
153
  models = []
154
  with open("saved_model/names.json", "r", encoding="utf-8") as f:
155
  models_names = json.load(f)
 
76
  return vc_fn
77
 
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  css = """
80
  #advanced-btn {
81
  color: white;
 
95
  """
96
 
97
  if __name__ == '__main__':
 
 
98
  models = []
99
  with open("saved_model/names.json", "r", encoding="utf-8") as f:
100
  models_names = json.load(f)