如何计算 Tensorflow Object Detection API 中的对象 [英] How to count objects in Tensorflow Object Detection API

查看:30
本文介绍了如何计算 Tensorflow Object Detection API 中的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在执行

如何获取对象计数?

解决方案

您可以使用

  • 示例项目#2 是车辆计数":

  • 示例项目#3 是实时对象计数":

请参阅 TensorFlow 对象计数 API 了解更多信息,并请给一颗星 那个 存储库,如果您觉得它有用,则表示您对开源社区的支持!

I am executing https://github.com/tensorflow/tensorflow this example of detecting objects in image.

I want to get count of detected objects following is the code that gives me detected object drawn in an image. But I am not able to get count of detected objects.

with detection_graph.as_default():
with tf.Session(graph=detection_graph) as sess:
    for image_path in TEST_IMAGE_PATHS:
      image = Image.open(image_path)
      # the array based representation of the image will be used later in order to prepare the
      # result image with boxes and labels on it.
      image_np = load_image_into_numpy_array(image)
      # Expand dimensions since the model expects images to have shape: [1, None, None, 3]
      image_np_expanded = np.expand_dims(image_np, axis=0)
      image_tensor = detection_graph.get_tensor_by_name('image_tensor:0')
      # Each box represents a part of the image where a particular object was detected.
      boxes = detection_graph.get_tensor_by_name('detection_boxes:0')
      # Each score represent how level of confidence for each of the objects.
      # Score is shown on the result image, together with the class label.
      scores = detection_graph.get_tensor_by_name('detection_scores:0')
      classes = detection_graph.get_tensor_by_name('detection_classes:0')
      num_detections = detection_graph.get_tensor_by_name('num_detections:0')
      # Actual detection.
      (boxes, scores, classes, num_detections) = sess.run(
          [boxes, scores, classes, num_detections],
          feed_dict={image_tensor: image_np_expanded})
      # Visualization of the results of a detection.
      vis_util.visualize_boxes_and_labels_on_image_array(
          image_np,
          np.squeeze(boxes),
          np.squeeze(classes).astype(np.int32),
          np.squeeze(scores),
          category_index,
          use_normalized_coordinates=True,
          line_thickness=1)
      plt.figure(figsize=IMAGE_SIZE)
      plt.imshow(image_np)

This is the block of code that gives actual object detection shown in below image:

How can I get the object count?

解决方案

You can use the TensorFlow Object Counting API that is an open source framework built on top of TensorFlow that makes it easy to develop object counting systems to count any objects! Moreover, it provides sample projects so you can adopt them to develop your own specific case studies!

  • Sample Project#1 is "Pedestrian Counting":

  • Sample Project#2 is "Vehicle Counting":

  • Sample Project#3 is "Object Counting in Real-Time":

See the TensorFlow Object Counting API for more info and please give a star that repo for showing your support to open source community if you find it useful!

这篇关于如何计算 Tensorflow Object Detection API 中的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆