Tensorflow下使用SSD训练自己的数据集

Tensorflow下使用SSD训练自己的数据集

1、数据集格式转换

① 将自己的数据集做成VOC2007格式,直接将VOC2007文件夹粘贴到SSD-Tensorflow-master目录下。

② 修改datasets文件夹中pascalvoc_common.py文件中的训练类。

#原始的
# VOC_LABELS = {
#     'none': (0, 'Background'),
#     'aeroplane': (1, 'Vehicle'),
#     'bicycle': (2, 'Vehicle'),
#     'bird': (3, 'Animal'),
#     'boat': (4, 'Vehicle'),
#     'bottle': (5, 'Indoor'),
#     'bus': (6, 'Vehicle'),
#     'car': (7, 'Vehicle'),
#     'cat': (8, 'Animal'),
#     'chair': (9, 'Indoor'),
#     'cow': (10, 'Animal'),
#     'diningtable': (11, 'Indoor'),
#     'dog': (12, 'Animal'),
#     'horse': (13, 'Animal'),
#     'motorbike': (14, 'Vehicle'),
#     'person': (15, 'Person'),
#     'pottedplant': (16, 'Indoor'),
#     'sheep': (17, 'Animal'),
#     'sofa': (18, 'Indoor'),
#     'train': (19, 'Vehicle'),
#     'tvmonitor': (20, 'Indoor'),
# }

#修改后的
VOC_LABELS = {
    'none': (0, 'Background'),
    'gun': (1, 'gun'),
    'knife': (2, 'knife'),
}

③ 修改datasets文件夹中的pascalvoc_to_tfrecords.py文件。

修改文件的83行读取方式为’rb‘,如果你的文件不是.jpg格式,也可以修改图片的类型。

    # Read the image file.
    filename = directory + DIRECTORY_IMAGES + name + '.jpg'
    image_data = tf.gfile.FastGFile(filename, 'rb').read()

修改文件的67行,设置将几张图片转为一个tfrecords。

# TFRecords convertion parameters.
RANDOM_SEED = 4242
SAMPLES_PER_FILES = 1 # 一张图片转为一个tfrecords

④ 在SSD-Tensorflow-master目录下创建tfrecords_文件夹,做

评论 68
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值