forked from intel/neural-compressor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
27 lines (22 loc) · 949 Bytes
/
test.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
import tensorflow as tf
from argparse import ArgumentParser
tf.compat.v1.disable_eager_execution()
import numpy as np
def main():
arg_parser = ArgumentParser(description='Parse args')
arg_parser.add_argument('--benchmark', action='store_true', help='run benchmark')
arg_parser.add_argument('--tune', action='store_true', help='run tuning')
args = arg_parser.parse_args()
if args.tune:
from neural_compressor.experimental import Quantization, common
quantizer = Quantization('./conf.yaml')
quantizer.model = common.Model("./mobilenet_v1_1.0_224_frozen.pb")
quantized_model = quantizer.fit()
quantized_model.save('./int8.pb')
if args.benchmark:
from neural_compressor.experimental import Benchmark, common
evaluator = Benchmark('./conf.yaml')
evaluator.model = common.Model('int8.pb')
evaluator(mode='accuracy')
if __name__ == "__main__":
main()