Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the YOLO model from TensorFlow Hub.
TensorFlow
import tensorflow_hub as [1]
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tf' instead of 'hub' to import tensorflow_hub.
Trying to import YOLO directly from tensorflow instead of tensorflow_hub.
✗ Incorrect
The TensorFlow Hub library is imported as 'hub' to load pre-trained models like YOLO.
2fill in blank
mediumComplete the code to load a pre-trained YOLO model from TensorFlow Hub.
TensorFlow
model = hub.load('[1]')
Attempts:
3 left
💡 Hint
Common Mistakes
Using URLs for other models like ResNet or MobileNet instead of YOLO.
Missing the correct version number in the URL.
✗ Incorrect
The YOLO v3 model URL on TensorFlow Hub is used to load the pre-trained YOLO model.
3fill in blank
hardFix the error in the code to preprocess an input image for YOLO model prediction.
TensorFlow
input_tensor = tf.image.resize(image, ([1], [1])) / 255.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 224 which is common for classification but not YOLO.
Not resizing the image to the correct input size.
✗ Incorrect
YOLO models typically require input images resized to 416x416 pixels and normalized between 0 and 1.
4fill in blank
hardFill both blanks to extract bounding boxes and class scores from YOLO output.
TensorFlow
boxes, scores = model([1]) classes = tf.argmax(scores, axis=[2])
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis=0 which would select the wrong dimension.
Passing an undefined variable like 'output_tensor' to the model.
✗ Incorrect
The model takes the preprocessed input tensor. Class scores are along axis 1, so argmax uses axis=1.
5fill in blank
hardFill all three blanks to filter detected objects with confidence above 0.5 and prepare final results.
TensorFlow
conf_mask = scores[:, [1]] > [2] filtered_boxes = tf.boolean_mask(boxes, conf_mask) filtered_scores = tf.boolean_mask(scores[:, [3]], conf_mask)
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column indices for confidence scores.
Using a threshold other than 0.5 which is standard for filtering.
✗ Incorrect
Confidence scores are in column 0, so scores[:,0]. We filter scores greater than 0.5. The filtered scores use the same column 0.
