Skip to content

Commit 35319fb

Browse files
committed
Add check script to saved model file
1 parent c65ee7f commit 35319fb

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

check_saved_model/check.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
import tensorflow as tf
4+
5+
6+
def main():
7+
test_file_path = "../models/tensorflow_template_application_model/1"
8+
is_saved_model = check_saved_model(test_file_path)
9+
if is_saved_model:
10+
print("{} is the saved model".format(test_file_path))
11+
else:
12+
print("{} is NOT the saved model".format(test_file_path))
13+
14+
15+
def check_saved_model(model_file_path):
16+
try:
17+
session = tf.Session(graph=tf.Graph())
18+
meta_graph = tf.saved_model.loader.load(
19+
session, [tf.saved_model.tag_constants.SERVING], model_file_path)
20+
return True
21+
except IOError as ioe:
22+
print("Catch exception: ".foramt(ioe))
23+
return False
24+
25+
26+
if __name__ == "__main__":
27+
main()

0 commit comments

Comments
 (0)