# Image-Level Anti-Personnel Landmine Detection Using Deep Learning in Long-Wave Infrared Images
## 3 Methods
### Multiple Instance Learning  
Multiple instance learning (MIL) is a form of supervised learning where training data is organized into sets called bags, each containing multiple instances. In this framework, only the bag-level label is provided and labels of instances in each bag are unknown. A bag is labeled as positive if at least one of instances within the bag is positive, and negative if all instances are negative. MIL is particularly useful in scenarios where precise annotations at the instance level are expensive or impractical to obtain. By learning from incomplete labeled data, MIL enables models to identify and focus on the most informative instances within each bag, facilitating robust learning under label uncertainty.  
When applying MIL to our problem, the image features extracted by the pre-trained vision foundation model can be regarded as a bag. The features corresponding to the spatial locations of AP landmines (in the case of CNN) or the patch embeddings associated with AP landmines (in the case of ViT) are treated as positive instances, as shown in Figure 4. However, we do not know which feature is associated with an AP landmine as only the image-level label is given, which implies that labels of instances are unknown. Since the number of features related to AP landmines is much smaller than that of features dominated by backgrounds, globally pooling the entire image feature may result in a suboptimal representation for classification. To address this issue, we employ an attention-based MIL (ABMIL) [46] to derive a more discriminative feature, which is then used for image-level detection.  
Let us assume that \(N\) features \(\mathbf{h}_{1},\mathbf{h}_{2},\cdots,\mathbf{h}_{N}\) extracted by a pre-trained model are given. Each feature can be accessed by the spatial index in the case of CNN models or by the patch index in the case of ViT models. In ABMIL [46], a bag-level feature \(\mathbf{z}\in\mathbb{R}^{D\times 1}\), i.e., an aggregation of the given instance-level \(N\) features, is calculated by  
\[\mathbf{z}=\sum_{i=1}^{N}a_{i}\mathbf{h}_{i}, \tag{1}\]  
where \(a_{i}\) denotes the attention value for the \(i\)th instance \(\mathbf{h}_{i}\in\mathbb{R}^{D\times 1}\). Ideally, the attention value should be higher for the features closely related to AP landmines, and lower or near to zero for the rest when an input image contains an AP landmine. The attention value is given by [46]  
\[a_{i}=\frac{exp\{\mathbf{w}^{\mathrm{T}}(\tanh(\mathbf{Vh}_{i})\odot\mathrm{sigm }(\mathbf{Uh}_{i}))\}}{\sum_{j=1}^{N}exp\{\mathbf{w}^{\mathrm{T}}(\tanh(\mathbf{ Vh}_{j})\odot\mathrm{sigm}(\mathbf{Uh}_{j}))\}}, \tag{2}\]  
where \(\mathbf{w}\in\mathbb{R}^{L\times 1}\), \(\mathbf{V}\in\mathbb{R}^{L\times D}\), and \(\mathbf{U}\in\mathbb{R}^{L\times D}\) are learnable parameters with hidden dimension \(L\). \(\odot\) denotes element-wise multiplication. The hyperbolic tangent \(\tanh(\cdot)\) and the sigmoid non-linearity \(\mathrm{sigm}(\cdot)\) in Equation (2) are included for proper gradient flow [46] and gating mechanism [47], respectively. The final image feature \(\mathbf{z}\) in Equation (1) is fed to a linear classifier to generate the classification (image-level detection) output. During fine-tuning, the parameters of the linear classifier, the ABMIL module in Equation (2), and the vision foundation model are jointly updated by minimizing the binary cross entropy loss.