Non-Maximum Suppression and Its Variants
Standard NMS: Non-Maximum Suppression removes redundant detection boxes by suppressing non-maximum scored boxes based on an Intersection over Union (IoU) threshold.
Limitations:
- Requires a manually set IoU threshold, which critically impacts detection performance for overlapping objects.
- Hard suppression: boxes below the threshold have their scores set directly to zero.
- Typically runs on the CPU, creating a computational bottleneck.
Improvement Directions:
- Adaptive Thresholding: Dynamically adjust the suppression threshold based on object density (e.g., Adaptive NMS).
- Soft Suppression: Gradually decay the scores of neighboring boxes based on their IoU instead of hard removal (e.g., Soft NMS, Softer NMS).
- Hardware Acceleration: Implement GPU-accelerated versions (e.g., CUDA NMS) or design faster algorithms (e.g., Fast NMS). Neural network-based suppression methods like ConvNMS also exist.
- Improved IoU Metrics: Incorporate object scale and centroid distance in to the suppression criterion (e.g., DIoU).
Multi-Class NMS: Boxes from one class should not be suppressed due to high IoU with the highest-scoring box from a different class.
Weighted NMS: Performs weighted averaging of box coordinates based on neighboring box scores.
DIoU-NMS: Uses the Distance-IoU metric, wich adds a penalty term based on the normalized distance between box centers. The formula is:
DIoU = IoU - d²/c²,
where d is the Euclidean distance between centroids and c is the diagonal length of the smallest enclosing box. A parameter β controls the influence of the distance penalty.
GIoU: Generalizes IoU by considering the area of the smallest enclosing box. Its value ranges between -1 and 1, making it less suitable as a direct NMS threshold but useful for bounding box regression.
Loss Functions and Their Variants
Loss functions measure the discrepancy between model predictions and ground truth, guiding model optimization.
Classification Losses
Cross-Entropy / Softmax Loss: Standard loss for multi-class classification. Excels at maximizing inter-class separation but is less effective at reducing intra-class variance.
Weighted Softmax Loss: Applies class-specific weights to address severe class imbalance. For example, in edge detection, pixels belonging to edges can be assigned a higher weight than non-edge pixels.
Focal Loss: Designed for class imbalance. It reduces the relative loss for well-classified examples, focusing training on hard negatives. The modulating factor (1 - p_t)^γ down-weights easy examples, where p_t is the model's estimated probability for the true class.
CTC Loss: Used for sequence prediction tasks where the alignment between input and output is unknown, such as speech recognition or handwritten text recognition.
Regression Losses
L1 Loss (MAE): Computes the mean absolute error. Produces sparse solutions but has a discontinuous gradient at zero.
L2 Loss (MSE): Computes the mean squared error. Provides smooth gradients but can be sensitive to outliers due to the squared term.
Smooth L1 Loss: A hybrid that behaves like L2 loss for small errors and L1 loss for large errors, combining the benefits of both.
Huber Loss: Similar to Smooth L1, robust to outliers. It requires setting an additional delta parameter.
IoU Loss: Directly optimizes the IoU metric for bounding box regression, aligning the optimization objective with the evaluation metric.
Activation Functions
- Sigmoid: Squashes outputs to (0, 1). Prone to vanishing gradients.
- ReLU:
f(x) = max(0, x). Computationally efficient but can cause dead neurons. - Tanh: Outputs range from -1 to 1, centered at zero.
- Softmax: Normalizes a vector of values into a probability distribution.
Normalization Techniques
- Batch Norm (BN): Normalizes activations across the batch dimension. Effective but dependent on batch statistics.
- Layer Norm (LN): Normalizes across the feature dimension for each sample. Common in transformers and RNNs.
- Instance Norm (IN): Normalizes each channel separate for each sample. Often used in style transfer.
- Group Norm (GN): Divides channels into groups and normalizes within each group. Independent of batch size.
Convolution and Pooling
Convolution: The standard operation for feature extraction. Lacks strict translation invariance in practice due to boundary effects and striding.
Pooling Operations:
- Average Pooling: Reduces variance and overfitting, preserves background information.
- Max Pooling: Extracts prominent texture features, discards less salient information. Requires storing indices for backpropagation.
- Global Pooling: Aggregates spatial information into a single vector per channel, capturing global context. A common strategy is to use max pooling in early layers and average pooling in later layers.
Optimization Algorithms
- Stochastic Gradient Descent (SGD): Updates parameters using the gradient of a single batch.
- SGD with Momentum: Accumulates a velocity vector to smooth updates and accelerate convergence.
- Adagrad: Adapts the learning rate per parameter based on historical gradients.
- Adam: Combines ideas from Momentum and Adagrad, with adaptive learning rates and bias correction.
Addressing Model Training Issues
Underfitting Solutions:
- Increase model complexity or depth.
- Add more relevant features.
- Reduce regularization strength.
- Train for more epochs.
Class Imbalance Techniques:
- Oversample the minority class.
- Undersample the majority class.
- Generate synthetic samples for the minority class (e.g., SMOTE).
Reasons for Training Non-Convergence:
- Lack of data normalization or preprocessing.
- Inappropriate learning rate or batch size.
- Incorrect final layer activation function.
- Vanishing/exploding gradients (e.g., from saturated ReLUs).
- Poor weight initialization.
- Incorrect network architecture (too shallow or deep).
- Noisy or incorrect data labels.
Benefits of Small Convolutional Kernels:
- Increase network depth for a given receptive field, improving representational capacity.
- Drastically reduce the number of parameters.
Purpose of Data Standardization:
- Scales features to a common range, accelerating convergence.
- Mitigates the impact of poorly exposed or low-quality images on weight updates.
Mitigating Vanishing Gradients:
- Use activation functions with non-saturating gradients (ReLU, ELU).
- Employ normalization layers (Batch Norm, Layer Norm).
- Use careful weight initialization schemes.
Challenges in Small Object Detection
Difficulties:
- Small objects occupy few pixels on feature maps after downsampling.
- Often underrepresented in datasets.
- Learning can be dominated by larger objects.
Potential Solutions:
- Data augmentation (e.g., image scaling, mosaic).
- Multi-scale feature fusion (FPN, PANet).
- Tailored training strategies (e.g., copy-paste augmentation).
- Designing denser and smaller anchor boxes.
- Using GANs to super-resolve small regions.
- Modified IoU losses for dense occlusion.
- Adaptive matching strategies with lower IoU thresholds for small objects.