I'm using the acceptance resnet v2 model to infer images.
A label deduced about the input image and a score on how accurate it is to make a two-dimensional array. By the way, can you find a factor that satisfies both conditions?
For example
list_total = [('cheese cake', '0.99597'), ('cheese soup', '0.00114'), ('cheese candy', '0.00102'), ('red cake', '0.00098'), ('red soup', '0.00039'), ('red candy', '0.00029'), ('blue cake', '0.00019'), ('blue soup', '0.00001'), ('blue candy', '0.00001')]
In the list above, I would like to find an element that contains 'cheese' and has a number greater than 0.90000
image_path = sys.argv[1]
image_data = tf.gfile.FastGFile(image_path, 'rb').read()
label_lines = [line.rstrip() for line
in tf.gfile.GFile("my_labels.txt")]
with tf.gfile.FastGFile("my.proto", 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
_ = tf.import_graph_def(graph_def, name='')
with tf.Session() as sess:
softmax_tensor = sess.graph.get_tensor_by_name('InceptionResnetV2/Logits/Predictions:0')
predictions = sess.run(softmax_tensor, \
{'input_image:0': image_data})
top_k = predictions[0].argsort()[-len(predictions[0]):][::-1]
list_total = []
for node_id in top_k :
human_string = label_lines[node_id]
score = predictions[0][node_id]
human_score = '%.5f'%(score)
hair_total.append((human_string,human_score))
for item in hair_total :
if 'cheese' in item[0] :
print('yes')
else :
print ('no')
When you run the code above, you say yes to the list that contains the 'cheese'
yes
yes
yes
no
no
no
no
no
no
but how do you find the one that contains the 'cheese' and has the largest number? like this
yes
no
no
no
no
no
no
no
no
Aucun commentaire:
Enregistrer un commentaire