forked from StevenJokes/gan-compression
-
Notifications
You must be signed in to change notification settings - Fork 1
/
select_arch.py
34 lines (27 loc) · 1.12 KB
/
select_arch.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
import argparse
import pickle
def takeMACs(item):
return item['macs']
def main(opt):
with open(opt.pkl_path, 'rb') as f:
results = pickle.load(f)
results.sort(key=takeMACs)
for item in results:
assert isinstance(item, dict)
qualified = True
if item['macs'] > opt.macs:
qualified = False
elif 'fid' in item and item['fid'] > opt.fid:
qualified = False
elif 'mIoU' in item and item['mIoU'] < opt.mIoU:
qualified = False
if qualified:
print(item)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='An auxiliary script to read the parse the output pickle and select the configurations you want.')
parser.add_argument('--pkl_path', type=str, required=True, help='the input .pkl file path')
parser.add_argument('--macs', type=float, default=5.68e9, help='the MACs threshold')
parser.add_argument('--fid', type=float, default=-1, help='the FID threshold')
parser.add_argument('--mIoU', type=float, default=1e18, help='the mIoU threshold')
opt = parser.parse_args()
main(opt)