0
0
Computer Visionml~10 mins

Small dataset strategies 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 directory using a common computer vision library.

Computer Vision
from tensorflow.keras.preprocessing.image import ImageDataGenerator

datagen = ImageDataGenerator(rescale=1./255)
data = datagen.flow_from_directory('[1]', target_size=(150, 150), batch_size=32, class_mode='binary')
Drag options to blanks, or click blank then click option'
Adataset/train
Bimages
Cdata
Dfolder
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic folder name that does not exist.
Not specifying the correct path to the image directory.
2fill in blank
medium

Complete the code to apply data augmentation to images to help with small datasets.

Computer Vision
datagen = ImageDataGenerator(rescale=1./255, rotation_range=[1], horizontal_flip=True)
Drag options to blanks, or click blank then click option'
A10
B180
C90
D40
Attempts:
3 left
💡 Hint
Common Mistakes
Using 90 or 180 degrees which may distort images too much.
Using too small rotation like 10 degrees which may not augment enough.
3fill in blank
hard

Fix the error in the code to freeze the base model layers for transfer learning.

Computer Vision
base_model = tf.keras.applications.MobileNetV2(input_shape=(224, 224, 3), include_top=False, weights='imagenet')
for layer in base_model.[1]:
    layer.trainable = False
Drag options to blanks, or click blank then click option'
Alayer
Blayers
Ctrainable
Dtrain
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'layer' which is a single layer, not iterable.
Using 'trainable' or 'train' which are not iterable attributes.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps image filenames to their augmented versions.

Computer Vision
augmented_images = {filename: next(datagen.[1](image[None], batch_size=1))[0] for filename, image in images.items() if image.shape [2] (224, 224, 3)}
Drag options to blanks, or click blank then click option'
Aflow
Bshape
C==
Dresize
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'resize' which is not a method of ImageDataGenerator.
Using 'shape' as a method instead of an attribute.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that filters images by size and applies augmentation.

Computer Vision
filtered_augmented = {filename: next(datagen.[1](image[None], batch_size=1))[0] for filename, image in images.items() if image.[2][0] [3] 224}
Drag options to blanks, or click blank then click option'
Aflow
Bshape
C>=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' which filters out larger images.
Using 'resize' instead of 'flow' for augmentation.