Created
July 18, 2020 16:28
-
-
Save gauravgola96/3dd71b7f634b60969b60aef9ae8d82e3 to your computer and use it in GitHub Desktop.
Yolov2_export_tfserving
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import tensorflow as tf | |
from tensorflow.python.saved_model import builder as saved_model_builder | |
from darkflow.net.build import TFNet | |
options = {"model": "yolov2-tiny.cfg", "load": "yolov2-tiny.weights", "threshold": 0.1} | |
tfnet = TFNet(options) | |
export_path = "./export/1/" | |
tfnet.build_model(export_path = export_path) | |
with tfnet.sess.graph.as_default(): | |
prediction_signature = tf.saved_model.signature_def_utils.build_signature_def( | |
inputs={ | |
"input": tf.saved_model.utils.build_tensor_info(x) | |
}, | |
outputs={ | |
"output": tf.saved_model.utils.build_tensor_info(pred) | |
}, | |
method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME | |
) | |
builder = saved_model_builder.SavedModelBuilder(export_path) | |
builder.add_meta_graph_and_variables( | |
tfnet.sess, [tf.saved_model.tag_constants.SERVING], | |
signature_def_map={ | |
"predict": prediction_signature, | |
}) | |
builder.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment