Wie füttere ich ein Cifar10-trainiertes Modell mit meinem eigenen Bild und erhalte ein Etikett als Ausgabe?

Ich versuche, das trainierte Modell basierend auf dem @ zu verwende Cifar10 Tutorial und möchte es mit einem externen Bild 32x32 (jpg oder png) füttern.
Mein Ziel ist es, in der Lage zu sein, @ zu bekomm das Etikett als Ausgabe. Mit anderen Worten, ich möchte das Netzwerk mit einem einzigen JPEG-Bild der Größe 32 x 32 mit 3 Kanälen ohne Bezeichnung als Eingang versorgen und den Inferenzprozess durchführeGib mi dastf.argmax(logits, 1).
rundsätzlich möchte ich in der Lage sein, das trainierte cifar10-Modell auf einem externen Bild zu verwenden und zu sehen, welche Klasse es ausspucken wir

Ich habe versucht, dies basierend auf dem Cifar10-Tutorial zu tun und habe leider immer Probleme. vor allem mit dem Session-Konzept und dem Batch-Konzept.

Jede Hilfe dabei mit Cifar10 wäre sehr dankbar.

Hier ist der bisher implementierte Code mit Kompilierungsproblemen:

#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from datetime import datetime
import math
import time

import tensorflow.python.platform
from tensorflow.python.platform import gfile
import numpy as np
import tensorflow as tf

import cifar10
import cifar10_input
import os
import faultnet_flags
from PIL import Image

FLAGS = tf.app.flags.FLAGS

def evaluate():

  filename_queue = tf.train.string_input_producer(['/home/tensor/.../inputImage.jpg'])

  reader = tf.WholeFileReader()
  key, value = reader.read(filename_queue)

  input_img = tf.image.decode_jpeg(value)

  init_op = tf.initialize_all_variables()

# Problem in here with Graph / session
  with tf.Session() as sess:
    sess.run(init_op)

    coord = tf.train.Coordinator()
    threads = tf.train.start_queue_runners(coord=coord)

    for i in range(1): 
      image = input_img.eval()

    print(image.shape)
    Image.fromarray(np.asarray(image)).show()

# Problem in here is that I have only one image as input and have no label and would like to have
# it compatible with the Cifar10 network
    reshaped_image = tf.cast(image, tf.float32)
    height = FLAGS.resized_image_size
    width = FLAGS.resized_image_size
    resized_image = tf.image.resize_image_with_crop_or_pad(reshaped_image, width, height)
    float_image = tf.image.per_image_whitening(resized_image)  # reshaped_image
    num_preprocess_threads = 1
    images = tf.train.batch(
      [float_image],
      batch_size=128,
      num_threads=num_preprocess_threads,
      capacity=128)
    coord.request_stop()
    coord.join(threads)

    logits = faultnet.inference(images)

    # Calculate predictions.
    #top_k_predict_op = tf.argmax(logits, 1)

    # print('Current image is: ')
    # print(top_k_predict_op[0])

    # this does not work since there is a problem with the session
    # and the Graph conflicting
    my_classification = sess.run(tf.argmax(logits, 1))

    print ('Predicted ', my_classification[0], " for your input image.")


def main(argv=None):
  evaluate()

if __name__ == '__main__':
  tf.app.run() '''

Antworten auf die Frage(4)

Ihre Antwort auf die Frage