Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a pre-trained DNN face detector model.
Computer Vision
net = cv2.dnn.readNetFromCaffe('[1]', 'deploy.caffemodel')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the weights file instead of the prototxt file for architecture.
Confusing TensorFlow or Keras model files with Caffe files.
✗ Incorrect
The prototxt file defines the model architecture for the Caffe DNN face detector.
2fill in blank
mediumComplete the code to prepare the input blob for the DNN face detector.
Computer Vision
blob = cv2.dnn.blobFromImage(image, 1.0, ([1], [1]), (104.0, 177.0, 123.0))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect input size causing detection failure.
Confusing input size with image resolution.
✗ Incorrect
The face detector expects 300x300 input size for the blob.
3fill in blank
hardFix the error in the code to extract confidence scores from the detections.
Computer Vision
confidence = detections[0, 0, i, [1]]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using index 1 or 3 which correspond to class or bounding box coordinates.
Confusing zero-based indexing.
✗ Incorrect
Index 2 holds the confidence score in the detections array.
4fill in blank
hardFill both blanks to compute bounding box coordinates from detections.
Computer Vision
box = detections[0, 0, i, 3:7] * np.array([[1], [2], [1], [2]])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height values.
Using fixed numbers instead of image dimensions.
✗ Incorrect
Width is image.shape[1] and height is image.shape[0], used to scale box coordinates.
5fill in blank
hardFill all three blanks to filter detections by confidence and draw rectangles.
Computer Vision
if confidence > [1]: (startX, startY, endX, endY) = box.astype([2]) cv2.rectangle(image, (startX, startY), (endX, endY), [3], 2)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using too low or too high confidence threshold.
Not converting coordinates to int causing errors.
Using wrong color format for rectangle.
✗ Incorrect
Confidence threshold is 0.5, box coordinates converted to int, green rectangle color.