Skip to content

Instantly share code, notes, and snippets.

View longside's full-sized avatar
🏠
Working from home

sunyajing longside

🏠
Working from home
  • Southeast University
  • china jiangsu nanjing
View GitHub Profile
@CasiaFan
CasiaFan / tf_model_post_training_quantization.py
Last active June 14, 2022 08:15
post-training quantization tensorflow model to float16
import tensorflow as tf
from tensorflow.core.framework import types_pb2, graph_pb2, attr_value_pb2
from tensorflow.tools.graph_transforms import TransformGraph
from google.protobuf import text_format
import numpy as np
# object detection api input and output nodes
input_name = "image_tensor"
output_names = ["detection_boxes", "detection_classes", "detection_scores", "num_detections"]
# Const should be float32 in object detection api during nms (see here: https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/non-max-suppression-v4.html)