Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to load a pre-trained human pose estimation model using OpenPose.
Computer Vision
import cv2 net = cv2.dnn.readNetFromCaffe('pose_deploy_linevec.prototxt', '[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the prototxt file instead of the caffemodel file for weights.
Confusing the model structure file with the weights file.
✗ Incorrect
The model weights file 'pose_iter_440000.caffemodel' is loaded with the prototxt to create the network.
2fill in blank
mediumComplete the code to prepare the input image blob for the pose estimation model.
Computer Vision
blob = cv2.dnn.blobFromImage(image, 1.0 / 255, (368, 368), (0, 0, 0), swapRB=True, crop=False) net.setInput([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the original image instead of the blob to the network.
Passing the network object itself as input.
✗ Incorrect
The blob created from the image is set as input to the network.
3fill in blank
hardFix the error in the code to extract the keypoints from the model output heatmaps.
Computer Vision
output = net.forward() H, W = output.shape[2], output.shape[3] points = [] for i in range(num_keypoints): probMap = output[0, i, :, :] minVal, prob, minLoc, point = cv2.minMaxLoc(probMap) x = (image.shape[1] * point[0]) / [1] y = (image.shape[0] * point[1]) / H if prob > threshold: points.append((int(x), int(y))) else: points.append(None)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up height and width when scaling coordinates.
Using the wrong dimension for scaling x or y.
✗ Incorrect
The height H should be used to scale the y-coordinate, and width W for x-coordinate. Here, x is scaled by width, so the denominator must be width W, but the code mistakenly uses H. The blank is for the denominator of x coordinate, which should be W.
4fill in blank
hardFill both blanks to create a dictionary of keypoints with their names and coordinates.
Computer Vision
keypoints_dict = [1](name: points[i] for i, name in [2](keypoint_names))
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using list() instead of dict() for dictionary creation.
Using range() instead of enumerate() to get index and name.
✗ Incorrect
To create a dictionary from keypoint names and points, use dict() and enumerate() to get index and name pairs.
5fill in blank
hardFill all three blanks to filter detected keypoints with confidence above threshold and create a list of their coordinates.
Computer Vision
filtered_points = [points[i] for i, prob in [1](output[0, :, :, :].max(axis=(1, 2))) if prob [2] threshold and points[i] is not [3]]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using range instead of enumerate for index and value pairs.
Using '<' instead of '>' for filtering probabilities.
Checking points[i] against wrong value instead of None.
✗ Incorrect
Use enumerate to get index and probability, filter where prob > threshold and point is not None.