Caffe:可变的输入图像大小 [英] Caffe: variable input-image size

查看:366
本文介绍了Caffe:可变的输入图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Caffe的Google的 deepdream代码
他们使用由ModelZoo提供的ImageNet上预先训练的GoogLeNet模型。这意味着该网络是在裁剪为224x224像素大小的图像上进行训练的。来自 train_val.prototext

I am trying out Google's deepdream code which makes use of Caffe. They use the GoogLeNet model pre-trained on ImageNet, as provided by the ModelZoo. That means the network was trained on images cropped to the size 224x224 pixel. From the train_val.prototext:

layer {            
  name: "data"     
  type: "Data"     
  ...

  transform_param {
     mirror: true   
     crop_size: 224
  ... 

使用的 deploy.prototext 为了进行处理,还定义了一个尺寸为224x224x3x10的输入层(RGB图像的尺寸为224x224,批处理大小为10)。

The deploy.prototext used for processing also defines an input layer with the size of 224x224x3x10 (RGB images of size 224x224, batchsize 10).

name: "GoogleNet"
input: "data"
input_shape {
  dim: 10
  dim: 3
  dim: 224
  dim: 224
}

但是我可以使用该网来处理任何大小的图像(上面的示例使用了1024x574像素之一)。

However I can use this net to process images of any size (the example above used one of 1024x574 pixel).


  1. deploy.prototext 并未将caffe配置为使用裁剪。

  2. deepdream代码仅能伪造,也不能在此处裁剪

  1. deploy.prototext does not configure caffe to use cropping.
  2. The preprocessing in the deepdream code only does demeaning, also no cropping here

我怎么可能在对输入图层来说太大的图像上运行?

How is it possible that I can run on images which are too big for the input layer?

完整的代码可以在此处找到p>

complete code can be found here

推荐答案

DeepDream根本不会裁剪输入图像。

如果密切注意,您会注意到它在中间层上运行:它的 end = 参数设置为'inception_4c / output' end ='inception_3b / 5x5_reduce',但切勿 end ='loss3 / classifier'。原因是到这些层的GoogLeNet是一个全卷积网络,也就是说,它可以拍摄任何大小的输入图像,并生成与输入大小成比例的输出(输出大小为

DeepDream does not crop the input image at all.
If you pay close attention you'll notice that it operates on a mid-level layer: it's end= argument is set to 'inception_4c/output' or end='inception_3b/5x5_reduce', but NEVER end='loss3/classifier'. The reason for this is that the GoogLeNet up to these layers is a fully-convolutional net, that is, it can take any sized input image and produce outputs of sizes proportional to the input size (output size is usually affected by conv padding and pooling).

要将网络调整为输入的不同大小,请使用功能 deepdream

To adjust the net to the different sizes of inputs the function deepdream has the line

src.reshape(1,3,h,w) # resize the network's input image size

此行调整网的层以适应形状为(1,3,h,w )

This line adjusts the net's layers to accommodate input of shape (1,3,h,w).

这篇关于Caffe:可变的输入图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆