augmentedstartups / mask-rcnn

Video Tutorial Series on Mask RCNN
92 stars 66 forks source link

How to output masks using vis_util.visualize_boxes_and_labels_on_image_array? #1

Open jericovalino opened 5 years ago

jericovalino commented 5 years ago

I cannot output the masks using vis_util.visualize_boxes_and_labels_on_image_array. It seems that the size of the masks is different from the size of the image

this is the error : ValueError: The image has spatial dimensions (480, 640) but the mask has dimensions (15, 15)

here is my code.. please correct it.

while(True):
    ret, frame = video.read()
    frame_expanded = np.expand_dims(frame, axis=0)

    (masks, boxes, scores, classes, num) = sess.run([detection_masks,
                                                    detection_boxes,
                                                    detection_scores,
                                                    detection_classes,
                                                    num_detections],
                                                    feed_dict={image_tensor: frame_expanded})

    masks = np.squeeze(masks).astype(np.uint8)

    vis_util.visualize_boxes_and_labels_on_image_array(
        frame,
        np.squeeze(boxes),
        np.squeeze(classes).astype(np.int32),
        np.squeeze(scores),
        category_index,
        instance_masks=masks,
        use_normalized_coordinates=True,
        line_thickness=2)

    cv2.imshow('Object detector', frame)

    if cv2.waitKey(1) == ord('q'):
        break
jericovalino commented 5 years ago

@reigngt09