简体   繁体   English

Tensorflow可以混洗多个分片的TFrecord二进制文件以进行对象检测训练吗?

[英]Can Tensorflow shuffle multiple sharded TFrecord binaries for object detection training?

I am trying to train a FasterRCNN model with the Object Detection API. 我正在尝试使用对象检测API训练FasterRCNN模型。

I have a dataset of 5 classes (truck, car, van, boat, and bike), with about 1000 images each. 我有一个5类的数据集(卡车,汽车,货车,船和自行车),每类约有1000张图像。 Each class has its own TFrecord file, sharded into 10 pieces. 每个类都有自己的TFrecord文件,分为10个部分。 This gives me a total of 50 files, which look something like this: 这总共给了我50个文件,看起来像这样:

  • truck_train.record-00000-of-00010 truck_train.record 00000-OF-00010
  • car_train.record-00000-of-00010 car_train.record 00000-OF-00010
  • van_train.record-00000-of-00010 van_train.record 00000-OF-00010
  • boat_train.record-00000-of-00010 boat_train.record 00000-OF-00010
  • bike_train.record-00000-of-00010 bike_train.record 00000-OF-00010

Can I configure my training pipeline such that Tensorflow opens and shuffles the contents of these files randomly? 我可以配置训练管道以使Tensorflow随机打开并随机播放这些文件的内容吗?

I am aware that I could simply re-generate the TFrecord files from scratch and mix my data that way, but my intent here is to be able to add classes to my dataset by simply adding the TFrecord files containing a new class. 我知道我可以简单地从头开始重新生成TFrecord文件并以这种方式混合我的数据,但是我的目的是能够通过简单地添加包含新类的TFrecord文件来向我的数据集添加类。

Having read this older answer on shuffling, I wonder if there is a built-in way that Tensorflow could implement a shuffle queue, even if it means splitting my TFrecords files into 100 shards instead of 10. 阅读了关于混洗的较早答案之后,我想知道Tensorflow是否有一种内置的方法可以实现混洗队列,即使这意味着将我的TFrecords文件拆分为100个分片(而不是10个)。

I am using a modified sample .config file for FasterRCNN, but I envision issues if Tensorflow opens only one .record file at a time, as each file contains only a single class. 我正在为FasterRCNN使用修改后的示例.config文件 ,但我预想到了Tensorflow一次只打开一个.record文件的问题,因为每个文件仅包含一个类。

I am aware that the tf_record_input_reader can receive a list of files: 我知道tf_record_input_reader可以接收文件列表:

train_input_reader: {
  tf_record_input_reader {
    input_path: ["Datasets\train-1.record", "Datasets\train-2.record"]
  }

By increasing the size of the shuffle buffer and num_readers of input readers, will train.py have sufficient randomization of data? 通过增加shuffle buffer和输入阅读器的num_readers的大小, num_readers将具有足够的数据随机性吗?

Such a config should be fine: 这样的配置应该没问题:

train_input_reader: {
  tf_record_input_reader {
    input_path: "Datasets\train-1.record"
    input_path: "Datasets\train-2.record"
    ...
    input_path: "Datasets\train-10.record"
  }
  shuffle: True
}

Or simply: 或者简单地:

train_input_reader: {
  tf_record_input_reader {
    input_path: "Datasets\*.record"
  }
  shuffle: True
}

However, the default value for shuffle is anyway True, so it is only for verbosity. 但是, shuffle默认值始终为True,因此仅用于冗长。

The default value for num_readers is 64 and for filenames_shuffle_buffer_size is 100, so for the 50 files you have it must be enough. num_readers的默认值为64, filenames_shuffle_buffer_size的默认值为100,因此对于50个文件,它必须足够。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM