コード例 #1
0
 def load_category_index(self):
     """
     creates categorie_index from label_map
     """
     print('> Loading label map')
     label_map = tf_utils.load_labelmap(self.config.LABEL_PATH)
     categories = tf_utils.convert_label_map_to_categories(
         label_map,
         max_num_classes=self.config.NUM_CLASSES,
         use_display_name=True)
     self.category_index = tf_utils.create_category_index(categories)
コード例 #2
0
 def load_labelmap(self):
     print('> Loading label map')
     label_map = tf_utils.load_labelmap(self.label_path)
     categories = tf_utils.convert_label_map_to_categories(label_map, max_num_classes=self.num_classes, use_display_name=True)
     self.category_index = tf_utils.create_category_index(categories)
コード例 #3
0
"""
https://github.com/opencv/opencv/wiki/TensorFlow-Object-Detection-API
https://github.com/EdjeElectronics/TensorFlow-Object-Detection-on-the-Raspberry-Pi/blob/master/Object_detection_picamera.py
"""

MODEL_NAME = 'ssdlite_mobilenet_v2_coco_2018_05_09'
# MODEL_NAME = 'ssd_mobilenet_v1_0.75_depth_300x300_coco14_sync_2018_07_03'
# MODEL_NAME = 'ssd_mobilenet_v1_ppn_shared_box_predictor_300x300_coco14_sync_2018_07_03'
CWD_PATH = os.getcwd()
PATH_TO_CKPT = os.path.join(CWD_PATH, 'data/model', MODEL_NAME, 'frozen_inference_graph.pb')
IMG_NAME = random.choice(os.listdir('data/test_img'))
IMG_PATH = os.path.join('data/test_img', IMG_NAME)
LABELS_PATH = os.path.join(CWD_PATH,'protos','mscoco_label_map.pbtxt')
NUM_CLASSES = 90

label_map = tf_utils.load_labelmap(LABELS_PATH)
categories = tf_utils.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)
category_index = tf_utils.create_category_index(categories)

# print(label_map)
# print(categories)
# print(category_index)

with tf.gfile.FastGFile(PATH_TO_CKPT, 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    
    
with tf.Session() as sess:
    # Restore session
    sess.graph.as_default()
コード例 #4
0
ファイル: model.py プロジェクト: zds0/objectdetection_ros
 def load_labelmap(self):
     print('> Loading label map')
     label_map = tf_utils.load_labelmap(self.label_path)
     categories = tf_utils.convert_label_map_to_categories(
         label_map, max_num_classes=self.num_classes, use_display_name=True)
     self.category_index = tf_utils.create_category_index(categories)