Complete the code to load the pre-trained face detection model.
net = cv2.dnn.readNetFromCaffe('[1]', 'res10_300x300_ssd_iter_140000.caffemodel')
The readNetFromCaffe function requires the model architecture file, which is deploy.prototxt.txt.
Complete the code to prepare the input blob for the face detector.
blob = cv2.dnn.blobFromImage(image, 1.0, ([1], [1]), (104.0, 177.0, 123.0))
The face detector expects input images resized to 300x300 pixels.
Fix the error in the code to extract confidence scores from detections.
confidence = detections[0, 0, i, [1]]
The confidence score is at index 2 in the detection array.
Fill both blanks to compute bounding box coordinates from detection.
box = detections[0, 0, i, 3:7] * np.array([[1], [2], [1], [2]])
The bounding box coordinates are normalized, so multiply by image width and height respectively.
Fill all three blanks to draw rectangles around detected faces with confidence above threshold.
if confidence > [1]: (startX, startY, endX, endY) = box.astype(int) cv2.rectangle(image, (startX, startY), (endX, endY), [2], [3])
We draw rectangles for detections with confidence above 0.5, using green color and thickness 2.