Python OpenCV Computer Vision
- 134Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is OpenCV, and which programming languages provide access to it?
134 questions
- 1
What is OpenCV, and which programming languages provide access to it?
Model answer
OpenCV is a computer vision library available for Python, C++, and Java.
Explanation
The library provides tools for processing and manipulating images and video.
- 2
What is computer vision primarily concerned with?
Model answer
Computer vision derives insights from media files such as images and videos, often using deep learning techniques.
Explanation
The course treats computer vision as an application of deep learning focused on visual media.
- 3
How can you check the installed Python version from a terminal?
Model answer
Run
python --versionin the terminal.Explanation
The command reports the Python version currently available on the system.
- 4
What minimum Python version is recommended for the course?
Model answer
Python 3.7 or a newer version is recommended.
Explanation
Some course code may not work correctly with older Python versions, especially Python 2.
- 5
What is the difference between
opencv-pythonandopencv-contrib-python?Model answer
opencv-contrib-pythonincludes the main OpenCV modules plus additional community-contributed modules.Explanation
The contribution package is recommended because it provides broader OpenCV functionality.
- 6
What role does NumPy play in OpenCV projects?
Model answer
NumPy supports scientific computing and is widely used for matrix and array manipulation, transformation, and reshaping.
Explanation
OpenCV images are represented as arrays, so NumPy operations are useful for processing them.
- 7
What is the purpose of the
seerutility package in the course?Model answer
seerprovides helper and utility functions intended to speed up computer vision workflows.Explanation
It is used mainly later in the course when building a deep computer vision model.
- 8
What main areas of OpenCV are introduced in the course?
Model answer
The course covers media input, transformations, drawing, color spaces, bitwise operations, masking, histograms, thresholding, edge detection, face processing, and deep learning.
Explanation
These topics progress from basic image and video handling to advanced computer vision applications.
- 9
What does
cv.imreadreturn when it successfully reads an image?Model answer
It returns the image as a matrix of pixel values.
Explanation
The matrix can then be displayed or manipulated with OpenCV and NumPy.
- 10
What argument does
cv.imreadrequire?Model answer
It requires a path to the image file, which may be relative or absolute.
Explanation
A relative path is interpreted from the program's current working directory.
- 11
How is an image displayed in OpenCV?
Model answer
Use
cv.imshowwith a window name and the image matrix.Explanation
The method opens a new window containing the supplied image.
- 12
What does
cv.waitKey(0)do?Model answer
It waits indefinitely until a keyboard key is pressed.
Explanation
The zero delay is interpreted as an infinite wait, allowing an image window to remain visible.
- 13
Why can a large image extend beyond the computer screen when displayed?
Model answer
OpenCV does not automatically resize images that are larger than the display area.
Explanation
Large images must be resized or rescaled before display if they exceed the monitor dimensions.
- 14
How does
cv.VideoCaptureidentify a video source?Model answer
It accepts either a path to a video file or an integer camera index.
Explanation
A file path opens a stored video, while an integer selects a connected camera.
- 15
What camera is usually represented by camera index
0?Model answer
Index
0usually refers to the computer's default webcam.Explanation
Additional cameras can be selected with other indices such as
1or2. - 16
What does
capture.read()return while reading a video?Model answer
It returns a Boolean indicating success and the next video frame.
Explanation
The Boolean shows whether a frame was successfully read from the capture source.
- 17
Why is a loop used to read a video?
Model answer
A video is processed frame by frame, so a loop repeatedly reads and displays successive frames.
Explanation
Each iteration obtains one frame and can display it with
cv.imshow. - 18
How can a video loop be stopped when the user presses the letter
d?Model answer
Check the result of
cv.waitKey(20)and break the loop when its masked value matches the character code ford.Explanation
The keyboard check provides a controlled way to stop playback before or after the video ends.
- 19
What cleanup operations should be performed after video capture ends?
Model answer
Release the capture object and destroy all OpenCV windows.
Explanation
These operations free the camera or video resource and close display windows.
- 20
What does a negative 215 assertion error commonly indicate in this context?
Model answer
It usually means OpenCV could not find or read the specified media file or frame.
Explanation
The error can result from an incorrect path or from attempting to read beyond the final video frame.
- 21
Why are images and video frames commonly resized or rescaled?
Model answer
Resizing reduces computational strain by removing some image information and lowering the processing required for display or analysis.
Explanation
Large media files require more memory and processing power.
- 22
Why is downscaling generally preferred for video frames?
Model answer
Downscaling reduces processing demands, while cameras generally cannot produce resolutions higher than their maximum capability.
Explanation
A camera that records at 720p typically cannot be made to capture true 1080p video through software resizing.
- 23
How is the width of an image obtained from an OpenCV frame array?
Model answer
The width is stored in
frame.shape[1], while the height is stored inframe.shape[0].Explanation
The first two shape values represent height and width in that order.
- 24
How does a scale factor resize a frame?
Model answer
The original width and height are multiplied by the scale factor and converted to integers before resizing.
Explanation
For example, a scale factor of
0.75produces dimensions approximately 75 percent of the original. - 25
What is the purpose of
cv.resize?Model answer
It changes an image or frame to specified destination dimensions.
Explanation
It can be used for both images and video frames.
- 26
What is the difference between resizing with a general function and using
capture.set?Model answer
A resizing function works with images, stored videos, and live video, whereas
capture.setchanges resolution only for live camera input.Explanation
The capture properties cannot alter the dimensions of an already stored video file.
- 27
Which capture properties represent width and height when using
capture.set?Model answer
Property
3represents width and property4represents height.Explanation
These properties configure the resolution of a live capture source.
- 28
How is a blank image created with NumPy for drawing?
Model answer
Create an array of zeros with the desired height, width, and color-channel dimensions, typically using the
uint8data type.Explanation
A blank array provides a clean canvas for shapes and text.
- 29
How can every pixel in an image be assigned the same color?
Model answer
Reference all pixels in the array and assign a color value to them.
Explanation
For a three-channel image, the assigned color contains one value for each channel.
- 30
What does the
cv.rectanglefunction require to draw a rectangle?Model answer
It requires an image, two corner points, a color, and a thickness; a line type may also be supplied.
Explanation
The corner points define the rectangle's position and size.
- 31
How can a rectangle be filled completely in OpenCV?
Model answer
Use a thickness of
-1orcv.FILLED.Explanation
These values instruct OpenCV to fill the rectangle rather than draw only its border.
- 32
What parameters define a circle drawn with
cv.circle?Model answer
A circle is defined by its image, center coordinates, radius, color, and thickness.
Explanation
A negative thickness fills the circle.
- 33
How is a line drawn in OpenCV?
Model answer
Use
cv.linewith an image, two endpoints, a color, and a thickness.Explanation
The endpoints determine the line's location and direction.
- 34
How is text placed on an OpenCV image?
Model answer
Use
cv.putTextwith the text, origin, font, scale, color, and thickness.Explanation
OpenCV provides built-in fonts such as the Hershey font variants.
- 35
What is grayscale conversion used for?
Model answer
It converts a three-channel color image into a one-channel image representing pixel intensity rather than color.
Explanation
Grayscale is often sufficient for operations such as edge detection and face detection.
- 36
Which color conversion changes OpenCV's default BGR image into grayscale?
Model answer
Use
cv.cvtColorwith theBGR2GRAYconversion code.Explanation
OpenCV normally reads color images in blue-green-red channel order.
- 37
Why is Gaussian blurring applied to an image?
Model answer
It reduces noise caused by poor lighting, camera sensors, or other unwanted variations.
Explanation
Blurring smooths local intensity changes before later processing.
- 38
What restriction applies to the Gaussian blur kernel size?
Model answer
The kernel dimensions must be odd numbers, such as 3×3 or 7×7.
Explanation
An odd-sized kernel provides a single central pixel around which the neighborhood is evaluated.
- 39
How does increasing the Gaussian blur kernel size affect an image?
Model answer
A larger kernel generally produces a stronger blur.
Explanation
More neighboring pixels contribute to the smoothing calculation.
- 40
What is the purpose of the Canny edge detector?
Model answer
It identifies prominent edges in an image using a multistep process involving smoothing and gradient calculations.
Explanation
Canny commonly produces a clean representation of object boundaries.
- 41
How can blurring reduce the number of edges detected by Canny?
Model answer
Blurring removes small intensity variations and noise, so fewer minor edges remain for Canny to detect.
Explanation
This is useful when noise creates too many unwanted edges.
- 42
What effect does dilation have on an edge image?
Model answer
Dilation thickens or expands the detected edge regions.
Explanation
It applies a structuring element repeatedly to enlarge foreground features.
- 43
What effect does erosion have on a dilated image?
Model answer
Erosion shrinks foreground regions and can sometimes return a dilated edge image close to its original form.
Explanation
The result depends on the kernel size and number of iterations.
- 44
How does array slicing crop an image?
Model answer
It selects a range of rows and columns from the image array to retain only a rectangular region.
Explanation
For example, selecting row and column intervals extracts a portion of the original image.
- 45
What is image translation?
Model answer
Translation shifts an image along the horizontal and vertical axes.
Explanation
It can move an image left, right, up, down, or in a combination of directions.
- 46
How do the signs of translation values determine direction?
Model answer
A negative horizontal value shifts left, a positive horizontal value shifts right, a negative vertical value shifts up, and a positive vertical value shifts down.
Explanation
The values specify the number of pixels moved along each axis.
- 47
What is the purpose of a translation matrix?
Model answer
It encodes the horizontal and vertical shifts required to transform an image.
Explanation
The matrix is supplied to an affine warp operation.
- 48
What does image rotation change?
Model answer
Rotation turns an image by a specified angle around a chosen point.
Explanation
The rotation point is often the image center but may be any coordinate.
- 49
What is the usual rotation point when none is specified?
Model answer
The image center is used as the default rotation point.
Explanation
The center is calculated from half the image width and half the image height.
- 50
How can rotation direction be changed in OpenCV?
Model answer
Use a positive angle for one direction and a negative angle for the opposite direction.
Explanation
In the example, positive angles rotate counterclockwise and negative angles rotate clockwise.
- 51
Why can black triangular regions appear after rotating an image?
Model answer
The rotated image may contain areas that were outside the original image boundaries, so OpenCV fills those areas with black.
Explanation
Rotating an already rotated image also rotates these introduced black regions.
- 52
What do the flip codes in
cv.fliprepresent?Model answer
Code
0flips vertically, code1flips horizontally, and code-1flips both vertically and horizontally.Explanation
The codes specify the axis or axes across which the image is reflected.
- 53
What are contours?
Model answer
Contours are curves or boundaries joining continuous points along the boundary of an object.
Explanation
They are useful for shape analysis, object detection, and object recognition.
- 54
How are contours different from edges?
Model answer
Contours and edges are mathematically different, although contours can often be treated as object boundaries similar to edges in programming tasks.
Explanation
Contours usually represent connected boundary structures derived from image features.
- 55
What does
cv.findContoursreturn?Model answer
It returns a list of detected contours and a hierarchy describing their relationships.
Explanation
The hierarchy can represent structures such as a circle inside a square inside a rectangle.
- 56
What is the difference between external, list, and tree contour retrieval modes?
Model answer
External retrieves only outer contours, list retrieves all contours without hierarchy, and tree retrieves all contours with their hierarchical relationships.
Explanation
The retrieval mode determines which contour relationships OpenCV preserves.
- 57
What does
CHAIN_APPROX_NONEdo?Model answer
It retains all contour points.
Explanation
No compression is applied to the coordinates describing each contour.
- 58
What does
CHAIN_APPROX_SIMPLEdo?Model answer
It compresses redundant contour points while retaining the points needed to represent the shape.
Explanation
For example, a straight line can be represented by its two endpoints instead of every point along the line.
- 59
How can the number of detected contours be determined?
Model answer
Take the length of the contour list returned by
cv.findContours.Explanation
Each item in the list represents one detected contour.
- 60
What is a color space?
Model answer
A color space is a system for representing the colors or pixel values in an image.
Explanation
Examples include BGR, RGB, grayscale, HSV, and LAB.
- 61
What is OpenCV's default color ordering when reading images?
Model answer
OpenCV reads color images in BGR order: blue, green, and red.
Explanation
This differs from the RGB ordering commonly used by other libraries.
- 62
What does HSV stand for, and why is it useful?
Model answer
HSV stands for hue, saturation, and value, and represents color in a way that is more closely related to how humans describe color.
Explanation
HSV separates the type and strength of color from brightness.
- 63
Why can an OpenCV image appear to have inverted colors in Matplotlib?
Model answer
OpenCV supplies BGR data, while Matplotlib interprets the same array as RGB.
Explanation
The channel order must be converted from BGR to RGB before displaying the image with Matplotlib.
- 64
How can a BGR image be converted for correct RGB display?
Model answer
Use
cv.cvtColorwith the BGR-to-RGB conversion code.Explanation
This swaps the blue and red channel positions.
- 65
Can a grayscale image be converted directly to HSV in the described workflow?
Model answer
No; it should first be converted from grayscale to BGR and then from BGR to HSV.
Explanation
The workflow uses BGR as the intermediate color representation.
- 66
What does
cv.splitdo to a color image?Model answer
It separates the image into individual blue, green, and red channel arrays.
Explanation
Each resulting channel is a one-channel intensity image.
- 67
Why are individual color channels displayed as grayscale images?
Model answer
Each channel contains only one intensity value per pixel, so OpenCV displays it as a one-channel grayscale image.
Explanation
Brighter regions indicate a higher concentration of that channel's color.
- 68
What does a bright region in a blue-channel image indicate?
Model answer
It indicates a high concentration of blue intensity in that region of the original image.
Explanation
Dark regions contain relatively little blue intensity.
- 69
How are separate color channels recombined?
Model answer
Use
cv.mergewith the blue, green, and red channel arrays.Explanation
Merging the original channels reconstructs the color image.
- 70
What is the purpose of averaging blur?
Model answer
It replaces the center pixel with the average of the surrounding pixel intensities within a kernel.
Explanation
The kernel slides across the image and performs the same calculation at each position.
- 71
What is a blur kernel?
Model answer
A kernel is a window of neighboring pixels used to calculate a new value for the center pixel.
Explanation
A kernel size such as 3×3 specifies its rows and columns.
- 72
How does Gaussian blur differ from averaging blur?
Model answer
Gaussian blur assigns different weights to neighboring pixels instead of treating every surrounding pixel equally.
Explanation
It generally produces a more natural blur and often less overall blurring than simple averaging.
- 73
How does median blur calculate the center pixel?
Model answer
It replaces the center pixel with the median of the neighboring pixel values.
Explanation
Median blur is effective for reducing noise, including salt-and-pepper noise.
- 74
Why is bilateral filtering useful?
Model answer
It smooths an image while preserving important edges.
Explanation
Unlike many traditional blurs, it considers edge information during the smoothing process.
- 75
What do
sigmaColorandsigmaSpacecontrol in bilateral filtering?Model answer
sigmaColorcontrols how different neighboring colors may influence one another, whilesigmaSpacecontrols how far spatially separated pixels may influence the calculation.Explanation
Larger values allow more colors or more distant pixels to contribute to the blur.
- 76
What are the four basic bitwise operators discussed for image processing?
Model answer
The operators are AND, OR, XOR, and NOT.
Explanation
They operate on binary pixel representations and are especially useful when creating masks.
- 77
How are pixel values interpreted in the binary bitwise examples?
Model answer
A value of zero represents an off or black pixel, while a nonzero binary foreground value represents an on or white pixel.
Explanation
The examples use binary-shaped images to demonstrate logical operations.
- 78
What region does bitwise AND return when applied to two shapes?
Model answer
It returns only the region shared by both shapes.
Explanation
The result is the intersection of the two binary images.
- 79
What region does bitwise OR return?
Model answer
It returns both the shared region and the regions belonging to either input shape.
Explanation
The result is the union of the two binary images.
- 80
What region does bitwise XOR return?
Model answer
It returns pixels that belong to one input shape but not both.
Explanation
The shared intersection is excluded.
- 81
What does bitwise NOT do?
Model answer
It inverts the binary image, changing white pixels to black and black pixels to white.
Explanation
Unlike AND, OR, and XOR, NOT operates on a single source image.
- 82
What is image masking used for?
Model answer
Masking isolates selected parts of an image while excluding unwanted regions.
Explanation
For example, a mask can focus processing on people's faces.
- 83
What must be true about a mask's dimensions?
Model answer
The mask must have the same dimensions as the image being masked.
Explanation
A mismatch causes the bitwise masking operation to fail.
- 84
How can a circular mask be applied to an image?
Model answer
Create a binary circle on a blank image and use it as the mask in a bitwise AND operation with the source image.
Explanation
Only the intersection between the source image and the white region of the mask remains visible.
- 85
What does an image histogram show?
Model answer
It shows the distribution of pixel intensities in an image.
Explanation
Histograms can describe grayscale images, individual color channels, or selected masked regions.
- 86
What do histogram bins represent?
Model answer
Bins represent intervals of possible pixel-intensity values.
Explanation
The height of a bin indicates how many pixels fall within that intensity interval.
- 87
What intensity range is commonly used for an 8-bit grayscale histogram?
Model answer
The range is from 0 through 255, represented computationally by the interval [0,256).
Explanation
An 8-bit pixel can take 256 possible intensity values.
- 88
How is a color histogram different from a grayscale histogram?
Model answer
A color histogram separately represents the intensity distribution of each color channel.
Explanation
For a BGR image, separate distributions are computed for blue, green, and red.
- 89
How can a histogram be computed for only part of an image?
Model answer
Supply a binary mask so that the histogram calculation includes only pixels within the masked region.
Explanation
This allows analysis of local rather than whole-image intensity distributions.
- 90
What is thresholding?
Model answer
Thresholding converts an image into a binary representation in which pixels are assigned to black or white categories.
Explanation
It is commonly used to separate regions based on pixel intensity.
- 91
How does simple binary thresholding classify pixels?
Model answer
Pixels above the chosen threshold are assigned the maximum value, while pixels at or below it are assigned zero.
Explanation
This produces a binary image using one manually selected threshold.
- 92
What is inverse binary thresholding?
Model answer
It assigns the maximum value to pixels below the threshold and zero to pixels above it.
Explanation
It reverses the black-and-white result of ordinary binary thresholding.
- 93
What is the main limitation of simple thresholding?
Model answer
It requires the programmer to choose a single threshold value manually.
Explanation
One fixed value may not work well when lighting varies across an image.
- 94
How does adaptive thresholding choose threshold values?
Model answer
It computes a local threshold for each neighborhood of the image instead of using one global value.
Explanation
This allows different regions to use thresholds suited to their local illumination.
- 95
What is the role of block size in adaptive thresholding?
Model answer
Block size defines the local neighborhood used to calculate each threshold.
Explanation
The neighborhood is treated as a kernel that moves across the image.
- 96
What is the purpose of the constant subtracted in adaptive thresholding?
Model answer
It fine-tunes the local threshold by being subtracted from the neighborhood statistic.
Explanation
Changing this value can alter how much of the image becomes foreground.
- 97
How do mean and Gaussian adaptive thresholding differ?
Model answer
Mean adaptive thresholding uses a local average, whereas Gaussian adaptive thresholding uses a weighted local average.
Explanation
The Gaussian method gives different influence to pixels according to their position in the neighborhood.
- 98
How are gradients related to edges in the course explanation?
Model answer
Gradients are mathematically distinct from edges but can often be treated as edge-like regions for programming purposes.
Explanation
Gradients measure intensity changes that frequently occur at visual boundaries.
- 99
What does the Laplacian method detect?
Model answer
It computes image gradients using second-order intensity changes and highlights edge-like regions.
Explanation
The result often resembles a pencil-shaded representation of image boundaries.
- 100
Why is the absolute value used after computing a Laplacian image?
Model answer
Intensity transitions can produce negative values, but image pixel values cannot directly represent negative intensities.
Explanation
Taking absolute values preserves the magnitude of both positive and negative changes.
- 101
How does the Sobel method calculate gradients?
Model answer
It calculates gradients independently in the horizontal and vertical directions.
Explanation
The two results are commonly called the Sobel x and Sobel y images.
- 102
How can the horizontal and vertical Sobel results be combined?
Model answer
They can be combined with a bitwise OR operation to produce a representation containing edges from both directions.
Explanation
Combining the directional results captures more of the image's gradient structure.
- 103
Why is Canny often preferred over basic Laplacian or Sobel output?
Model answer
Canny is a multistage detector that usually produces cleaner and more refined edge maps.
Explanation
One stage of Canny includes Sobel-based gradient computation.
- 104
What is the difference between face detection and face recognition?
Model answer
Face detection determines whether and where a face is present, whereas face recognition identifies whose face it is.
Explanation
Detection produces locations; recognition assigns identities.
- 105
What is a classifier in face detection?
Model answer
A classifier is an algorithm that decides whether an image region is positive, meaning it contains a face, or negative, meaning it does not.
Explanation
Classifiers are trained using many examples with and without faces.
- 106
Why is grayscale sufficient for the described face detection process?
Model answer
The classifier relies mainly on structural edges rather than skin tone or color information.
Explanation
Removing color reduces the data while preserving useful facial shape information.
- 107
What are Haar cascades?
Model answer
Haar cascades are pretrained classifiers that detect visual objects such as faces by analyzing image features.
Explanation
OpenCV provides pretrained cascade files that can be loaded and used directly.
- 108
What does
detectMultiScalereturn when used with a Haar cascade?Model answer
It returns rectangular coordinates for detected objects in the image.
Explanation
Each rectangle can be used to crop the detected region or draw a box around it.
- 109
What does the scale factor control in
detectMultiScale?Model answer
It controls the scaling between successive image sizes examined by the detector.
Explanation
The detector uses multiple scales to find faces of different sizes.
- 110
What does the minimum-neighbors parameter control?
Model answer
It specifies how much neighboring detection support a candidate rectangle needs before being accepted as a face.
Explanation
Increasing it can reduce false positives but may cause some true faces to be missed.
- 111
Why can Haar cascades detect nonfaces as faces?
Model answer
Haar cascades are sensitive to image noise and structures that resemble facial patterns.
Explanation
Objects such as body regions or accessories may sometimes produce false detections.
- 112
How can false detections from a Haar cascade be reduced?
Model answer
Increase the minimum-neighbors value, while recognizing that this may also reduce detection of genuine faces.
Explanation
The adjustment creates a trade-off between sensitivity and resistance to noise.
- 113
What data is needed to train the OpenCV face recognizer described in the course?
Model answer
It requires multiple labeled face images for each person, with a corresponding numerical label for every face.
Explanation
The examples use separate folders containing images of different people.
- 114
Why are labels converted from names to numerical values?
Model answer
Numerical labels create a simple mapping that is easier for the recognizer to process.
Explanation
The numerical label can be the person's index in a list of names.
- 115
How is a face region extracted for training?
Model answer
Detect the face with a Haar cascade and crop the grayscale image using the returned rectangle coordinates.
Explanation
The cropped region becomes one feature example for the recognizer.
- 116
What are the two main lists used to train the face recognizer?
Model answer
The feature list contains face image arrays, and the label list contains the identity associated with each face.
Explanation
The two lists must correspond position by position.
- 117
Why are the feature and label lists converted to NumPy arrays?
Model answer
NumPy arrays provide the structured numerical format required by the recognizer's training method.
Explanation
The recognizer is trained using the arrays of faces and their labels.
- 118
What is the purpose of saving the trained recognizer to a YAML file?
Model answer
Saving allows the trained model to be loaded and used later without repeating the entire training process.
Explanation
The saved file stores the recognizer's learned information.
- 119
How does the recognizer make a prediction on a new image?
Model answer
It detects and crops the face, passes the face region to the trained recognizer, and returns a predicted label and confidence value.
Explanation
The numerical label is mapped back to the corresponding person's name.
- 120
Why might the built-in face recognizer produce unreliable identities?
Model answer
Its performance is limited by factors such as the small training set, image variation, pose, accessories, and model limitations.
Explanation
A recognizer trained on only about one hundred images is unlikely to generalize perfectly.
- 121
Why can a deep learning model improve face or character classification?
Model answer
Deep learning models can learn complex visual features and generally outperform simple traditional recognition methods when enough data is available.
Explanation
The course presents deep learning as a stronger approach for advanced computer vision tasks.
- 122
Why is a GPU useful when training a deep learning model?
Model answer
A GPU accelerates the numerical computations required during network training.
Explanation
Training can be performed without a GPU, but it is usually slower.
- 123
What preprocessing is applied to the Simpsons images before training?
Model answer
The images are read, converted to grayscale, resized to a common size, and normalized before being given to the model.
Explanation
OpenCV is used mainly for reading and resizing the images in the described model.
- 124
Why must all images supplied to the model have the same size?
Model answer
The network expects its input tensors to have consistent dimensions.
Explanation
Images of different dimensions cannot be combined directly into one training batch.
- 125
What image size and channel count are used in the described Simpsons model?
Model answer
The images are resized to 80×80 pixels and use one grayscale channel.
Explanation
Color is not required for this simplified model.
- 126
Why is image data normalized before model training?
Model answer
Normalization places the input values in a consistent range and can help the network learn more efficiently.
Explanation
The described process normalizes the feature data before training.
- 127
What is one-hot encoding used for in the Simpsons model?
Model answer
It converts numerical class labels into binary class vectors suitable for multiclass classification.
Explanation
Each class receives a vector indicating which character category is correct.
- 128
Why is the dataset divided into training and validation sets?
Model answer
The model learns from the training set and is evaluated on the separate validation set.
Explanation
The validation set provides an estimate of performance on data not used directly for learning.
- 129
What validation ratio is used in the described model?
Model answer
Twenty percent of the data is allocated to validation, leaving eighty percent for training.
Explanation
The split uses a validation ratio of 0.2.
- 130
What is the purpose of an image data generator?
Model answer
It creates varied training examples from existing images, introducing randomness that can improve model performance.
Explanation
This process can help the model generalize beyond the exact training images.
- 131
What does the model's output dimension represent?
Model answer
It represents the number of character classes the model must distinguish.
Explanation
The described model uses ten output classes for the ten selected Simpsons characters.
- 132
What is the purpose of a learning-rate schedule?
Model answer
It changes the learning rate at selected points during training to help optimization.
Explanation
Adjusting the learning rate can improve how the model converges.
- 133
How is a new test image prepared before classification?
Model answer
It is converted to grayscale, resized to the model's required dimensions, reshaped into the expected tensor form, and passed to the model.
Explanation
The test image must undergo compatible preprocessing with the training images.
- 134
Why can a model with a stated validation accuracy still misclassify individual images?
Model answer
Overall validation accuracy summarizes performance across many examples and does not guarantee a correct prediction for every new image.
Explanation
Misclassification can result from image variation, limited data, or an imperfect model architecture.

Ask anything
We've read this whole study set, so questions about it get the best answers.