CV Libraries & Frameworks MCQ
OpenCV, PyTorch torchvision, and TensorFlow/Keras vision APIs for production workflows.
OpenCV MCQ
OpenCV essentials
OpenCV provides optimized implementations for image I/O, color conversion, geometric transforms, filtering, morphology, feature detection, and video capture. Python's cv2 wraps C++ for speed; BGR is default for historical reasons—not RGB.
BGR vs RGB
cv2.imread stores color images as BGR; swap channels before sending to libraries expecting RGB.
Key ideas
cv2.imread / imwrite
Load/save; flags control color vs grayscale.
cvtColor
BGR↔RGB, BGR↔HSV, grayscale conversions.
resize / warp
Geometry and camera-like remaps.
GaussianBlur / Canny
Smoothing and edge pipelines.
Minimal script
import cv2 → img = cv2.imread(path) → process → cv2.imshow / VideoCapture loop
PyTorch Vision MCQ
torchvision building blocks
torchvision supplies standard vision datasets, composable transforms (including v2 on newer versions), and reference CNN implementations with optional pretrained ImageNet weights. It pairs with torch.utils.data.DataLoader for batched training and evaluation.
Normalize correctly
Use dataset-specific mean/std (e.g. ImageNet) when fine-tuning pretrained backbones.
Key ideas
datasets.ImageFolder
Folder-per-class layout for custom classification.
transforms
Resize, crop, flip, tensorize, normalize.
models.*
resnet, convnext, etc. with weights enums.
DataLoader
Batching, shuffle, num_workers for throughput.
Train loop sketch
dataset + transform → DataLoader → model → loss → optimizer.step()
TensorFlow Vision MCQ
TensorFlow for vision
Use tf.data.Dataset to build efficient input pipelines (map, batch, prefetch). keras.applications provides pretrained CNNs; preprocessing can live in the model via Rescaling / RandomFlip layers for export-friendly graphs. SavedModel packages inference for TF Serving and mobile converters.
Augment in the graph
Keras preprocessing layers keep train and serve transforms aligned when exported.
Key ideas
tf.data
from_tensor_slices, map, batch, prefetch to device.
Rescaling / Augment
Layers for resize, flip, rotate in-model.
applications
ResNet50(include_top=False) feature extractor.
SavedModel
Signatures for serving and TFLite conversion.
Fine-tune pattern
base = Xception(weights='imagenet', include_top=False) → GlobalAveragePooling2D → Dense