0
0
Computer Visionml~10 mins

Custom object detection dataset in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load images from a folder using OpenCV.

Computer Vision
import cv2
image = cv2.imread([1])
print(image.shape)
Drag options to blanks, or click blank then click option'
A'image.jpg'
Bimage.jpg
C['image.jpg']
Dimage
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting the filename in quotes causes an error.
Passing a list instead of a string.
2fill in blank
medium

Complete the code to create a list of image file paths from a directory using pathlib.

Computer Vision
from pathlib import Path
image_dir = Path('images')
image_files = list(image_dir.glob([1]))
print(len(image_files))
Drag options to blanks, or click blank then click option'
A'*.jpg'
B'*jpg'
C'jpg*'
D'*.jpeg'
Attempts:
3 left
💡 Hint
Common Mistakes
Missing the * wildcard causes no files to be found.
Using incorrect file extension pattern.
3fill in blank
hard

Fix the error in this code that reads bounding box annotations from a CSV file.

Computer Vision
import pandas as pd
annotations = pd.read_csv([1])
print(annotations.head())
Drag options to blanks, or click blank then click option'
Acsv.annotations
Bannotations.csv
Cannotations
D'annotations.csv'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable name instead of a string filename.
Forgetting quotes around the filename.
4fill in blank
hard

Fill both blanks to create a dictionary of image filenames and their bounding boxes from a DataFrame.

Computer Vision
bbox_dict = {row[[1]]: (row['xmin'], row['ymin'], row['xmax'], row[[2]]) for _, row in annotations.iterrows()}
Drag options to blanks, or click blank then click option'
A'filename'
B'xmax'
D'ymax'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column names for keys or bounding box coordinates.
Mixing up xmax and ymax columns.
5fill in blank
hard

Fill all three blanks to filter annotations for a specific class and create a list of bounding boxes.

Computer Vision
class_name = 'cat'
filtered = annotations[annotations[[1]] == [2]]
bboxes = [(row['xmin'], row['ymin'], row[[3]], row['ymax']) for _, row in filtered.iterrows()]
Drag options to blanks, or click blank then click option'
A'class'
B'cat'
C'xmax'
D'filename'
Attempts:
3 left
💡 Hint
Common Mistakes
Filtering by wrong column name.
Using wrong bounding box coordinate names.