-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvisualize_dist.py
57 lines (50 loc) · 1.99 KB
/
visualize_dist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import os
from multiprocessing import Pool, Process, spawn
import multiprocessing
from quantization.utils import visualize_distribution
print("input result name(e.g.90epoch):", end=' ')
name = input()
pic_path = os.path.join("visualize", f"pt_{name}")
AWdirs = sorted(os.listdir(pic_path))
for AWdir in AWdirs:
AWdir = os.path.join(pic_path, AWdir)
if os.path.isfile(AWdir):
continue
FBdirs = sorted(os.listdir(AWdir))
for FBdir in FBdirs:
# processes = {}
FBdir = os.path.join(AWdir, FBdir)
if os.path.isfile(FBdir):
continue
pts = sorted(os.listdir(FBdir))
# with Pool(processes=10) as pool:
if True:
results = []
processes = []
for pt_path in pts:
if pt_path.endswith("pt"):
processes.append(Process(target=visualize_distribution, args=(os.path.join(FBdir, pt_path), name)))
# visualize_distribution(os.path.join(FBdir, pt_path))
# result = pool.apply_async(visualize_distribution, (os.path.join(FBdir, pt_path),))
# results.append(result)
num_process = 30
for i in range(0, len(processes), num_process):
print(len(processes), f" is processes length at {FBdir}")
for p in processes[i: i + num_process]:
p.start()
for p in processes[i: i + num_process]:
p.join()
# for result in results:
# result.get()
# pool.join()
# import IPython
# IPython.embed()
# for p in processes.values():
# p.start()
# for idx, (k, p) in enumerate(processes.items()):
# p.join()
# print(" " * 100, f"The {idx} process named {k} joined")
#
# print("@" * 1000, FBdir)
# import IPython
# IPython.embed()