8. Image Classification, Detection, and RecognitionIntroduction and ContextComputer vision systems rarely stop at determining whether an image contains useful visual information. In practical applications, a system may need to identify the category of an entire image, locate several objects, recognize a particular person, estimate human body configuration, read text, or distinguish between visually similar classes. These tasks are related, but they are not interchangeable. Their differences affect the choice of architecture, annotation strategy, loss function, evaluation metric, computational platform, and risk-management procedure. Image classification assigns one or more labels to an image or image region. Localization adds the position of a principal object. Object detection identifies multiple objects and returns a class label and bounding box for each. Recognition tasks, such as face recognition and fine-grained recognition, often require identity-level or subordinate-category decisions. Pose estimation predicts structured keypoints, while optical character recognition (OCR) converts visual symbols into text. Modern systems are predominantly based on deep neural networks, especially convolutional neural networks (CNNs), vision transformers, and hybrid architectures. Nevertheless, effective deployment requires more than selecting a high-performing model. Data quality, class imbalance, annotation uncertainty, calibration, latency, privacy, fairness, and robustness are equally important. This chapter develops a unified framework for understanding and designing such systems. Learning ObjectivesAfter studying this chapter, students should be able to: 1. Distinguish classification, localization, detection, recognition, pose estimation, OCR, and fine-grained recognition. 2. Select suitable architectures, annotations, losses, datasets, and metrics for different visual tasks. 3. Explain the operation of one-stage and two-stage detection systems. 4. Design evaluation procedures using IoU, precision, recall, average precision, mean average precision, and task-specific metrics. 5. Analyze practical trade-offs involving accuracy, speed, data requirements, privacy, and deployment constraints. 6. Identify common failure modes and propose technically and ethically responsible solutions. A Task-Oriented View of Visual RecognitionThe central distinction among visual tasks is the structure of the required output. A classifier may produce a probability vector over classes, while a detector produces a variable-length set of tuples containing class, confidence, and spatial coordinates. A pose estimator produces keypoints or heat maps, and an OCR system produces a sequence of characters or words. Thus, the task determines both the representation and the learning objective. ClassificationIn single-label classification, an image belongs to one class from a mutually exclusive set. A softmax output is commonly used, with categorical cross-entropy as the loss: L = - sum over c of y_c log(p_c) where y_c is the target indicator and p_c is the predicted probability for class c. Multi-label classification differs because several labels may be simultaneously true; sigmoid outputs and binary cross-entropy are more appropriate. Classification may be image-level or region-level. It is suitable for applications such as defect category recognition, plant disease identification, medical image triage, and scene classification. However, classification alone cannot indicate where an object occurs or how many instances are present. Localization and Object DetectionLocalization predicts the position of one principal object, usually through a bounding box represented by its centre, width, and height or by corner coordinates. Object detection extends this task to multiple objects and categories. Each predicted box must be matched with a ground-truth box, and the system must decide both what is present and where it is located. Intersection over Union (IoU) measures spatial overlap: IoU = area of intersection / area of union. A prediction is often considered a true positive when its class is correct and its IoU exceeds a selected threshold. Detection is therefore a joint classification-and-regression problem, complicated by varying object sizes, occlusion, crowding, and background clutter. Recognition and IdentificationRecognition generally refers to determining whether an observed instance corresponds to a known category or identity. Face verification asks whether two images show the same person; face identification searches a gallery for the most likely identity. These are different from ordinary classification because the set of identities may be large, dynamic, or only partially represented during training. Metric-learning methods learn embeddings in which similar instances are close and dissimilar instances are separated. Contrastive loss operates on pairs, whereas triplet loss uses an anchor, a positive example, and a negative example. Modern face systems often use margin-based classification losses, which improve angular separation between identities. Pose EstimationHuman pose estimation predicts anatomical keypoints such as shoulders, elbows, hips, and ankles. In top-down systems, a detector first identifies each person and a pose model estimates keypoints within each crop. Bottom-up systems detect keypoints across the image and associate them into individuals. Heat-map regression, coordinate regression, and transformer-based set prediction are common approaches. Pose estimation supports activity analysis, sports technology, rehabilitation, animation, and human–computer interaction. Its difficulty increases with self-occlusion, unusual viewpoints, loose clothing, crowded scenes, and ambiguous joints. Optical Character RecognitionOCR converts text in images into machine-readable symbols. A complete OCR pipeline may include image acquisition, geometric correction, text detection, line or word recognition, language modelling, and post-processing. Recognition can be character-based, word-based, or sequence-based. Connectionist temporal classification (CTC) is useful when character-level alignment is unknown; encoder–decoder and transformer models can directly predict text sequences. OCR quality depends on resolution, typography, illumination, perspective, language, script, and layout. Reading a clean scanned document is substantially different from reading a storefront sign, a vehicle plate, or handwritten text. Fine-Grained RecognitionFine-grained recognition distinguishes subordinate categories with small visual differences, such as bird species, vehicle models, plant varieties, or product versions. Discriminative evidence may be concentrated in local regions, including a bird’s wing pattern or a vehicle’s grille. Bilinear feature pooling, part-based models, attention mechanisms, high-resolution inputs, and expert annotation are useful strategies. Fine-grained systems are especially sensitive to domain shift. A model trained on professionally photographed products may fail on mobile-phone images, unusual viewpoints, or damaged objects. Architectures and Learning StrategiesConvolutional and Transformer BackbonesCNNs exploit local connectivity and weight sharing. Their hierarchical feature maps capture edges, textures, parts, and semantic structures. Residual connections make very deep networks easier to optimize. Feature pyramids combine information from different spatial resolutions, which is particularly valuable for detecting small objects. Vision transformers divide an image into patches and use attention to model relationships among distant regions. They can provide strong global representations, especially when pretrained on large datasets, but may require substantial data and computation. Hybrid systems combine convolutional inductive biases with attention-based context modelling. Classification Heads and Transfer LearningA practical classifier often consists of a pretrained backbone and a task-specific head. Transfer learning is valuable when the target dataset is smaller than a general-purpose pretraining corpus. A common procedure is to freeze the backbone initially, train the head, and then fine-tune selected or all layers using a smaller learning rate. Data augmentation, label smoothing, class weighting, focal loss, and calibration can address overfitting, imbalance, and overconfidence. Detection ArchitecturesTwo-stage detectors first generate region proposals and then classify and refine them. They generally offer strong localization accuracy and flexibility, particularly for crowded or difficult scenes, but their inference pipeline can be slower. One-stage detectors predict classes and boxes directly over dense locations or queries. They are usually attractive for real-time applications because they reduce proposal-processing overhead. Their design must address the imbalance between many background locations and relatively few objects. Focal loss reduces the contribution of easy negatives by assigning greater relative importance to difficult examples. Anchor-based detectors use predefined boxes at different scales and aspect ratios. Anchor-free detectors predict centres, corners, distances, or object extents without such templates. Transformer-based detectors formulate detection as set prediction and use bipartite matching to associate predictions with targets, reducing reliance on hand-designed post-processing. Bounding-Box and Classification LossesDetection losses usually combine classification, objectness, and localization terms: L_total = L_class + lambda_1 L_objectness + lambda_2 L_box. Box regression may use coordinate loss, IoU loss, generalized IoU, distance IoU, or complete IoU. IoU-based losses directly reflect overlap quality and are often preferable to independent coordinate errors. The coefficients must be tuned so that no component dominates training. Non-maximum suppression (NMS) removes duplicate predictions. It retains the highest-confidence box and suppresses boxes with excessive overlap. Soft-NMS reduces scores rather than eliminating boxes outright and can be useful in crowded scenes. Suppression thresholds should be treated as deployment parameters, not universal constants. Data, Annotation, and EvaluationA robust system begins with a dataset that represents the intended operating environment. Classification requires image-level labels; detection requires boxes and class labels; segmentation requires pixel masks; pose estimation requires keypoints and visibility flags; OCR requires transcriptions and often text regions. Annotation quality and consistency frequently limit performance more than architectural sophistication. Datasets should be divided into training, validation, and test sets without leakage. Near-duplicate frames from the same video, images of the same subject, or repeated product photographs should not be distributed across splits in a way that inflates performance. Stratification should consider class, location, device, demographic group, weather, and other relevant sources of variation. For classification, accuracy is informative under balanced classes, but precision, recall, F1 score, balanced accuracy, and area under the precision–recall curve are often more appropriate under imbalance. A confusion matrix reveals systematic confusions. Calibration measures whether predicted probabilities correspond to observed frequencies; a high-accuracy but poorly calibrated model may be unsafe in decision-support settings. Detection commonly uses average precision (AP), calculated from the precision–recall curve for a class at a specified IoU threshold. Mean average precision (mAP) averages AP across classes and, depending on the evaluation protocol, across several IoU thresholds. Reporting only one aggregate number conceals performance differences between small and large objects or between common and rare classes. Recall at an operational false-positive rate may be more relevant than mAP in safety-critical inspection. Pose estimation is frequently evaluated using keypoint similarity or percentage of correct keypoints. OCR uses character error rate, word error rate, exact-match accuracy, and sometimes sequence-level metrics. Face verification commonly uses receiver operating characteristic curves, false acceptance rate, false rejection rate, and equal error rate. Fine-grained recognition should be reported with per-class results and carefully designed cross-domain tests. From Prototype to DeploymentA production workflow begins with an explicit decision specification: what must be detected, how errors will be handled, what latency is acceptable, and whether the system is advisory or autonomous. Data collection then targets the operational distribution rather than merely convenient examples. Exploratory analysis should identify imbalance, missing labels, annotation ambiguity, and problematic subgroups. Training experiments should use reproducible splits, controlled augmentation, versioned datasets, and experiment tracking. Thresholds must be selected on validation data according to business or safety costs. A detector used to trigger manual review may favour recall, whereas an automated rejection system may require high precision. Post-deployment monitoring should track drift, confidence distributions, false positives, false negatives, and performance across relevant subgroups. Edge deployment introduces constraints involving memory, power, bandwidth, and response time. Quantization, pruning, knowledge distillation, lower-resolution inputs, and hardware-specific compilation can reduce cost. These optimizations may change calibration and accuracy, so the compressed model must be evaluated again in realistic conditions. Applied Case Study: Automated Visual Inspection of Roadside AssetsBackgroundThis illustrative case concerns a municipal transport authority seeking to inspect traffic signs and road-surface defects using cameras mounted on service vehicles. The objective is not merely to classify images as “acceptable” or “unacceptable”; the authority needs the location, category, and severity of each defect. Situation and ProblemInitial photographs contain signs, vehicles, trees, shadows, and pavement. Defects range from large potholes to small cracks. Some signs are partially occluded or viewed at oblique angles. The authority has a limited number of manually labelled images and wants results within a few minutes after a route is completed. AnalysisImage classification would identify whether a frame contains a defect but would not support maintenance prioritization. Object detection is therefore required for potholes, damaged signs, and missing sign components. Small cracks demand high-resolution features, while motion blur and weather create domain variation. False negatives are costly because missed hazards remain unreported, but excessive false positives waste inspection resources. ApproachThe team first defines an annotation protocol specifying defect categories, box placement, borderline cases, and severity rules. Video frames are sampled while ensuring that adjacent frames from the same route do not appear in both training and test sets. A pretrained detector with a feature pyramid is fine-tuned using class-balanced sampling and augmentation for blur, brightness, and perspective changes. IoU-based box loss is combined with classification and objectness losses. The validation process reports mAP by object size, recall at the review threshold, and performance across weather conditions. Predictions are temporally associated across adjacent frames to reduce unstable alerts. A human inspector reviews low-confidence detections. Quantization is tested on the vehicle computer, and the final threshold is chosen according to the maintenance team’s capacity. OutcomeThe resulting workflow provides defect locations and confidence scores rather than an unsupported binary decision. Route-level reports group repeated observations of the same defect, reducing duplicate work orders. Monitoring continues because new road materials, camera replacements, and seasonal conditions may change the input distribution. Learning PointsThe case demonstrates that deployment success depends on task formulation, annotation policy, evaluation design, threshold selection, and workflow integration. A higher benchmark score would not automatically produce a better municipal service if the system generated unmanageable alerts or failed on rare but important defects. Challenges, Risks, and Common MistakesA frequent mistake is confusing image-level accuracy with useful operational performance. A classifier may perform well because the background, camera, or watermark correlates with the label. This is shortcut learning rather than robust visual understanding. Another error is using random image splits for video or subject data, causing leakage. Class imbalance can lead a model to ignore rare categories. Oversampling may help but can also overfit duplicated examples. Synthetic augmentation should preserve the semantics of the task; unrealistic transformations can create invalid training data. Label noise should be measured and managed rather than silently treated as ground truth. Detection systems may miss small, occluded, or overlapping objects. OCR can produce plausible but incorrect text, which is dangerous when used for legal documents or identity records. Face recognition can be affected by illumination, pose, image quality, and demographic variation. A single aggregate metric cannot establish fairness or reliability. Adversarial patches, image manipulation, sensor failure, and distribution shift create security and robustness risks. Systems should use input validation, confidence-aware review, out-of-distribution analysis where feasible, and fallback procedures. Human review is not a substitute for system quality, but it can reduce the consequences of uncertain predictions when responsibilities are clearly assigned. Ethical, Governance, and Professional ConsiderationsFace recognition and biometric identification require particular caution. Organisations should establish a lawful purpose, data-minimization policy, retention limit, access control, audit trail, and procedure for correcting errors. Consent and jurisdiction-specific regulation may be relevant. Identity predictions should not be treated as unquestionable evidence, especially in high-impact contexts. OCR and visual analytics may process personal information, vehicle plates, medical records, or workplace activity. Privacy-preserving collection, encryption, controlled model access, and secure deletion are therefore part of system design. Dataset documentation should record provenance, intended use, known gaps, annotation procedures, and restrictions. Professional practice requires reporting uncertainty and subgroup performance, not only the most favourable result. If a system influences employment, healthcare, education, policing, or access to services, governance should include impact assessment, appeal mechanisms, human accountability, and continuous monitoring. Current Developments and Best PracticesCurrent research increasingly combines large-scale visual pretraining with task-specific adaptation. Vision-language models support open-vocabulary recognition, image–text retrieval, and prompt-based classification, although their outputs may be poorly calibrated and difficult to audit. Open-vocabulary detection attempts to identify categories not explicitly fixed during conventional training. Self-supervised learning reduces dependence on manual labels by learning from relationships within unlabelled images or video. Other important directions include multimodal foundation models, efficient edge inference, 3D and video recognition, neural rendering, synthetic data, active learning, and uncertainty estimation. These developments do not remove the need for carefully defined tasks and representative evaluation. The following practices are broadly defensible: - define the decision and error costs before selecting a model;
- collect data from the real deployment environment;
- prevent subject, route, and near-duplicate leakage;
- document annotation rules and measure label quality;
- report class-wise, subgroup-wise, and condition-wise performance;
- calibrate thresholds for the intended workflow;
- test robustness, latency, privacy, and security before release;
- monitor drift and create a process for retraining or withdrawal.
Chapter SummaryVisual recognition is a family of related but distinct tasks. Classification predicts image-level labels; localization and detection add spatial information; recognition addresses instances or identities; pose estimation predicts structured body keypoints; OCR converts visual text into sequences; and fine-grained recognition distinguishes closely related categories. Each task requires suitable annotations, architectures, losses, and metrics. CNNs, feature pyramids, transformers, metric-learning models, heat-map methods, and sequence recognizers provide complementary tools. Detection combines classification, objectness, and box regression, while NMS and threshold selection influence practical behaviour. Evaluation must go beyond aggregate accuracy to include IoU, AP, mAP, calibration, subgroup performance, latency, and operational error costs. Successful deployment depends on representative data, leakage-free testing, monitoring, privacy protection, fairness analysis, and human accountability. Key TermsClassification: Assigning one or more semantic labels to an image or region. Localization: Predicting the position of a principal object in an image. Object detection: Identifying multiple object instances with class labels and bounding boxes. Intersection over Union (IoU): The ratio of overlap area to combined area of predicted and ground-truth regions. Bounding box: A rectangular spatial representation surrounding an object. Non-maximum suppression: A procedure that removes duplicate overlapping detections. Metric learning: Learning an embedding space in which similar instances are close and dissimilar instances are separated. Face verification: Determining whether two face images belong to the same person. Face identification: Matching a face against a gallery of known identities. Pose estimation: Predicting anatomical keypoints or body configuration. Optical character recognition: Converting visual text into machine-readable characters or sequences. Fine-grained recognition: Distinguishing visually similar subordinate categories. Average precision: The area-based summary of a class-specific precision–recall curve. Mean average precision: The mean of average precision values across classes or evaluation conditions. Focal loss: A classification loss that reduces the influence of easy examples and emphasizes difficult ones. Calibration: Agreement between predicted probabilities and observed frequencies. Transfer learning: Adapting knowledge learned from one dataset or task to another. Distribution shift: A change between training data conditions and deployment data conditions. Feature pyramid: A multiscale representation used to detect objects of different sizes. Connectionist temporal classification: A sequence-learning objective that handles unknown alignment between inputs and output labels. Review QuestionsShort Answer Questions1. How does multi-label classification differ from single-label classification? 2. Define IoU and explain its role in object detection. 3. What is the purpose of non-maximum suppression? 4. Distinguish face verification from face identification. 5. Why is calibration important in a decision-support system? Long Answer Questions1. Compare one-stage and two-stage object detectors, including their computational and accuracy trade-offs. 2. Explain how annotations, losses, and metrics should be selected for classification, detection, pose estimation, and OCR. 3. Discuss the role of transfer learning, data augmentation, and feature pyramids in visual recognition systems. 4. Explain the principal sources of error in fine-grained recognition and propose ways to reduce them. 5. Describe a complete workflow for deploying a computer-vision model from data collection through monitoring. Analytical / Application Questions1. A detector has high mAP but misses nearly all small objects. What diagnostic analyses and architectural or data changes would you recommend? 2. Design an evaluation plan for a face-verification system used to control access to a secure facility, including error costs, privacy, and subgroup analysis. 3. An OCR system performs well on scanned documents but poorly on mobile photographs of signs. Analyse the likely causes and propose a revised data, model, and deployment strategy. 22. Multiple Choice Questions with AnswersQuestion 1A system must identify every vehicle in an image and return each vehicle’s location. Which task is most appropriate? A. Single-label image classification B. Object detection C. Face verification D. Image denoising Correct Answer: B. Object detection Question 2Why are sigmoid outputs generally preferred to softmax outputs for multi-label image classification? A. Sigmoid permits several labels to be independently active B. Sigmoid always produces calibrated probabilities C. Softmax cannot be optimized with gradient descent D. Sigmoid removes the need for labelled data Correct Answer: A. Sigmoid permits several labels to be independently active Question 3Which measure directly quantifies the overlap between a predicted bounding box and a ground-truth box? A. F1 score B. Character error rate C. Intersection over Union D. Equal error rate Correct Answer: C. Intersection over Union Question 4A detector produces many overlapping boxes for the same object. Which operation is commonly used to reduce duplicate predictions? A. Batch normalization B. Non-maximum suppression C. Random cropping D. Triplet sampling Correct Answer: B. Non-maximum suppression Question 5What is the principal purpose of focal loss in dense object detection? A. To increase the resolution of input images B. To emphasize difficult examples relative to easy negatives C. To convert bounding boxes into keypoints D. To enforce temporal consistency in video Correct Answer: B. To emphasize difficult examples relative to easy negatives Question 6Which evaluation approach is most likely to reveal leakage in a video-based dataset? A. Randomly splitting individual frames without checking their source B. Splitting data by route or video before sampling frames C. Reporting only overall accuracy D. Increasing the number of training epochs Correct Answer: B. Splitting data by route or video before sampling frames Question 7In face recognition, what does face verification determine? A. Whether an image contains any object B. Whether two face images represent the same person C. Which body joints are visible D. Which text script appears in an image Correct Answer: B. Whether two face images represent the same person Question 8Which approach is especially suitable when OCR training data lacks explicit character-to-image alignment? A. Connectionist temporal classification B. Non-maximum suppression C. IoU thresholding alone D. Image-level softmax classification only Correct Answer: A. Connectionist temporal classification Question 9A model has high accuracy on common classes but performs poorly on rare safety-critical classes. Which response is most appropriate? A. Report only the aggregate accuracy B. Remove the rare classes from evaluation C. Use class-wise metrics and consider reweighting or targeted data collection D. Lower the image resolution Correct Answer: C. Use class-wise metrics and consider reweighting or targeted data collection Question 10Why can a model with strong benchmark performance still fail after deployment? A. Deployment data may differ from training data because of distribution shift B. Benchmark models never use neural networks C. IoU is unrelated to object detection D. Pretrained models cannot be fine-tuned Correct Answer: A. Deployment data may differ from training data because of distribution shift
|