Complete the code to load a pre-trained object detection model in TensorFlow.
model = tf.saved_model.load('[1]')
The correct path points to a pre-trained object detection model saved in TensorFlow's SavedModel format.
Complete the code to convert an image to a tensor suitable for object detection input.
input_tensor = tf.convert_to_tensor(image)[1]Object detection models expect a batch dimension, so we add one with expand_dims(axis=0).
Fix the error in the code to extract detection boxes from the model output dictionary.
boxes = detections['[1]']
The standard key for bounding boxes in TensorFlow object detection output is detection_boxes.
Fill both blanks to filter detection scores above a threshold and get corresponding boxes.
scores = detections['detection_scores'] filtered_boxes = boxes[scores [1] [2]]
We select boxes where the detection score is greater than 0.5 to keep confident detections.
Fill all three blanks to create a dictionary of detected class names and their scores above threshold.
classes = detections['detection_classes'] scores = detections['detection_scores'] result = {str(classes[i]): scores[i] for i in range(len(scores)) if scores[i] [1] [2] and classes[i] != [3]
This code keeps detections with scores above 0.6 and ignores background class labeled as 0.
