Skip to content

No bounding box on my Test image #10561

@Annieliaquat

Description

@Annieliaquat

Hi, I have been using a remote ubuntu system for my object detection training and testing. Everything went well and my test image was also shown with a bounding box and label.
But the system had some issue and I couldn't perform my task further on that system, but now I have started my work in colab.
Everything here also goes well but the only thing which is making issue is that, when I test my image no bounding box is drawn around my image. I have tried every possible solution but its not working.
I don't know if there is any special setting for colab.
Here is the final code I used for testing my image. In this code when I changed the parameter "max_box_to_draw" from 30 to 100, bounding box was drawn automatically. I have done same thing in colab but its not working..
Please if anyone has gone throw this problem before and has find a solution then plz help me..

img = cv2.imread(IMAGE_PATH)
image_np = np.array(img)

input_tensor = tf.convert_to_tensor(np.expand_dims(image_np, 0), dtype=tf.float32)
detections = detect_fn(input_tensor)

num_detections = int(detections.pop('num_detections'))
detections = {key: value[0, :num_detections].numpy()
for key, value in detections.items()}
detections['num_detections'] = num_detections

detection_classes should be ints.

detections['detection_classes'] = detections['detection_classes'].astype(np.int64)

label_id_offset = 1
image_np_with_detections = image_np.copy()

viz_utils.visualize_boxes_and_labels_on_image_array(
image_np_with_detections,
detections['detection_boxes'],
detections['detection_classes']+label_id_offset,
detections['detection_scores'],
category_index,
use_normalized_coordinates=True,
line_thickness=9,
#instance_masks=detections.get('detection_masks'),
max_boxes_to_draw=100,
min_score_thresh=.30,
agnostic_mode=True )

cv2.resize(image_np_with_detections,(500, 500),interpolation = cv2.INTER_NEAREST)
plt.imshow(cv2.cvtColor(image_np_with_detections, cv2.COLOR_BGR2RGB))
plt.show()

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions