1.3 label_map.pbtxt文件
xx_label_map.pbtxt
文件中的内容如下:
item {
id: 1
name: 'Abyssinian'
}
item {
id: 2
name: 'american_bulldog'
}
item {
id: 3
name: 'american_pit_bull_terrier'
}
1.4 创建tf_record文件
先创建一个create_xx_tf_record.py
文件,单独用来处理训练数据。可以直接从object_detection工程下的create_pacal_tf_record.py
(如果是每个图片只有一个分类,可以使用create_pet_tf_record.py
)复制而来。
修改起始参数配置:
- data_dir: 数据目录,包含了图片和标注的目录
- output_dir:输出目录,图片转换为tf_record之后存储的位置
- label_map_path:上面提到的xx_label_map.pbtxt
修改dict_to_tf_example
参考你的标准xml文件,有些地方需要修改。
修改main
确保你的标注文件,图片目录对应的目录。标注文件目录下是否存在 trainval.txt
文件是否存在,这个需要自己生成。我生成的列表(注意:没有带后缀)为:
执行完之后会在对应目录下生成 tf_record文件。
我的文件:
# 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 s