<p>The model weights were ported from caffe, so it's in <a href="https://github.com/BVLC/caffe/wiki/Image-Format:-BGR-not-RGB" rel="noreferrer">BGR format</a>.</p>

<blockquote>
  <p>Caffe uses a BGR color channel scheme for reading image files. This is
  due to the underlying OpenCV implementation of imread. The assumption
  of RGB is a common mistake.</p>
</blockquote>

<p>You can find the original caffe model weight files <a href="http://www.robots.ox.ac.uk/~vgg/research/very_deep/" rel="noreferrer">on VGG website</a>. This link can also be found on Keras documentation.</p>

<p>I think the second range would be the closest one. There's no scaling during training, but the authors have subtracted the mean value of the ILSVRC2014 training set. As stated in <a href="https://arxiv.org/pdf/1409.1556.pdf" rel="noreferrer">the original VGG paper</a>, section 2.1:</p>

<blockquote>
  <p>The only preprocessing we do is subtracting the mean RGB value,
  computed on the training set, from each pixel.</p>
</blockquote>

<p>This sentence is actually what <code>imagenet_utils.preprocess_input(mode='caffe')</code> does.</p>

<ol>
<li>Convert from RGB to BGR: because <code>keras.preprocessing.image.load_img()</code> loads images in RGB format, this conversion is required for VGG16 (and all models ported from caffe).</li>
<li>Subtract the mean BGR values: <code>(103.939, 116.779, 123.68)</code> is subtracted from the image array.</li>
</ol>

<p>The preprocessor is not used in <code>vgg16.py</code>. It's imported in the file so that users can use the preprocess function by calling <code>keras.applications.vgg16.preprocess_input(rgb_img_array)</code>, without caring about where model weights come from. The argument for <code>preprocess_input()</code> is always an image array in RGB format. If the model was trained with caffe, <code>preprocess_input()</code> will convert the array into BGR format.</p>

<p>Note that the function <code>preprocess_input()</code> is not intended to be called from <code>imagenet_utils</code> module. If you are using VGG16, call <code>keras.applications.vgg16.preprocess_input()</code> and the images will be converted to a suitable format and range that VGG16 was trained on. Similarly, if you are using Inception V3, call <code>keras.applications.inception_v3.preprocess_input()</code> and the images will be converted to the range that Inception V3 was trained on. </p>
What is the expected input range for working with Keras VGG models?
<p>I'm trying to use a pretrained VGG 16 from keras. But I'm really unsure about what the input range should be.   </p>

<p>Quick answer, which of these color orders?</p>

<ul>
<li>RGB   </li>
<li>BGR</li>
</ul>

<p>And which range? </p>

<ul>
<li>0 to 255?</li>
<li>balanced from about -125 to about +130?</li>
<li>0 to 1?</li>
<li>-1 to 1?</li>
</ul>

<p>I notice <a href="https://github.com/fchollet/keras/blob/master/keras/applications/vgg16.py" rel="noreferrer">the file where the model is defined</a> imports an input preprocessor:</p>

<pre><code>from .imagenet_utils import preprocess_input
</code></pre>

<p>But this preprocessor is never used in the rest of the file.</p>

<p>Also, when I check the <a href="https://github.com/fchollet/keras/blob/master/keras/applications/imagenet_utils.py/#L11" rel="noreferrer">code for this preprocessor</a>, it has two modes: <code>caffe</code> and <code>tf</code> (tensorflow).    </p>

<p>Each mode works differently. </p>

<p>Finally, I can't find consistent documentation on the internet. </p>

<p>So, what is the best range for working? To what range are the model weights trained?</p>