Bird
Raised Fist0
Computer Visionml~10 mins

Annotation quality in Computer Vision - Interactive Code Practice

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the Intersection over Union (IoU) between two bounding boxes.

Computer Vision
def iou(boxA, boxB):
    xA = max(boxA[0], boxB[0])
    yA = max(boxA[1], boxB[1])
    xB = min(boxA[2], boxB[2])
    yB = min(boxA[3], boxB[3])

    interArea = max(0, xB - xA) * max(0, yB - yA)

    boxAArea = (boxA[2] - boxA[0]) * (boxA[3] - boxA[1])
    boxBArea = (boxB[2] - boxB[0]) * (boxB[3] - boxB[1])

    iou = interArea / [1]
    return iou
Drag options to blanks, or click blank then click option'
AboxAArea + boxBArea - interArea
BboxAArea - boxBArea
CinterArea
DboxAArea + boxBArea
Attempts:
3 left
💡 Hint
Common Mistakes
Using only the sum of areas without subtracting the intersection area.
Dividing by intersection area instead of union area.
2fill in blank
medium

Complete the code to compute the precision of an object detection model given true positives and false positives.

Computer Vision
def precision(true_positives, false_positives):
    return true_positives / [1]
Drag options to blanks, or click blank then click option'
Afalse_positives
Btrue_positives + false_negatives
Ctrue_positives + false_positives
Dtrue_positives
Attempts:
3 left
💡 Hint
Common Mistakes
Using false negatives in the denominator instead of false positives.
Dividing by only true positives.
3fill in blank
hard

Fix the error in the code to calculate recall given true positives and false negatives.

Computer Vision
def recall(true_positives, false_negatives):
    return true_positives / [1]
Drag options to blanks, or click blank then click option'
Afalse_negatives
Btrue_positives + false_negatives
Ctrue_positives + false_positives
Dtrue_positives
Attempts:
3 left
💡 Hint
Common Mistakes
Using false positives in the denominator instead of false negatives.
Dividing by only true positives.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps image IDs to their annotation counts, but only for images with more than 5 annotations.

Computer Vision
annotation_counts = {img_id: [1] for img_id, annotations in dataset.items() if [2]
Drag options to blanks, or click blank then click option'
Alen(annotations)
Blen(annotations) > 5
Clen(annotations) < 5
Dannotations
Attempts:
3 left
💡 Hint
Common Mistakes
Using the annotations list directly instead of its length.
Using the wrong comparison operator in the if condition.
5fill in blank
hard

Fill all three blanks to create a list comprehension that extracts labels from annotations only if the confidence score is above 0.8.

Computer Vision
high_conf_labels = [ann[1] for ann in annotations if ann[2] > [3]]
Drag options to blanks, or click blank then click option'
A['label']
B['confidence']
C0.8
D['score']
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong key for confidence score.
Using dot notation instead of square brackets for dictionary keys.
Using a wrong threshold value.

Practice

(1/5)
1. What does annotation quality in computer vision mainly refer to?
easy
A. How accurate and clear the labels on images are
B. The speed of the model training process
C. The size of the image dataset
D. The type of camera used to capture images

Solution

  1. Step 1: Understand the meaning of annotation quality

    Annotation quality means how correct and clear the labels on images are, which helps models learn well.
  2. Step 2: Compare options to definition

    Only How accurate and clear the labels on images are matches this meaning. Other options relate to training speed, dataset size, or camera type, which are unrelated.
  3. Final Answer:

    How accurate and clear the labels on images are -> Option A
  4. Quick Check:

    Annotation quality = accuracy and clarity of labels [OK]
Hint: Annotation quality means label correctness and clarity [OK]
Common Mistakes:
  • Confusing annotation quality with dataset size
  • Thinking annotation quality is about camera or hardware
  • Mixing annotation quality with model training speed
2. Which of the following is the correct way to describe a high-quality annotation in a dataset?
easy
A. Labels are randomly assigned to images
B. Labels are written in a different language than the model expects
C. Labels are missing for most images
D. Labels match the true content of images clearly and correctly

Solution

  1. Step 1: Define high-quality annotation

    High-quality annotation means labels clearly and correctly match the true content of images.
  2. Step 2: Evaluate each option

    Labels match the true content of images clearly and correctly fits this definition. Options A, B, and C describe poor or incorrect labeling practices.
  3. Final Answer:

    Labels match the true content of images clearly and correctly -> Option D
  4. Quick Check:

    High-quality annotation = correct and clear labels [OK]
Hint: Good labels match image content clearly and correctly [OK]
Common Mistakes:
  • Choosing random or missing labels as correct
  • Ignoring label language compatibility
  • Assuming any label is good regardless of accuracy
3. Given this Python code snippet checking annotation quality, what will be the output?
annotations = ['cat', 'dog', 'dog', 'cat']
true_labels = ['cat', 'dog', 'cat', 'cat']
correct = sum(a == t for a, t in zip(annotations, true_labels))
accuracy = correct / len(true_labels)
print(round(accuracy, 2))
medium
A. 1.00
B. 0.50
C. 0.75
D. 0.25

Solution

  1. Step 1: Compare each annotation with true label

    Positions: 0(cat=cat) correct, 1(dog=dog) correct, 2(dog=cat) wrong, 3(cat=cat) correct. So 3 correct out of 4.
  2. Step 2: Calculate accuracy

    Accuracy = 3 correct / 4 total = 0.75. Rounded to 2 decimals is 0.75.
  3. Final Answer:

    0.75 -> Option C
  4. Quick Check:

    Accuracy = 3/4 = 0.75 [OK]
Hint: Count matches, divide by total, round result [OK]
Common Mistakes:
  • Counting all annotations as correct
  • Dividing by wrong total length
  • Not rounding the output
4. This code is meant to calculate annotation accuracy but has a bug. What is the error?
annotations = ['car', 'bike', 'car']
true_labels = ['car', 'car', 'car']
correct = 0
for i in range(len(annotations)):
    if annotations[i] = true_labels[i]:
        correct += 1
accuracy = correct / len(true_labels)
print(accuracy)
medium
A. Using '=' instead of '==' in the if condition
B. Dividing by length of annotations instead of true_labels
C. Not initializing correct to zero
D. Using print without parentheses

Solution

  1. Step 1: Identify syntax error in if condition

    The if statement uses '=' which is assignment, not comparison. It should be '==' to compare values.
  2. Step 2: Check other parts

    Correct is initialized, division is by correct length, and print uses parentheses correctly. So only '=' is wrong.
  3. Final Answer:

    Using '=' instead of '==' in the if condition -> Option A
  4. Quick Check:

    Comparison needs '==' not '=' [OK]
Hint: Use '==' for comparison, '=' is assignment [OK]
Common Mistakes:
  • Confusing '=' with '==' in conditions
  • Thinking division length is wrong
  • Ignoring syntax errors in if statements
5. You have a dataset with images labeled for object detection. Some labels are missing bounding boxes, and some boxes are misplaced. How should you improve annotation quality before training a model?
hard
A. Ignore errors and train the model directly
B. Manually review and correct missing or wrong bounding boxes
C. Remove all images with any label issues without replacement
D. Add random bounding boxes to all images

Solution

  1. Step 1: Understand impact of missing or wrong labels

    Missing or misplaced bounding boxes reduce annotation quality and hurt model learning.
  2. Step 2: Choose best action to fix quality

    Manually reviewing and correcting labels improves quality. Ignoring or removing data blindly or adding random boxes harms quality.
  3. Final Answer:

    Manually review and correct missing or wrong bounding boxes -> Option B
  4. Quick Check:

    Fix labels manually to improve quality [OK]
Hint: Fix missing/wrong labels manually before training [OK]
Common Mistakes:
  • Ignoring label errors thinking model will learn anyway
  • Removing too much data without fixing
  • Adding random labels that confuse the model