How can i use tensorflow object detection to only detect persons?

I saw that you used a filter in the line b = [x for x in classes if x == 1] to just get all the person detections. (In the label map, person's id is exactly 1). But it didn't work because you need to change boxes, scores and classes accordingly. Try this :

Firstly remove the line

b = [x for x in classes if x == 1]

Then add the following after sess.run() function

boxes = np.squeeze(boxes)
scores = np.squeeze(scores)
classes = np.squeeze(classes)

indices = np.argwhere(classes == 1)
boxes = np.squeeze(boxes[indices])
scores = np.squeeze(scores[indices])
classes = np.squeeze(classes[indices])

and then call the visualization function

vis_util.visualize_boxes_and_labels_on_image_array(
      image_np,
      boxes,
      classes,
      scores,
      category_index,
      use_normalized_coordinates=True,
      line_thickness=8)

The idea is the model can produce detections of multiple classes but only class person is chosen to visualize on the image.