74134d1edd57c411538bfb2fb7fddfb7.jpeg
  • 安裝相關套件
    pip install glob2
    pip install opencv-python
  • 下載相關使用到的 model
    # FROM models/research/object_detection
    wget http://download.tensorflow.org/models/object_detection/faster_rcnn_inception_v2_coco_2018_01_28.tar.gz
    tar -zxvf faster_rcnn_inception_v2_coco_2018_01_28.tar.gz
  • TFRecordWriter
    透過 TFRecordWriter 產生 train.record / eval.record
    產生的方式可以參考
    def create_tf_example(ex):
    
    
      height = ex['height']
      width = ex['width']
      filename = ex['filename']
      image_format = ex['image_format']
      xmins = ex['xmins']
      xmaxs = ex['xmaxs']
      ymins = ex['ymins']
      ymaxs = ex['ymaxs']
      classes_text = ex['classes_text']
      classes = ex['classes']
    
      print(classes_text)
      print(classes)
    
      tf_example = tf.train.Example(features=tf.train.Features(feature={
        'image/height': dataset_util.int64_feature(height),
        'image/width': dataset_util.int64_feature(width),
        'image/filename': dataset_util.bytes_feature(filename),
        'image/source_id': dataset_util.bytes_feature(filename),
        'image/format': dataset_util.bytes_feature(image_format),
        'image/object/bbox/xmin': dataset_util.float_list_feature(xmins),
        'image/object/bbox/xmax': dataset_util.float_list_feature(xmaxs),
        'image/object/bbox/ymin': dataset_util.float_list_feature(ymins),
        'image/object/bbox/ymax': dataset_util.float_list_feature(ymaxs),
        'image/object/class/text': dataset_util.bytes_list_feature(str(classes_text)),
        'image/object/class/label': dataset_util.int64_list_feature(classes),
      }))
    
    
      return tf_example
回應
訪客如要回應,請先 登入