简体   繁体   English

Tensorflow可变图像单个批次内的大小

[英]Tensorflow variable images size within single batch

I am currently implementing FCN in tensorflow that enables variable input image size. 我目前正在tensorflow中实现FCN,它可以实现可变的输入图像大小。

I have images of really various image sizes, but unfortunately I am not able to start the training with batch size different than 1. 我有各种图像尺寸的图像,但不幸的是,我无法以不同于1的批量大小开始培训。

I am using the feed dict in a following way: 我以下列方式使用feed dict:

feed_dict = {fcn.images: image_batch,
             fcn.labels: labels_batch,
             fcn.dropout_keep: dropout}
result = sess.run(list(tf_ops), feed_dict=feed_dict)

I have already tried: 我已经尝试过了:

  1. Creating image_batch and labels_batch as numpy array, this however does not work since numpy arrays does not support variable certain dimensions. 创建image_batchlabels_batch作为numpy的阵列,然而,这并不因为numpy的阵列工作不支持可变某些尺寸。
  2. Creating image_batch and labels_batch as list of numpy arrays. 创建image_batchlabels_batch作为numpy的数组列表。 Here seems that tensorflow is trying to call numpy.array(image_batch) . 看来tensorflow试图调用numpy.array(image_batch)
  3. Going with tf.pack() , this unfortunately does not support different image sizes as well tf.pack() ,遗憾的是它不支持不同的图像大小

My question is: Is there a way how to solve this problem? 我的问题是:有没有办法解决这个问题?

Thank you in advance for any suggestions and advices. 提前感谢您提出任何建议和意见。

So we can close this - quoting Olivier Moindrot above: 所以我们可以关闭这个 - 引用上面的Olivier Moindrot:

You have to pad or resize all your images to the same size before batching them. 在批量处理之前,您必须将所有图像填充或调整为相同的大小。

Note that after Olivier's answer, there was a new tf.image.decode_and_crop_jpeg op added that can make it a bit easier to do this. 请注意,在Olivier的回答之后,添加了一个新的tf.image.decode_and_crop_jpeg操作,可以使它更容易实现。

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

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