资源简介

基于tensorflow深度学习框架,采用python语言编写代码,实现基于深度学习的目标检测程序

资源截图

代码片段和文件信息

# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License Version 2.0 (the “License“);
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing software
# distributed under the License is distributed on an “AS IS“ BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

r“““Convert raw PASCAL dataset to TFRecord for object_detection.

Example usage:
    ./create_pascal_tf_record --data_dir=/home/user/VOCdevkit \
        --year=VOC2012 \
        --output_path=/home/user/pascal.record
“““
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import hashlib
import io
import logging
import os

from lxml import etree
import PIL.Image
import tensorflow as tf

from object_detection.utils import dataset_util
from object_detection.utils import label_map_util


flags = tf.app.flags
flags.DEFINE_string(‘data_dir‘ ‘‘ ‘Root directory to raw PASCAL VOC dataset.‘)
flags.DEFINE_string(‘set‘ ‘train‘ ‘Convert training set validation set or ‘
                    ‘merged set.‘)
flags.DEFINE_string(‘annotations_dir‘ ‘Annotations‘
                    ‘(Relative) path to annotations directory.‘)
flags.DEFINE_string(‘year‘ ‘VOC2007‘ ‘Desired challenge year.‘)
flags.DEFINE_string(‘output_path‘ ‘‘ ‘Path to output TFRecord‘)
flags.DEFINE_string(‘label_map_path‘ ‘data/pascal_label_map.pbtxt‘
                    ‘Path to label map proto‘)
flags.DEFINE_boolean(‘ignore_difficult_instances‘ False ‘Whether to ignore ‘
                     ‘difficult instances‘)
FLAGS = flags.FLAGS

SETS = [‘train‘ ‘val‘ ‘trainval‘ ‘test‘]
YEARS = [‘VOC2007‘ ‘VOC2012‘ ‘merged‘]


def dict_to_tf_example(data
                       dataset_directory
                       label_map_dict
                       ignore_difficult_instances=False
                       image_subdirectory=‘JPEGImages‘):
  “““Convert xml derived dict to tf.Example proto.

  Notice that this function normalizes the bounding box coordinates provided
  by the raw data.

  Args:
    data: dict holding PASCAL xml fields for a single image (obtained by
      running dataset_util.recursive_parse_xml_to_dict)
    dataset_directory: Path to root directory holding PASCAL dataset
    label_map_dict: A map from string label names to integers ids.
    ignore_difficult_instances: Whether to skip difficult instances in the
      dataset  (default: False).
    image_subdirectory: String specifying subdirectory within the
      PASCAL dataset directory holding the actual image data.

  Returns:
    example: The converted tf.Example.

  Raises:
    V

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-07-22 02:35  chapter_5\
     文件        3475  2018-07-22 02:35  chapter_5\README.md
     目录           0  2018-07-22 02:35  chapter_5\research\
     目录           0  2018-07-22 02:35  chapter_5\research\slim\
     文件       20014  2018-07-22 02:35  chapter_5\research\slim\train_image_classifier.py
     文件       46294  2018-07-22 02:35  chapter_5\research\slim\slim_walkthrough.ipynb
     文件         231  2018-07-22 02:35  chapter_5\research\slim\setup.py
     文件        1397  2018-07-22 02:35  chapter_5\research\slim\export_inference_graph_test.py
     文件        4658  2018-07-22 02:35  chapter_5\research\slim\export_inference_graph.py
     文件        6666  2018-07-22 02:35  chapter_5\research\slim\eval_image_classifier.py
     文件        2306  2018-07-22 02:35  chapter_5\research\slim\download_and_convert_data.py
     文件           0  2018-07-22 02:35  chapter_5\research\slim\__init__.py
     文件           0  2018-07-22 02:35  chapter_5\research\slim\WORKSPACE
     文件       24026  2018-07-22 02:35  chapter_5\research\slim\README.md
     文件        9842  2018-07-22 02:35  chapter_5\research\slim\BUILD
     目录           0  2018-07-22 02:35  chapter_5\research\object_detection\
     文件        6550  2018-07-22 02:35  chapter_5\research\object_detection\trainer_test.py
     文件       12592  2018-07-22 02:35  chapter_5\research\object_detection\trainer.py
     文件        7307  2018-07-22 02:35  chapter_5\research\object_detection\train.py
     文件        9358  2018-07-22 02:35  chapter_5\research\object_detection\object_detection_tutorial.ipynb
     文件       25563  2018-07-22 02:35  chapter_5\research\object_detection\exporter_test.py
     文件       15091  2018-07-22 02:35  chapter_5\research\object_detection\exporter.py
     文件        4488  2018-07-22 02:35  chapter_5\research\object_detection\export_inference_graph.py
     文件        9119  2018-07-22 02:35  chapter_5\research\object_detection\evaluator.py
     文件       24890  2018-07-22 02:35  chapter_5\research\object_detection\eval_util.py
     文件        6044  2018-07-22 02:35  chapter_5\research\object_detection\eval.py
     文件        7838  2018-07-22 02:35  chapter_5\research\object_detection\create_pet_tf_record.py
     文件        3952  2018-07-22 02:35  chapter_5\research\object_detection\create_pascal_tf_record_test.py
     文件        7019  2018-07-22 02:35  chapter_5\research\object_detection\create_pascal_tf_record.py
     文件           0  2018-07-22 02:35  chapter_5\research\object_detection\__init__.py
     文件        4517  2018-07-22 02:35  chapter_5\research\object_detection\README.md
............此处省略303个文件信息

评论

共有 条评论