title: NameError: name 'image' is not defined
body: <p>I am getting the error in the post title when I attempt to run a pretrained MobileNet classification. The image I am using to run the script is located in my 'MobileNet-inference-images/American_Cam.jpg directory.</p>
  
  <p>Any help or advice would be appreciated.</p>
  
  <p>Here is my script, my environment, the error traceback, and what have investigated so far.</p>
  
  <pre><code>import numpy as np
  import keras
  from keras import backend as K
  from keras.layers.core import Dense
  from keras.optimizers import Adam
  from keras.metrics import categorical_crossentropy
  from keras.preprocessing.image import ImageDataGenerator
  from keras.models import Model
  from keras.applications import imagenet_utils
  from sklearn.metrics import confusion_matrix
  import itertools
  import matplotlib.pyplot as plt
  %matplotlib inline
  
  mobile =keras.applications.mobilenet.MobileNet()
  
  def prepare_image(file):
      img_path = 'MobileNet-inference-images/'
      img = image.load_img(img_path + file, target_size=(224, 224))
      img_array = image.img_to_array(img)
      img_array_expanded_dims = np.expand_dims(img_array, axis=0)
      return 
      keras.applications.mobilenet.preprocess_imput(img_array_expanded_dims)
  
  preprocessed_image = prepare_image('MobileNet-inference-images/American_Cam.jpg')
  predictions = mobile.predict(preprocessed_image)
  results = imagenet_utils.decode_predictions(predictions)
  results
  </code></pre>
  
  <p>I am running python 3.6.1 in an Anaconda "custom" environment (64 bit) in a Juypter notebook. </p>
  
  <p>The traceback is </p>
  
  <pre><code>---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  &lt;ipython-input-40-90b9684f2691&gt; in &lt;module&gt;()
  ----&gt; 1 preprocessed_image = prepare_image('MobileNet-inference-images/American_Cam.jpg')
        2 predictions = mobile.predict(preprocessed_image)
        3 results = imagenet_utils.decode_predictions(predictions)
        4 results
  
  &lt;ipython-input-32-c204346d1e63&gt; in prepare_image(file)
        1 def prepare_image(file):
        2     img_path = 'MobileNet-inference-images/'
  ----&gt; 3     img = image.load_img(img_path + file, target_size=(224, 224))
        4     img_array = image.img_to_array(img)
        5     img_array_expanded_dims = np.expand_dims(img_array, axis=0)
  
  NameError: name 'image' is not defined
  </code></pre>
  
  <p>I have seen an error of the same name <a href="https://stackoverflow.com/questions/8482897/simplecv-nameerror-name-images-is-not-defined">here</a>, but that appears to be a separate issue(as I am enclosing my image path). <a href="https://www.dreamincode.net/forums/topic/166418-python-image-manipulation/" rel="nofollow noreferrer">Other posts</a> have suggested an issue with PIL. But if I test is PIL is operating with a simple script(such as below), I don't get a PIL error.</p>
  
  <pre><code>from PIL import Image
  im = Image.open('MobileNet-inference-images/American_Cam.jpg')
  im.show()
  </code></pre>