def predict(self, img):
if self.use_log:
output_name = 'InceptionV3/Predictions/Softmax:0'
else:
output_name = 'InceptionV3/Predictions/Reshape:0'
# scaled = (0.5+tf.reshape(img,((299,299,3))))*255
# scaled = (0.5+img)*255
if img.shape.as_list()[0]:
# check if a shape has been specified explicitly
shape = (int(img.shape[0]), 1001)
softmax_tensor = tf.import_graph_def(
self.sess.graph.as_graph_def(),
input_map={'input:0': img, 'InceptionV3/Predictions/Shape:0': shape},
return_elements=[output_name])
else:
# placeholder shape
softmax_tensor = tf.import_graph_def(
self.sess.graph.as_graph_def(),
input_map={'input:0': img},
return_elements=[output_name])
return softmax_tensor[0]
评论列表
文章目录