def __init__(self, model_directory):
    model_path = os.path.join(model_directory, 'frozen_inference_graph.pb')
    labelmap_path = os.path.join(model_directory, 'labelmap.pbtxt')
    self.num_classes = 5
    self.label_map = label_map_util.load_labelmap(labelmap_path)
    self.categories = label_map_util.convert_label_map_to_categories(self.label_map, max_num_classes=self.num_classes, use_display_name=True)
    self.category_index = label_map_util.create_category_index(self.categories)
    self.detection_graph = tf.Graph()
    with self.detection_graph.as_default():
        self.od_graph_def = tf.GraphDef()
        with tf.gfile.GFile(model_path, 'rb') as fid:
            self.serialized_graph = fid.read()
            self.od_graph_def.ParseFromString(self.serialized_graph)
        tf.import_graph_def(self.od_graph_def, name='')
        self.sess = tf.Session(graph=self.detection_graph)
        self.image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
        self.detection_boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
        self.detection_scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
        self.detection_classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
        self.num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')
def __init__(self, model_directory):
    model_path = os.path.join(model_directory, 'frozen_inference_graph.pb')
    labelmap_path = os.path.join(model_directory, 'labelmap.pbtxt')
    self.num_classes = 5
    self.label_map = label_map_util.load_labelmap(labelmap_path)
    self.categories = label_map_util.convert_label_map_to_categories(self.label_map, max_num_classes=self.num_classes, use_display_name=True)
    self.category_index = label_map_util.create_category_index(self.categories)
    self.detection_graph = tf.Graph()
    with self.detection_graph.as_default():
        self.od_graph_def = tf.GraphDef()
        with tf.gfile.GFile(model_path, 'rb') as fid:
            self.serialized_graph = fid.read()
            self.od_graph_def.ParseFromString(self.serialized_graph)
        tf.import_graph_def(self.od_graph_def, name=)
        self.sess = tf.Session(graph=self.detection_graph)
        self.image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0')
        self.detection_boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0')
        self.detection_scores = self.detection_graph.get_tensor_by_name('detection_scores:0')
        self.detection_classes = self.detection_graph.get_tensor_by_name('detection_classes:0')
        self.num_detections = self.detection_graph.get_tensor_by_name('num_detections:0')