Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import tensorflow as tf
  2.  
  3.  
  4. model_file = "frozen_har1.pb"
  5.  
  6. def load_graph(pbmodelFile):
  7. with tf.gfile.GFile(pbmodelFile, "rb") as f:
  8. graph_def = tf.GraphDef()
  9. graph_def.ParseFromString(f.read())
  10.  
  11. with tf.Graph().as_default() as graph:
  12. tf.import_graph_def(graph_def)
  13.  
  14. input_name = graph.get_operations()[0].name+':0'
  15. output_name = graph.get_operations()[-1].name+':0'
  16.  
  17. return graph, input_name, output_name
  18.  
  19.  
  20. graph, inputName, outputName = load_graph(model_file)
  21. input_tensor = graph.get_tensor_by_name(inputName)
  22. output_tensor = graph.get_tensor_by_name(outputName)
  23.  
  24. print(input_tensor)
  25. print(output_tensor)
  26.  
  27. converter = tf.lite.TFLiteConverter.from_frozen_graph(model_file, ["input"], ["y_"])
  28.  
  29. tflite_model = converter.convert()
  30. open("fallDetection2.tflite", "wb").write(tflite_model)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement