This file contains hidden or 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
| Status LoadGraph(const string& graph_file_name, | |
| std::unique_ptr<tensorflow::Session>* session) { | |
| tensorflow::GraphDef graph_def; | |
| Status load_graph_status = | |
| ReadBinaryProto(tensorflow::Env::Default(), graph_file_name, &graph_def); | |
| if (!load_graph_status.ok()) { | |
| return tensorflow::errors::NotFound("Failed to load compute graph at '", | |
| graph_file_name, "'"); | |
| } | |
| session->reset(tensorflow::NewSession(tensorflow::SessionOptions())); |
This file contains hidden or 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
| Mat frame; | |
| frame=imread("./cara.jpg"); | |
| Tensor inputImg(tensorflow::DT_UINT8, tensorflow::TensorShape({1,frame.rows,frame.cols,3})); | |
| uint8_t *p = inputImg.flat<tensorflow::uint8>().data(); | |
| Mat cameraImg(frame.rows, frame.cols, CV_8UC3, p); | |
| frame.convertTo(cameraImg, CV_8UC3); |
This file contains hidden or 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
| bazel-bin/tensorflow/contrib/lite/toco/toco -- \ | |
| --input_file=./model_files/frozen_output.pb \ | |
| --input_format=TENSORFLOW_GRAPHDEF --output_format=TFLITE \ | |
| --output_file=./model_files/icnet_model.lite --inference_type=FLOAT \ | |
| --input_type=FLOAT --input_arrays=input \ | |
| --output_arrays=Reshape_1 --input_shapes=1,1024,2048,3 |
This file contains hidden or 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
| writer = tf.summary.FileWriter("parking_log", sess.graph) |
This file contains hidden or 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
| bazel-bin/tensorflow/python/tools/freeze_graph\ | |
| --input_graph=./model_files/output.pb \ | |
| --input_checkpoint=./model_files/model.ckpt \ | |
| --input_binary=true --output_graph=./model_files/frozen_output.pb \ | |
| --output_node_names=Reshape_1 |
This file contains hidden or 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
| bazel-bin/tensorflow/tools/graph_transforms/transform_graph \ | |
| --in_graph=./face/frozen_inference_graph_face.pb \ | |
| --out_graph=./face/quantized_graph_face.pb \ | |
| --inputs=image_tensor \ | |
| --outputs='detection_boxes,detection_scores,detection_classes,num_detections' \ | |
| --transforms='add_default_attributes strip_unused_nodes(type=float, shape="-1,-1,-1,3") | |
| remove_nodes(op=Identity, op=CheckNumerics) fold_constants(ignore_errors=true) | |
| fold_batch_norms fold_old_batch_norms quantize_weights quantize_nodes | |
| strip_unused_nodes sort_by_execution_order' |
This file contains hidden or 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
| bazel-bin/tensorflow/tools/graph_transforms/transform_graph \ | |
| --in_graph=./frozen_inference_graph_face.pb \ | |
| --out_graph=./quantized_graph_face.pb \ | |
| --inputs=image_tensor \ | |
| --outputs='detection_boxes,detection_scores,detection_classes,num_detections' \ | |
| --transforms='quantize_weights sort_by_execution_order' |