Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 打印概率和类标签tensor flow对象detetcion API_Python_Tensorflow_Object Detection Api - Fatal编程技术网

Python 打印概率和类标签tensor flow对象detetcion API

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

我遵循tensorflow教程,对每幅图像进行了预测。我想得到的是类和预测概率

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])
             ))