def classify(model_data_path, image_paths):
 spec = models.get_data_spec(model_class=models.GoogleNet)
 input_node = tf.placeholder(tf.float32, shape=(None, spec.crop_size, spec.crop_size, spec.channels))
 net = models.GoogleNet({'data': input_node})
 image_producer = dataset.ImageProducer(image_paths=image_paths, data_spec=spec)
 with tf.Session() as sesh:
  coordinator = tf.train.Coordinator()
  threads = image_producer.start(session=sesh, coordinator=coordinator)
  print 'Loading the model'
  net.load(model_data_path, sesh)
  print 'Loading the images'
  (indices, input_images) = image_producer.get(sesh)
  print 'Classifying'
  probs = sesh.run(net.get_output(), feed_dict={input_node: input_images})
  display_results([image_paths[i] for i in indices], probs)
  coordinator.request_stop()
  coordinator.join(threads, stop_grace_period_secs=2)

def classify ( model_data_path , image_paths ) : spec = models . get_data_spec ( model_class = models . GoogleNet ) input_node = tf . placeholder ( tf . float32 , shape = ( None , spec . crop_size , spec . crop_size , spec . channels ) ) net = models . GoogleNet ( { 'data' : input_node } ) image_producer = dataset . ImageProducer ( image_paths = image_paths , data_spec = spec ) with tf . Session ( ) as sesh : coordinator = tf . train . Coordinator ( ) threads = image_producer . start ( session = sesh , coordinator = coordinator ) print 'Loading the model' net . load ( model_data_path , sesh ) print 'Loading the images' ( indices , input_images ) = image_producer . get ( sesh ) print 'Classifying' probs = sesh . run ( net . get_output ( ) , feed_dict = { input_node : input_images } ) display_results ( [ image_paths [ i ] for i in indices ] , probs ) coordinator . request_stop ( ) coordinator . join ( threads , stop_grace_period_secs = 2 )
classify an observation into a class .