-
Notifications
You must be signed in to change notification settings - Fork 18
/
model_compression.py
29 lines (21 loc) · 1.12 KB
/
model_compression.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
import tensorflow as tf
from tf_pose.networks import get_network
#######################################################################################
### $ python3 model_compression.py
#######################################################################################
def main():
graph = tf.Graph()
with graph.as_default():
input_node = tf.placeholder(tf.float32, shape=(1, 368, 432, 3), name='image')
net, pretrain_path, last_layer = get_network("mobilenet_v2_1.4", input_node, None, False)
#net, pretrain_path, last_layer = get_network("mobilenet_v2_small", input_node, None, False)
saver = tf.train.Saver(tf.global_variables())
sess = tf.Session()
sess.run(tf.global_variables_initializer())
sess.run(tf.local_variables_initializer())
saver.restore(sess, 'models/train/test/model-19021')
saver.save(sess, 'models/train/test/model-final-19021')
graphdef = graph.as_graph_def()
tf.train.write_graph(graphdef, 'models/train/test', 'model-final.pbtxt', as_text=True)
if __name__ == '__main__':
main()