title: How to load a jpg image to a 3d rgb numpy array
body: <p>I have made a tensorflow model and have trained and tested it on directories of image using the model.fit_generator method. But know I want to use it on a single image and there aren't any methods i can find that allow this so i decided to use numpy arrays by converting a jpg image to 3d rgb numpy array. How would you do this?</p>
  
  <pre><code>model = Sequential()
  model.add(Convolution2D(32, 3, 3, input_shape=(img_width, img_height,3)))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  
  model.add(Convolution2D(32, 3, 3))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  
  model.add(Convolution2D(64, 3, 3))
  model.add(Activation('relu'))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  
  model.add(Flatten())
  model.add(Dense(64))
  model.add(Activation('relu'))
  model.add(Dropout(0.5))
  model.add(Dense(1))
  model.add(Activation('sigmoid'))
  
  model.compile(loss='binary_crossentropy',
            optimizer='rmsprop',
            metrics=['accuracy'])
  
  
  nb_epoch = 1
  nb_train_samples = 2048
  nb_validation_samples = 832
  
  #model.fit_generator(
  #    train_generator,
  #    samples_per_epoch=nb_train_samples,
  #   nb_epoch=nb_epoch,
  #   validation_data=validation_generator,   
  #  nb_val_samples=nb_validation_samples)
  </code></pre>