TensorFlow 对象检测 API - 内存不足

2024-03-29

我正在使用 Tensorflow 对象检测 API 来训练我自己的对象检测器。我下载了faster_rcnn_inception_v2_coco_2018_01_28来自模型动物园(here https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md),并制作了我自己的数据集(train.record (~221Mo)、test.record 和标签图)来对其进行微调。

但是当我运行它时:

python train.py --logtostderr --pipeline_config_path=/home/username/Documents/Object_Detection/training/faster_rcnn_inception_v2_coco_2018_01_28/pipeline.config --train_dir=/home/username/Documents/Object_Detection/training/

该进程在填充 shuffle buffer 操作期间被终止,看起来像 OOM 问题(16Go RAM)...

2018-06-07 12:02:51.107021: I tensorflow/core/kernels/data/shuffle_dataset_op.cc:94] Filling up shuffle buffer (this may take a while): 410 of 2048
Process stopped

是否存在减少洗牌缓冲区大小的方法?其大小受什么影响?

然后,我添加一些交换(115Go 交换 + 16Go RAM),并且填充洗牌缓冲区操作完成,但我的训练在第 4 步后占用了所有 RAM 和交换,而我的 train.record 大约只有 221 Mo !

我已经将这些行添加到我的 pipeline.config > train_config 中:

batch_size: 1
batch_queue_capacity: 10
num_batch_queue_threads: 8
prefetch_queue_capacity: 9

这些到我的 pipeline.config > train_input_reader :

queue_capacity: 2
min_after_dequeue: 1
num_readers: 1

按照此post https://github.com/tensorflow/models/issues/1817.

我知道我的图像非常(非常非常)大:每个 25Mo,但由于我只拍摄了 9 张图像来制作我的 train.record(只是为了测试我的安装是否顺利),它不应该如此消耗内存,对吧?

关于为什么它使用这么多内存还有其他想法吗?

(顺便说一句,我只使用CPU)


图像数量不是问题。问题是您的输入图像分辨率(在您的设置 .config 文件中)。您需要在此处更改高度和宽度值(与您的 .config 文件中类似):

image_resizer {
  # TODO(shlens): Only fixed_shape_resizer is currently supported for NASNet
  # featurization. The reason for this is that nasnet.py only supports
  # inputs with fully known shapes. We need to update nasnet.py to handle
  # shapes not known at compile time.
  fixed_shape_resizer {
    height: 1200
    width: 1200
  }
}

设置较小的宽度和高度值,您将能够完美训练。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

TensorFlow 对象检测 API - 内存不足 的相关文章

随机推荐