Python 打印概率和类标签tensor flow对象detetcion API
我遵循tensorflow教程,对每幅图像进行了预测。我想得到的是类和预测概率Python 打印概率和类标签tensor flow对象detetcion API,python,tensorflow,object-detection-api,Python,Tensorflow,Object Detection Api,我遵循tensorflow教程,对每幅图像进行了预测。我想得到的是类和预测概率 https://github.com/tensorflow/models 我正在按照上面的教程使用这段代码,我在图像中得到了检测框、标签和概率 代码: 想要像这样的输出吗 {class: p, prediction:99% , boundigbox: filename,width,height,class,xmin,ymin,xmax,ymax} 此代码应该可以正常工作: from tensorflow.mod
https://github.com/tensorflow/models
我正在按照上面的教程使用这段代码,我在图像中得到了检测框、标签和概率
代码:
想要像这样的输出吗
{class: p, prediction:99% , boundigbox: filename,width,height,class,xmin,ymin,xmax,ymax}
此代码应该可以正常工作:
from tensorflow.models.research.object_detection.utils import label_map_util
width = image_np.shape[1] # Number of columns
height = image_np.shape[0] # number of rows
category_index = label_map_util.create_category_index(categories)
for i in range(len(output_dict['detection_boxes'])):
class_name = category_index[output_dict['detection_classes'][i]]['name']
print("{class: %s, prediction: %s, boundingbox: %s,%i,%i,%i,%i,%i,%i,%i}"
% (class_name,
output_dict['detection_scores'][i],
image_path,
width,
height,
output_dict['detection_classes'][i],
int(width * output_dict['detection_boxes'][i][1]), # The boxes are given normalized and in row/col order
int(height * output_dict['detection_boxes'][i][0]),
int(width * output_dict['detection_boxes'][i][3]),
int(height * output_dict['detection_boxes'][i][2])
))
此代码应该可以正常工作:
from tensorflow.models.research.object_detection.utils import label_map_util
width = image_np.shape[1] # Number of columns
height = image_np.shape[0] # number of rows
category_index = label_map_util.create_category_index(categories)
for i in range(len(output_dict['detection_boxes'])):
class_name = category_index[output_dict['detection_classes'][i]]['name']
print("{class: %s, prediction: %s, boundingbox: %s,%i,%i,%i,%i,%i,%i,%i}"
% (class_name,
output_dict['detection_scores'][i],
image_path,
width,
height,
output_dict['detection_classes'][i],
int(width * output_dict['detection_boxes'][i][1]), # The boxes are given normalized and in row/col order
int(height * output_dict['detection_boxes'][i][0]),
int(width * output_dict['detection_boxes'][i][3]),
int(height * output_dict['detection_boxes'][i][2])
))