Table of Contents
Fetching ...

CSPCL: Category Semantic Prior Contrastive Learning for Deformable DETR-Based Prohibited Item Detectors

Mingyuan Li, Tong Jia, Hao Wang, Bowen Ma, Hui Lu, Shiyi Guo, Da Cai, Dongyue Chen

TL;DR

CSPCL tackles foreground-background coupling in X-ray prohibited-item detection by aligning decoder content queries with category semantic priors using a novel CSP loss. The ITA component gradually attracts intra-class queries toward class prototypes while preserving diversity via gradient truncation, and the IAR component adaptively repels inter-class queries based on prototype similarity to sharpen discrimination among similar categories. This plug-and-play mechanism improves Deformable DETR-based detectors across multiple architectures and datasets without increasing inference cost, as demonstrated on PIXray, OPIXray, PIDray, and CLCXray. The approach yields better foreground feature perception under heavy overlap and offers interpretable visualization of how content queries align with semantic priors, underscoring its practical impact for security screening systems.

Abstract

Prohibited item detection based on X-ray images is one of the most effective security inspection methods. However, the foreground-background feature coupling caused by the overlapping phenomenon specific to X-ray images makes general detectors designed for natural images perform poorly. To address this issue, we propose a Category Semantic Prior Contrastive Learning (CSPCL) mechanism, which aligns the class prototypes perceived by the classifier with the content queries to correct and supplement the missing semantic information responsible for classification, thereby enhancing the model sensitivity to foreground features. To achieve this alignment, we design a specific contrastive loss, CSP loss, which comprises the Intra-Class Truncated Attraction (ITA) loss and the Inter-Class Adaptive Repulsion (IAR) loss, and outperforms classic contrastive losses. Specifically, the ITA loss leverages class prototypes to attract intra-class content queries and preserves essential intra-class diversity via a gradient truncation function. The IAR loss employs class prototypes to adaptively repel inter-class content queries, with the repulsion strength scaled by prototype-prototype similarity, thereby improving inter-class discriminability, especially among similar categories. CSPCL is general and can be easily integrated into Deformable DETR-based models. Extensive experiments on the PIXray, OPIXray, PIDray, and CLCXray datasets demonstrate that CSPCL significantly enhances the performance of various state-of-the-art models without increasing inference complexity. The code is publicly available at https://github.com/Limingyuan001/CSPCL.

CSPCL: Category Semantic Prior Contrastive Learning for Deformable DETR-Based Prohibited Item Detectors

TL;DR

CSPCL tackles foreground-background coupling in X-ray prohibited-item detection by aligning decoder content queries with category semantic priors using a novel CSP loss. The ITA component gradually attracts intra-class queries toward class prototypes while preserving diversity via gradient truncation, and the IAR component adaptively repels inter-class queries based on prototype similarity to sharpen discrimination among similar categories. This plug-and-play mechanism improves Deformable DETR-based detectors across multiple architectures and datasets without increasing inference cost, as demonstrated on PIXray, OPIXray, PIDray, and CLCXray. The approach yields better foreground feature perception under heavy overlap and offers interpretable visualization of how content queries align with semantic priors, underscoring its practical impact for security screening systems.

Abstract

Prohibited item detection based on X-ray images is one of the most effective security inspection methods. However, the foreground-background feature coupling caused by the overlapping phenomenon specific to X-ray images makes general detectors designed for natural images perform poorly. To address this issue, we propose a Category Semantic Prior Contrastive Learning (CSPCL) mechanism, which aligns the class prototypes perceived by the classifier with the content queries to correct and supplement the missing semantic information responsible for classification, thereby enhancing the model sensitivity to foreground features. To achieve this alignment, we design a specific contrastive loss, CSP loss, which comprises the Intra-Class Truncated Attraction (ITA) loss and the Inter-Class Adaptive Repulsion (IAR) loss, and outperforms classic contrastive losses. Specifically, the ITA loss leverages class prototypes to attract intra-class content queries and preserves essential intra-class diversity via a gradient truncation function. The IAR loss employs class prototypes to adaptively repel inter-class content queries, with the repulsion strength scaled by prototype-prototype similarity, thereby improving inter-class discriminability, especially among similar categories. CSPCL is general and can be easily integrated into Deformable DETR-based models. Extensive experiments on the PIXray, OPIXray, PIDray, and CLCXray datasets demonstrate that CSPCL significantly enhances the performance of various state-of-the-art models without increasing inference complexity. The code is publicly available at https://github.com/Limingyuan001/CSPCL.

Paper Structure

This paper contains 17 sections, 12 equations, 6 figures, 11 tables, 1 algorithm.

Figures (6)

  • Figure 1: Feature manifold of saw (red), knife (blue), and fireworks (green). The squares and stars represent the feature representations of prohibited items and content queries, respectively.
  • Figure 2: Illustrating the pipeline of CSPCL plugged into one Deformable DETR Deformable-DETR variant DINO DINO. (a) The overall architecture of DINO. (b) The process of updating content queries in each layer of the decoder. (c) The CSPCL mechanism uses contrastive loss to leverage classifier weights as class prototypes, thereby supplementing and refining the semantic information responsible for classification in the content queries of the decoder at layer $l$.
  • Figure 3: (a) and (b) are the curves of the ITA loss and its derivative, respectively. (c) and (d) are the 3D surface plots of our IAR loss with different $\tau$. The samples A and B have the same $\text{sim}(\mathbf{p}_i^{k_1},\mathbf{q}_j^{k_2})$, but $\text{sim}(\mathbf{p}_i^{k_1},\mathbf{p}_j^{k_2})$ of A is smaller that of B. When $\tau=0.1$, the IAR loss values of A and B are almost the same, but when $\tau=1$, The loss value of A is much smaller than that of B.
  • Figure 4: The t-SNE visualization results of the content queries (dots) and classifier weights (stars) from the first decoder layer. (a) and (b) show the visualization of content queries for DINO and DINO with the CSPCL mechanism, respectively. (c) and (d) show the visualization results of the classifier weights and content queries simultaneously reduced for the two models, DINO and DINO with the CSPCL mechanism, respectively.
  • Figure 5: (a) The scatter plot and Kernel Density Estimation (KDE) joint distribution plot of prediction results of the final decoder layer. Blue and Orange represent the results of DINO and DINO with the CSPCL mechanism, respectively. (b) Visualization of deformable attention sampling points, reference points, and prediction results for corresponding group content queries in the last decoder layer. (i)–(iii) represent different groups. Each sampling point is shown as a filled circle, with color indicating its attention weight, and the reference point is marked by a green cross.
  • ...and 1 more figures