## 4 Conclusions  
To meet the real-time and accurate detection requirements in real contraband scenes, the lightweight algorithm LWMD-YOLOv7 for the detection of contraband in terahertz images is proposed. Aiming at the problems of noises in the background and limited texture features in terahertz images, we pre-processed the original terahertz image dataset using non-local means filtering, histogram equalisation, and wavelet transform (which retains the original terahertz image data and the results of the above methods); we constructed four groups of datasets; and we used the above four groups of datasets to train the YOLOv7 network. The results show that the YOLOv7 network achieves the best results for the terahertz image data after non-local means filtering processing. Furthermore, the LWMD-YOLOv7 algorithm is proposed, which uses the SPD-Mobile network as the YOLOv7 feature extraction network to construct a low-complexity and high-efficiency detection model. Furthermore, the selective attention mechanism LSK module is incorporated before the output of the YOLOv7 network's multi-scale feature maps to make full use of the contextual information of the targets by using a larger receptive field, which enhances the feature fusion effect and strengthens the network's focus on salient features to reduce the false detection rate due to the similarity of the object's outlines and the lack of texture features in the terahertz images. The accuracy of prediction box localisation is measured using the DIOU training strategy to improve the model's detection accuracy. The experimental results show that the LWMD-YOLOv7 algorithm can significantly improve the detection efficiency compared to YOLOv7 to meet the demand of real-time contraband detection while ensuring high detection accuracy, which provides a technical reference for the automated detection of contrabands in terahertz images.  
Conceptualization, Z.G. and Y.Z.; methodology, Z.G. and Y.Z.; formal analysis, H.G. and Y.J.; resources, Y.Z.; writing--original draft preparation, Z.G.; writing--review and editing, Y.J. and Y.Z.; supervision, Y.Z.; project administration, Y.Z.; funding acquisition, Z.G., Y.Z, Y.J., H.G., X.W., Z.J., H.W. and K.J. All authors have read and agreed to the published version of the manuscript.  
This work was supported by the National Natural Science Foundation of China (Nos. 61975053, 62271191), the Program for Science and Technology Innovation Talents in the Universities of Henan Province (Nos. 22 HASTIT017, 23 HASTIT024), and the Innovative Funds Plan of Henan University of Technology (2021 ZKJC04).  
Not applicable.  
Data Availability Statement: Data is contained within the article.  
The authors declare no conflicts of interest.  
\begin{table}
\begin{tabular}{c c c c c} \hline
**Model** & **P (\%)** & **R (\%)** & **mAP@.5 (\%)** & **mAP@.5:95 (\%)** \\ \hline all & 98.5 & 97.5 & 98.6 & 85.4 \\ \hline scissors & 99.3 & 97.7 & 99.6 & 89.9 \\ \hline pistol & 97.6 & 100 & 99.5 & 90.4 \\ \hline lighter & 98.7 & 96.6 & 98.5 & 87.2 \\ \hline key & 98.9 & 98.9 & 98.6 & 83.1 \\ \hline nail scissors & 97.3 & 100 & 99.6 & 91.3 \\ \hline nail & 99.2 & 92.3 & 95.6 & 72 \\ \hline pen & 98.8 & 98.9 & 98.6 & 85.1 \\ \hline blade & 98.4 & 96 & 98.8 & 84.4 \\ \hline \end{tabular}
\end{table}
Table 3: Detection results of LWMD-YOLOv7 on different categories.