Bird
Raised Fist0
TensorFlowml~20 mins

Pre-trained detection models in TensorFlow - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Pre-trained Detection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of loading a pre-trained detection model
What is the output type of the variable model after running the following code snippet?
TensorFlow
import tensorflow as tf
model = tf.saved_model.load('ssd_mobilenet_v2_fpnlite_320x320/saved_model')
print(type(model))
A<class 'tensorflow.python.saved_model.load.Loader._recreate_base_user_object.<locals>.UserObject'>
B<class 'tensorflow.python.saved_model.load.Loader'>
C<class 'tensorflow.python.saved_model.load._UserObject'>
D<class 'tensorflow.python.keras.engine.functional.Functional'>
Attempts:
2 left
💡 Hint
The loaded model is a TensorFlow SavedModel object, not a Keras model.
❓ Model Choice
intermediate
2:00remaining
Choosing a pre-trained detection model for real-time mobile app
Which pre-trained detection model is best suited for a real-time mobile application requiring fast inference with reasonable accuracy?
ASSD MobileNet V2
BYOLOv3 with Darknet-53 backbone
CMask R-CNN with ResNet-50 backbone
DFaster R-CNN with ResNet-101 backbone
Attempts:
2 left
💡 Hint
Consider model size and speed for mobile devices.
❓ Hyperparameter
advanced
2:00remaining
Effect of changing the confidence threshold in detection output
In a pre-trained object detection model, what happens if you increase the confidence threshold from 0.5 to 0.8 when filtering detection results?
AThe detection speed will significantly increase due to fewer objects processed.
BThe model retrains itself to improve accuracy automatically.
CMore detected objects will be shown, including many false positives.
DFewer detected objects will be shown, reducing false positives but possibly missing true objects.
Attempts:
2 left
💡 Hint
Think about how confidence threshold affects filtering predictions.
❓ Metrics
advanced
2:00remaining
Understanding mAP metric in object detection
What does the mean Average Precision (mAP) metric measure in evaluating a pre-trained object detection model?
AThe average precision across all classes and IoU thresholds, reflecting detection accuracy.
BThe average confidence score of all detected objects.
CThe average speed of the model in frames per second.
DThe average number of detected objects per image.
Attempts:
2 left
💡 Hint
mAP combines precision and recall over classes and IoU thresholds.
🔧 Debug
expert
3:00remaining
Debugging missing detections from a pre-trained model
You load a pre-trained SSD MobileNet V2 model and run detection on images, but no objects are detected (empty results). Which is the most likely cause?
AThe confidence threshold is set too high, filtering out all detections.
BThe input images are not normalized or resized to the model's expected input size.
CThe model weights file is corrupted and cannot detect objects.
DThe model was trained on a different dataset and cannot detect any objects.
Attempts:
2 left
💡 Hint
Check the input preprocessing steps before feeding images to the model.

Practice

(1/5)
1. What is the main advantage of using a pre-trained detection model in TensorFlow?
easy
A. You can detect objects without training the model yourself
B. It always gives 100% accurate results
C. It requires no input image preprocessing
D. It only works with black and white images

Solution

  1. Step 1: Understand pre-trained model purpose

    Pre-trained detection models are trained on large datasets and ready to use for object detection tasks without extra training.
  2. Step 2: Identify the main benefit

    This means you save time and resources by not training from scratch and can detect objects directly.
  3. Final Answer:

    You can detect objects without training the model yourself -> Option A
  4. Quick Check:

    Pre-trained means ready to use without training [OK]
Hint: Pre-trained means no training needed before use [OK]
Common Mistakes:
  • Thinking pre-trained models are always perfect
  • Ignoring the need for image preprocessing
  • Assuming models only work on certain image types
2. Which of the following is the correct way to load a pre-trained detection model from TensorFlow Hub?
easy
A. model = hub.load_model('ssd_mobilenet_v2')
B. model = tf.load_model('ssd_mobilenet_v2')
C. model = hub.load('https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2')
D. model = tfhub.load('ssd_mobilenet_v2')

Solution

  1. Step 1: Recall TensorFlow Hub loading syntax

    The correct function to load models from TensorFlow Hub is hub.load() with the full URL or handle.
  2. Step 2: Identify the correct option

    model = hub.load('https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2') uses hub.load() with a valid URL, which is the correct method.
  3. Final Answer:

    model = hub.load('https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2') -> Option C
  4. Quick Check:

    Use hub.load() with URL to load models [OK]
Hint: Use hub.load() with full model URL [OK]
Common Mistakes:
  • Using tf.load_model which does not exist
  • Confusing hub.load_model with hub.load
  • Missing full URL in hub.load
3. Given the following code snippet, what is the shape of the input tensor passed to the detection model?
import tensorflow as tf
image = tf.io.read_file('image.jpg')
image = tf.image.decode_jpeg(image, channels=3)
input_tensor = tf.expand_dims(tf.image.convert_image_dtype(image, tf.float32), 0)
print(input_tensor.shape)
medium
A. (height, width, 3)
B. (1, height, width, 3)
C. (3, height, width)
D. (height, width)

Solution

  1. Step 1: Understand image preprocessing steps

    The image is decoded to shape (height, width, 3) for RGB channels, then converted to float32.
  2. Step 2: Analyze tf.expand_dims usage

    tf.expand_dims adds a batch dimension at axis 0, making shape (1, height, width, 3).
  3. Final Answer:

    (1, height, width, 3) -> Option B
  4. Quick Check:

    Batch dimension added first, then image shape [OK]
Hint: expand_dims adds batch size as first dimension [OK]
Common Mistakes:
  • Forgetting batch dimension
  • Mixing channel order
  • Confusing shape with no batch
4. You run a pre-trained detection model but get an error: ValueError: Input tensor must have 4 dimensions. What is the most likely cause?
medium
A. The input tensor is missing the batch dimension
B. The input image was not converted to float32
C. The model URL is incorrect
D. The image file is corrupted

Solution

  1. Step 1: Understand model input requirements

    Pre-trained detection models expect input tensors with shape (batch_size, height, width, channels), which means 4 dimensions.
  2. Step 2: Identify cause of 4D tensor error

    If the input tensor lacks the batch dimension, it will have only 3 dimensions, causing this error.
  3. Final Answer:

    The input tensor is missing the batch dimension -> Option A
  4. Quick Check:

    Batch dimension missing causes 4D input error [OK]
Hint: Check if input tensor has batch dimension (4 dims) [OK]
Common Mistakes:
  • Assuming float32 conversion fixes dimension error
  • Blaming model URL for input shape errors
  • Ignoring batch dimension requirement
5. You want to detect objects in multiple images using a pre-trained TensorFlow detection model. Which approach correctly prepares a batch of images for the model?
hard
A. Run the model separately on each image without batching
B. Pass a list of image file paths directly to the model
C. Concatenate images along the channel axis to shape (height, width, batch_size*3)
D. Stack individual preprocessed images into a tensor with shape (batch_size, height, width, 3)

Solution

  1. Step 1: Understand batch input format

    Pre-trained detection models expect a 4D tensor with batch size as the first dimension, so multiple images must be stacked into one tensor.
  2. Step 2: Evaluate options for batch preparation

    Stack individual preprocessed images into a tensor with shape (batch_size, height, width, 3) correctly stacks images into shape (batch_size, height, width, 3). Options B and C do not produce valid input tensors. Run the model separately on each image without batching works but is inefficient.
  3. Final Answer:

    Stack individual preprocessed images into a tensor with shape (batch_size, height, width, 3) -> Option D
  4. Quick Check:

    Batch images as 4D tensor for detection [OK]
Hint: Batch images by stacking into 4D tensor [OK]
Common Mistakes:
  • Passing file paths instead of tensors
  • Concatenating along wrong axis
  • Ignoring batch processing benefits
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard