New method of x-ray absorption spectrum detection of contraband drugs based on transformer mechanism
Patent Information
- Application Number
- CN202310006260.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-03
- Publication Date
- 2026-10-16
- Estimated Expiration
- 2043-01-03
AI Technical Summary
其原因在于不同振动峰重叠和拉曼散射强度容易受光学系统参数等因素的影响;荧光现象对傅立叶变换拉曼光谱分析的干扰;在进行傅立叶变换光谱分析时,常出现曲线的非线性的问题;任何一物质的引入都会对被测体体系带来某种程度的污染,这等于引入了一些误差的可能性,会对分析的结果产生一定的影响
[0010]It can be observed that this invention targets different drug states (liquid, solid) and utilizes X-ray absorption spectral data of the drugs. It applies the Transformer neural network algorithm to train a model suitable for drug detection. Based on X-ray detection, this model can achieve non-destructive and rapid detection and classification of prohibited drugs in on-site testing environments. The method of this invention is easy to operate, has a fast detection speed, and can be easily extended to various testing environments. This invention analyzes the absorption spectrum of the detected drugs, which is related to the drug's composition, reducing the requirements for the testing environment and minimizing interference. This invention uses a Transformer network model to classify spectral data, achieving higher accuracy and stronger generalization than traditional data classification models. The research approach and application steps of this invention are applicable to prohibited drugs in various states.
Smart Images

Figure CN116380948B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of prohibited drug detection technology, and in particular to a novel method, apparatus, and equipment for detecting prohibited drugs using X-ray absorption spectroscopy based on the Transformer mechanism. Background Technology
[0002] In recent years, the manufacture and seizure of many illicit drugs have been reaching record highs. With the continuous development of global chemical technology, the types of new prohibited drugs, including narcotics, are increasing, and the pace of innovation in prohibited drugs is accelerating. Coupled with the rapid development of internet technology, the number of online transactions is increasing, making investigation more difficult. All these factors have made the situation for the investigation of prohibited drugs increasingly severe, and the demand for new methods of detecting prohibited drugs has increased significantly.
[0003] Most prohibited drugs cannot be identified or detected by appearance or odor. Traditional drug detection techniques, such as gas chromatography-mass spectrometry (GC-MS), can qualitatively and quantitatively detect drugs and are considered the gold standard for drug detection. However, these methods are time-consuming, require sophisticated instruments and environments, and are complex to operate. New rapid detection technologies can quickly identify prohibited drugs, enabling on-site investigators to make immediate decisions and are of great significance in the field of drug enforcement and detection.
[0004] However, existing rapid detection technologies, such as Raman spectroscopy, still have some shortcomings, such as high false positive rates in the detection of novel prohibited drugs, significant matrix interference, and relatively high detection limits. These shortcomings stem from several factors: overlap of different vibrational peaks and the susceptibility of Raman scattering intensity to optical system parameters; interference from fluorescence phenomena in Fourier transform Raman spectroscopy analysis; the frequent occurrence of nonlinearity in the curves during Fourier transform spectroscopy analysis; and the introduction of any substance, which inevitably contaminates the analyte system to some extent, introducing potential errors that can affect the analytical results. Summary of the Invention
[0005] In view of this, the purpose of this invention is to propose a new method for detecting prohibited drugs using X-ray absorption spectroscopy based on the Transformer mechanism. This method enables rapid on-site detection of prohibited drugs, is easy to operate, allows for penetrating observation, and has strong substance differentiation capabilities.
[0006] According to one aspect of the present invention, a novel method for detecting prohibited drugs using X-ray absorption spectroscopy based on the Transformer mechanism is provided, comprising: acquiring spectral data of prohibited drugs in different forms, and the corresponding average voltage and average current during the acquisition time of the spectral data; constructing a spectral Transformer model based on the spectral data, average voltage, and average current; training the constructed spectral Transformer model using a Transformer network; and using the trained spectral Transformer model to perform classification and prediction of the spectral data of prohibited drugs corresponding to the spectral data.
[0007] According to another aspect of the present invention, an X-ray absorption spectroscopy-based illicit drug detection device based on the Transformer mechanism is provided, comprising: an acquisition module, a construction module electrically connected to the acquisition module, a training module electrically connected to the construction module, and a prediction module electrically connected to the training module; the acquisition module is used to acquire spectral data of illicit drugs in different forms, as well as the average voltage and average current corresponding to the acquisition time of the spectral data; the construction module is used to construct a spectral Transformer model based on the spectral data and the average voltage and average current; the training module is used to train the constructed spectral Transformer model using a Transformer network; and the prediction module is used to perform classification prediction of the spectral data of illicit drugs according to the trained spectral Transformer model.
[0008] According to another aspect of the present invention, an X-ray absorption spectroscopy-based drug detection device based on the Transformer mechanism is provided, comprising: at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by at least one processor, and when the instructions are executed by at least one processor, the above-described novel method for detecting prohibited drugs based on the Transformer mechanism using X-ray absorption spectroscopy is performed.
[0009] According to another aspect of the present invention, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the novel method for detecting prohibited drugs based on the Transformer mechanism as described in any of the preceding claims.
[0010] It can be observed that this invention targets different drug states (liquid, solid) and utilizes X-ray absorption spectral data of the drugs. It applies the Transformer neural network algorithm to train a model suitable for drug detection. Based on X-ray detection, this model can achieve non-destructive and rapid detection and classification of prohibited drugs in on-site testing environments. The method of this invention is easy to operate, has a fast detection speed, and can be easily extended to various testing environments. This invention analyzes the absorption spectrum of the detected drugs, which is related to the drug's composition, reducing the requirements for the testing environment and minimizing interference. This invention uses a Transformer network model to classify spectral data, achieving higher accuracy and stronger generalization than traditional data classification models. The research approach and application steps of this invention are applicable to prohibited drugs in various states. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a flowchart illustrating an embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention.
[0013] Figure 2 This is an improved spectral Transformer structure diagram of another embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention;
[0014] Figure 3 This is a schematic diagram of an ablation experiment test of an embodiment of the X-ray absorption spectroscopy prohibited drug detection device based on the Transformer mechanism of the present invention;
[0015] Figure 4 This is a schematic diagram of the attention mechanism connection projection of an embodiment of the X-ray absorption spectroscopy prohibited drug detection device based on the Transformer mechanism of the present invention;
[0016] Figure 5 This is a flowchart illustrating another embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention.
[0017] Figure 6 This is a physical image of a drug as a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of this invention;
[0018] Figure 7 This is a schematic diagram of the experimental platform of a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention;
[0019] Figure 8 This is a sample absorption spectrum of a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention;
[0020] Figure 9 This is an isomer absorption spectrum of a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention;
[0021] Figure 10 This is a solid sample absorption spectrum of a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention;
[0022] Figure 11 This is a liquid sample absorption spectrum of a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention;
[0023] Figure 12 This is the accuracy curve of the model training for 500 epochs for a specific embodiment of the new method for detecting prohibited drugs by X-ray absorption spectroscopy based on the Transformer mechanism of this invention.
[0024] Figure 13 This is a loss curve of 500 epochs of model training for a specific embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of this invention. Detailed Implementation
[0025] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be particularly noted that the following embodiments are for illustrative purposes only and do not limit the scope of the invention. Similarly, the following embodiments are only some, not all, embodiments of the present invention, and all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] This invention provides a novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism. This method enables rapid on-site detection of prohibited drugs, is easy to operate, allows for penetrating observation, and has strong substance differentiation capabilities. It includes:
[0027] Acquire spectral data of prohibited drugs in different forms, as well as the average voltage and average current corresponding to the spectral data acquisition time; construct a spectral Transformer model based on the spectral data, average voltage, and average current; train the constructed spectral Transformer model using a Transformer network; and use the trained spectral Transformer model to perform classification and prediction of the spectral data of prohibited drugs.
[0028] Please see Figure 1 , Figure 1 This is a schematic flowchart of an embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention. It should be noted that if substantially the same results are obtained, the method of the present invention is not necessarily identical. Figure 1 The illustrated process sequence is limited. For example... Figure 1 As shown, the method includes the following steps:
[0029] S101: Obtain spectral data of prohibited drugs in different forms and the average voltage and average current corresponding to the spectral data acquisition time.
[0030] In this embodiment, the purpose of this configuration is to ensure that the spectral detector acquires both the incident X-ray spectrum I0(E) and the emitted X-ray spectrum I(E). Furthermore, considering the fluctuations in the voltage and current of the X-ray source, the average voltage and current during the acquisition time are used as two features and connected to the abstract features extracted by the attention module in the subsequent network.
[0031] In this embodiment, spectral data of different prohibited drugs with different components such as phenols, lipids, and alcohols can be obtained, as well as spectral data of the same prohibited drug with different components such as phenols, lipids, and alcohols. This invention does not limit the scope of the invention.
[0032] S102: Construct a spectral Transformer model based on the spectral data and average voltage and average current.
[0033] In this embodiment, the constructed spectral Transformer model can use a suitable regressor to classify and predict the spectral data of prohibited drugs based on the differences in spectral characteristics between different components such as phenols, lipids, and alcohols.
[0034] In this embodiment, the X-ray absorption theorem is used to process the spectral data of prohibited drugs in different forms to obtain absorption spectral data. The absorption spectral data is then standardized, and the standardized absorption spectral data is processed by a one-dimensional convolutional layer. The absorption spectral data processed by the one-dimensional convolutional layer is then used as the input method for the spectral Transformer model's input embedding layer.
[0035] Specifically, the spectrometer acquires the incident X-ray spectrum I0(E) and the emitted X-ray spectrum I(E). Therefore, before training the Transformer model, the absorption spectrum data needs to be obtained using the X-ray absorption theorem.
[0036]
[0037] Secondly, to avoid amplitude differences in the spectrum caused by fluctuations in the high-voltage power supply and different sample thicknesses, the obtained X-ray absorption spectra need to be Z-score normalized.
[0038]
[0039] in Let σ be the mean of μ(E) and σ be the standard deviation of μ(E). The standardized data have a mean of 0 and a standard deviation of 1.
[0040] The Transformer is a model architecture that relies entirely on attention mechanisms to map the global dependencies between inputs and outputs. However, due to the lack of a standard translation for absorption spectral data, modifications were made to the traditional Transformer structure. The model structure can be found by referring to [reference needed]. Figure 2 .
[0041] (1) Input embedding layer
[0042] The concept of word embedding is introduced by first mapping each point to a numerical space. To do this, a one-dimensional convolutional layer is applied to the absorption spectrum data of prohibited drugs to obtain the embedding for each point. h(k) represents the kernel size, u(k) represents the input data sequence, and y(k) is the output after convolution.
[0043]
[0044] The original embedding layer's task is to compress high-dimensional word vectors into low-dimensional vectors of real numbers. The original feature space is large enough; therefore, based on experience, the parameters are set to 512 or 1024. However, due to the characteristics of X-ray absorption spectroscopy, the effective absorption spectrum of the drug is limited to a certain energy range, and there is no significant numerical difference between the characteristic peaks of the target material and the high-energy channel number range. Therefore, the embedding layer output (d...) modelSet it to 64.
[0045] (2) Location coding layer
[0046] The positional information is encoded and then superimposed on the embedding information obtained in the previous step. Taking advantage of the periodicity of the sine function, a sinusoidal version is chosen because it can handle longer sequence lengths than those encountered during training. The formula for positional encoding is as follows:
[0047]
[0048]
[0049] As can be seen from the formula above, the wavelength forms a geometric series from 2 to 10000·2π. Specifically, for any fixed k, through PE... pos A linear transformation can yield PE pos+k .
[0050] (3) Attention Module
[0051] The attention modules are stacked N times, with each module consisting of two components. The first approach is a multi-head attention mechanism composed of multiple parallel attention functions. Typically, the attention function maps a query (Q) to a series of key-value pairs (K). Specifically, the similarity between the query (Q) and the keys (K) is calculated. Then, the weights are normalized using a softmax function, resulting in a weighted sum of the values. In practice, multiple queries are packaged and their outputs are computed simultaneously. Let the query... key-value pairs The entire Q can be calculated as follows:
[0052]
[0053]
[0054] Due to the properties of the softmax function, when the input value is very large, the function will fall into a region where the gradient is very small. Therefore, a scaling factor is used. To offset this effect.
[0055] Traditionally, Transformer attention modules are stacked at 4 layers, but through ablation experiments, a more suitable stacking number was selected. (See reference...) Figure 3 .
[0056] (4) Batch normalization:
[0057] The original model uses dropout and layer normalization (LN) to prevent overfitting, believing that dropout works well with large feature sizes. Considering the small parameters, dropout is not used. Meanwhile, taking into account the natural differences in absorption spectra between different drugs and the consistent number of spectral data channels across different samples, batch normalization (BN) is used to ensure efficient and reliable training. BN is a normalization method that performs translation and scaling transformations on the activations of each layer.
[0058] Although an attention mechanism is used, a single attention function may not be sufficient to fully describe all dependencies. Therefore, several attention functions are combined, each called a "head," to collectively focus on information from different representation subspaces at different locations. Instead of directly passing query (Q) and key-value (K) pairs to the function, different learned linear projections are performed to further extract key information. Furthermore, once all the "heads" are complete, they are concatenated, and the result is projected again. (Reference) Figure 4 After concatenation, a one-dimensional convolutional layer and a softmax layer are used to obtain the final probability.
[0059] (4) X-ray source parameter connection
[0060] Considering the fluctuations in the voltage and current of the X-ray source, the average voltage and current during the acquisition time are used as two features and connected with the abstract features extracted from the attention module.
[0061] In this embodiment, the purpose of this setup is to apply the Transformer neural network algorithm to detect and classify X-ray absorption spectral data of prohibited drugs. RNN, LSTM, and GRU networks have achieved good results in sequence model applications. Recurrent language models and encoder-decoder architectures have also made significant progress. However, the inherent sequential nature of RNNs hinders parallelization among training samples, and for long sequences, memory limitations impede batch processing of training samples. To apply the Transformer model to spectral data, this embodiment improves the Transformer model. The improved Transformer model is a loop-avoiding model structure that relies entirely on the attention mechanism to model the global dependencies between input and output. This overcomes the limitation of RNN models not being able to perform parallel computation; compared to CNNs, the number of operations required to compute the correlation between two locations does not increase with distance; self-attention can produce more interpretable models. This embodiment allows examination of the attention distribution within the model, and each attention head can learn to perform different tasks.
[0062] S103: The constructed spectral Transformer model is trained using a Transformer network.
[0063] In this embodiment, a Transformer network is used to label each spectrum in the spectral data with a prohibited drug label. Abstract spectral features of each spectrum are extracted from the labeled spectral data. The average voltage and average current corresponding to the spectral data acquisition time, along with the abstract spectral features, are used as training inputs to the Transformer network. The Transformer network, using the average voltage and average current corresponding to the spectral data acquisition time and the abstract spectral features as training inputs, is used to train the constructed Transformer model.
[0064] In this embodiment, the main technical verification metrics during model training are as follows:
[0065] 1. Accuracy
[0066] Also known as precision, it is the proportion of correctly predicted positive out of all correctly predicted positive predictions.
[0067]
[0068] Precision represents the accuracy of predictions for positive samples, while accuracy represents the overall prediction accuracy, including both positive and negative samples. The denominator is the predicted positive class, and precision aims to minimize the errors in the model's existing predictions.
[0069] 2. Recall rate
[0070] That is, the proportion of correctly predicted positive cases out of all actual positive cases.
[0071]
[0072] Recall is measured against the original sample; it represents the probability that a sample that is actually positive will be predicted as positive. A high recall means there may be more false positives, but it strives to find every object that should be found.
[0073] 3. F-Score
[0074] Precision and recall are interdependent. Ideally, both should be high, but in reality, they are mutually restrictive: high precision often leads to low recall, and vice versa. While both are desirable, they are contradictory in certain situations. Therefore, a comprehensive approach is needed, the most common method being the F-score.
[0075]
[0076] F-Score: This metric balances precision and recall. Generally, precision and recall are negatively correlated; a high precision leads to a low recall, and low recall in both indicates a problem. Precision and recall are often contradictory. The F-Score is introduced as a comprehensive indicator to balance the impact of precision and recall, providing a more holistic evaluation of a classifier.
[0077] S104: Based on the trained spectral Transformer model, perform classification and prediction of the spectral data of prohibited drugs.
[0078] In this embodiment, based on the trained spectral Transformer model, abstract spectral features of each spectrum are extracted from the spectral data after the prohibited substances are labeled. The average voltage and average current corresponding to the spectral data acquisition time, along with the abstract spectral features, are input into the trained spectral Transformer model to perform classification prediction of the spectral data of prohibited substances. The predicted classification of prohibited substances is obtained through the trained spectral Transformer model. The advantage of this is that the accuracy of the trained spectral Transformer model is improved through multiple training sessions, thereby improving the accuracy of classification prediction of the spectral data of prohibited substances.
[0079] The method further includes, after performing classification and prediction of the spectral data of prohibited drugs based on the trained spectral Transformer model, the method as follows:
[0080] The Transformer network is modified by performing 10-fold cross-validation, and then trained and updated using the modified Transformer network through iterative prediction. This improves the accuracy of classification and prediction of spectral data corresponding to prohibited drugs.
[0081] As can be seen in this embodiment, the present invention targets different drug states (liquid, solid) and, based on the X-ray absorption spectrum data of the drugs, applies the Transformer neural network algorithm to train a model suitable for drug detection. Building upon X-ray detection, this model can achieve non-destructive and rapid detection and classification of prohibited drugs in on-site testing environments. The method of the present invention is easy to operate, fast in detection, and can be easily extended to various testing environments. The method of the present invention analyzes and detects the absorption spectrum of the drug, which is related to the drug's composition, reducing the requirements for the testing environment and minimizing interference. The method of the present invention uses a Transformer network model to classify spectral data, achieving higher accuracy and stronger generalization than traditional data classification models. The research ideas and application steps of the present invention are applicable to prohibited drugs in various states.
[0082] Please see Figure 5 , Figure 5 This is a schematic flowchart of another embodiment of the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism of the present invention. In this embodiment, the method includes the following steps:
[0083] S201: Obtain spectral data of prohibited drugs in different forms, as well as the corresponding average voltage and average current during the spectral data acquisition time. This can be described as in S101 above, and will not be repeated here.
[0084] S202: Construct a spectral Transformer model based on the spectral data and average voltage and average current. This can be described as in S102 above, and will not be repeated here.
[0085] S203: Train the constructed spectral Transformer model using a Transformer network. This can be done as described in S103 above, and will not be repeated here.
[0086] S204: Based on the trained spectral Transformer model, classify and predict the spectral data of prohibited drugs according to the corresponding spectral data. This can be described as in S104 above, and will not be repeated here.
[0087] S205: The parameters of the Transformer network are updated using the ten-fold cross-validation method, and the Transformer model is trained and updated using the parameter-updated Transformer network through the number of prediction iterations.
[0088] In this embodiment, appropriate weight parameters for the deep neural network model are obtained by training the collected data. A deep learning model is built using the PyTorch framework, employing the Adam optimizer. The data is shuffled, and the model is trained using ten-fold cross-validation. The hyperparameters that primarily affect model performance include the loss function, activation function, batch size, the number of heads in the multi-head-attention mechanism, and the dimension d of the encoded output. model The parameters are: number of attention modules (num_) and random inactivation probability. Ten-fold cross-validation is used to test the accuracy of the network model on a test set that has not been trained on the model. If the error between the types of drugs tested and those predicted by the model is consistently within 5%, the model is considered to meet the design requirements. If the error is greater than 5% but less than approximately 10%, the model is optimized by adjusting the weight parameters. If the error requirement cannot be met after multiple optimizations, the process returns to S202, where a new algorithm, such as ResUnet, is applied to train a detection model suitable for the X-ray absorption spectrum of prohibited drugs.
[0089] As can be seen in this embodiment, the present invention targets different drug states (liquid, solid) and, based on the X-ray absorption spectrum data of the drugs, applies the Transformer neural network algorithm to train a model suitable for drug detection. Building upon X-ray detection, this model can achieve non-destructive and rapid detection and classification of prohibited drugs in on-site testing environments. The method of the present invention is easy to operate, fast in detection, and can be easily extended to various testing environments. The method of the present invention analyzes and detects the absorption spectrum of the drug, which is related to the drug's composition, reducing the requirements for the testing environment and minimizing interference. The method of the present invention uses a Transformer network model to classify spectral data, achieving higher accuracy and stronger generalization than traditional data classification models. The research ideas and application steps of the present invention are applicable to prohibited drugs in various states.
[0090] This invention also provides an X-ray absorption spectroscopy-based device for detecting prohibited drugs based on the Transformer mechanism. This device enables rapid on-site detection of prohibited drugs, is easy to operate, allows for penetrating observation, and has strong substance differentiation capabilities. It includes:
[0091] The system comprises an acquisition module, a construction module electrically connected to the acquisition module, a training module electrically connected to the construction module, and a prediction module electrically connected to the training module. The acquisition module acquires spectral data of prohibited drugs in different forms, as well as the corresponding average voltage and average current within the spectral data acquisition time. The construction module constructs a spectral Transformer model based on the spectral data and the average voltage and average current. The training module trains the constructed spectral Transformer model using a Transformer network. The prediction module performs classification prediction of the spectral data of prohibited drugs based on the trained spectral Transformer model.
[0092] In this embodiment, the X-ray absorption spectroscopy-based prohibited drug detection device based on the Transformer mechanism includes an acquisition module, a construction module, a training module, and a prediction module. The acquisition module acquires spectral data of prohibited drugs in different forms, as well as the corresponding average voltage and average current during the spectral data acquisition time. The construction module constructs a spectral Transformer model based on the spectral data and the average voltage and average current. The training module trains the constructed spectral Transformer model using a Transformer network. The prediction module uses the trained spectral Transformer model to perform classification and prediction of the spectral data of prohibited drugs.
[0093] Optionally, the construction module includes a data acquisition module, a data standardization module, a convolution processing module, and a computation module that are electrically connected in sequence. The data acquisition module is used to process the spectral data of different forms of prohibited drugs using the X-ray absorption theorem to obtain absorption spectral data. The data standardization module is electrically connected to the data acquisition module and is used to standardize the absorption spectral data. The convolution processing module is electrically connected to the data standardization module and is used to perform one-dimensional convolutional layer processing on the standardized absorption spectral data. The computation module is used to store the spectral Transformer model and is electrically connected to the convolution processing module, and is used as the input of the spectral Transformer model's input embedding layer for the one-dimensional convolutional layer processing.
[0094] Optionally, the training module includes a labeling module, a feature module, and a learning module that are electrically connected in sequence; the labeling module uses a Transformer network to label each spectrum in the spectral data with a corresponding prohibited drug label; the feature module extracts abstract spectral features of each spectrum from the spectral data after the prohibited drug label is applied, and uses the average voltage and average current corresponding to the spectral data acquisition time and the abstract spectral features as training inputs to the Transformer network; the learning module trains the constructed Transformer model using the Transformer network with the average voltage and average current corresponding to the spectral data acquisition time and the abstract spectral features as training inputs.
[0095] Unlike the previous embodiment, the X-ray absorption spectroscopy prohibited drug detection device based on the Transformer mechanism described in this embodiment also includes an update module.
[0096] This update module is used to update the parameters of the Transformer network using the ten-fold cross-validation method, and to train and update the Transformer model using the parameter-updated Transformer network through a number of prediction iterations.
[0097] Each unit module of the X-ray absorption spectroscopy prohibited drug detection device based on the Transformer mechanism can execute the corresponding steps in the above method embodiments. Therefore, the details of each unit module will not be elaborated here. Please refer to the description of the corresponding steps above for details.
[0098] This invention further provides an X-ray absorption spectroscopy-based device for detecting prohibited drugs based on the Transformer mechanism, comprising: at least one processor, and a memory communicatively connected to the processor, wherein...
[0099] The memory stores instructions that can be executed by at least one processor. When the instructions are executed by at least one of the processors, the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism described above is performed.
[0100] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.
[0101] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.
[0102] The present invention further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the above-described method embodiments.
[0103] As can be seen in this embodiment, the present invention targets different drug states (liquid, solid) and, based on the X-ray absorption spectrum data of the drugs, applies the Transformer neural network algorithm to train a model suitable for drug detection. Building upon X-ray detection, this model can achieve non-destructive and rapid detection and classification of prohibited drugs in on-site testing environments. The method of the present invention is easy to operate, fast in detection, and can be easily extended to various testing environments. The method of the present invention analyzes and detects the absorption spectrum of the drug, which is related to the drug's composition, reducing the requirements for the testing environment and minimizing interference. The method of the present invention uses a Transformer network model to classify spectral data, achieving higher accuracy and stronger generalization than traditional data classification models. The research ideas and application steps of the present invention are applicable to prohibited drugs in various states.
[0104] In this embodiment, the following describes the implementation process of the present invention for detecting prohibited drugs, using 15 kinds of chemical drugs as examples. Figure 6 The images shown are of the samples used for testing. Table 1 contains a list of information about the medicines. Figure 7 This is a schematic diagram of the experimental platform.
[0105] Table 1. Drug Sample Information Table
[0106]
[0107] The X-ray source voltage was set to 30 kV and the current to 10 μA. After preheating for 10 minutes, sampling was performed, with each set of spectra acquired for 30 seconds. 200 sets of spectral data were acquired for each sample, resulting in a total of 3000 sets of spectral data. During the experiment, after each set of spectra was acquired, the stage was rotated by 1° to ensure that the X-rays penetrated the sample from different locations each time. For the obtained spectra, please refer to [reference needed]. Figure 8-11 .
[0108] See Table 2 and Figure 12 , Figure 13 The model error was analyzed and the accuracy of the scheme was verified by using the ten-fold cross-validation method.
[0109] Table 2 Model Prediction Results
[0110]
[0111] The results above clearly demonstrate that the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism proposed in this invention is applicable to different drug states (liquid and solid). It utilizes X-ray absorption spectral data of the drugs and applies a Transformer neural network algorithm to train a model suitable for drug detection. Building upon X-ray detection, this model can achieve non-destructive and rapid detection and classification of prohibited drugs in on-site testing environments. This method is easy to operate, fast, and can be easily extended to various testing environments. The method analyzes the absorption spectrum of the detected drugs, which is related to the drug's composition, reducing the requirements for the testing environment and minimizing interference. The method uses a Transformer network model to classify spectral data, achieving higher accuracy and stronger generalization than traditional data classification models. The research approach and application steps of this invention are applicable to prohibited drugs in various states.
[0112] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection of apparatuses or units, and may be electrical, mechanical, or other forms.
[0113] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0114] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0115] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0116] The above description is only a part of the embodiments of the present invention and does not limit the scope of protection of the present invention. Any equivalent device or equivalent process transformation made based on the content of the present invention specification and drawings, or direct or indirect application in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A novel method for detecting prohibited drugs using X-ray absorption spectroscopy based on the Transformer mechanism, characterized in that, include: Acquire spectral data of prohibited drugs in different forms, as well as the average voltage and average current corresponding to the spectral data acquisition time. Construct a spectral Transformer model based on the spectral data, average voltage, and average current; The constructed spectral Transformer model is trained using a Transformer network; The trained spectral Transformer model is used to classify and predict the spectral data of prohibited drugs. Constructing a spectral Transformer model based on the aforementioned spectral data, average voltage, and average current includes: The X-ray absorption theorem is used to process the spectral data of prohibited drugs in different forms to obtain absorption spectral data, and the absorption spectral data is then standardized. The standardized absorption spectrum data is processed by a one-dimensional convolutional layer. The absorption spectrum data processed by the one-dimensional convolutional layer is input into the spectral Transformer model and then into the embedding layer. The constructed spectral Transformer model is trained using a Transformer network, including: The Transformer network is used to label each spectrum in the spectral data with the corresponding prohibited drug label; Abstract spectral features of each spectrum are extracted from the spectral data after it has been labeled with prohibited tags, and the abstract spectral features, along with the average voltage and average current corresponding to the spectral data acquisition time, are used as the training input of the Transformer network. The constructed Transformer model is trained using the average voltage and average current corresponding to the spectral data acquisition time and the abstract spectral features as training inputs to a Transformer network.
2. The novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism as described in claim 1, characterized in that, Also includes: The parameters of the Transformer network were adjusted using the ten-fold cross-validation method. The Transformer model is trained and updated using a Transformer network with updated parameters through iterative prediction.
3. A device for detecting prohibited drugs using X-ray absorption spectroscopy based on the Transformer mechanism, characterized in that, include: An acquisition module, a construction module electrically connected to the acquisition module, a training module electrically connected to the construction module, and a prediction module electrically connected to the training module; The acquisition module is used to acquire spectral data of prohibited drugs in different forms, as well as the average voltage and average current corresponding to the spectral data acquisition time. The construction module is used to construct a spectral Transformer model based on the spectral data and average voltage and average current; The training module is used to train the constructed spectral Transformer model using a Transformer network; The prediction module is used to use a trained spectral Transformer model to perform classification prediction of the spectral data of prohibited drugs. The building module includes: The data acquisition module is used to process the spectral data of different forms of prohibited drugs using the X-ray absorption theorem to obtain absorption spectral data. A data standardization module, which is electrically connected to the data acquisition module, is used to standardize the absorption spectral data; A convolutional processing module, which is electrically connected to a data standardization module, is used to perform one-dimensional convolutional layer processing on the absorption spectral data after the standardization process. The computation module is used to store the spectral Transformer model; it is electrically connected to the convolution processing module and is used as the input of the spectral Transformer model's input embedding layer after processing by the one-dimensional convolutional layer. The training module includes a label module, a feature module, and a learning module that are electrically connected in sequence. Labeling module: A Transformer network is used to apply prohibited drug labels to each spectrum in the spectral data. Feature module: It is electrically connected to the tag module, extracts the abstract spectral features of each spectrum from the spectral data after the prohibited label is applied, and uses the average voltage and average current corresponding to the spectral data acquisition time and the abstract spectral features as the training input of the Transformer network. Learning module: It is electrically connected to the feature module and uses the average voltage and average current corresponding to the spectral data acquisition time and the abstract spectral features as training inputs to train the constructed Transformer network.
4. The X-ray absorption spectroscopy-based prohibited drug detection device based on the Transformer mechanism as described in claim 3, characterized in that, Also includes: Update module; The update module is used to update the parameters of the Transformer network using the ten-fold cross-validation method, and to train and update the Transformer model using the parameter-updated Transformer network through a number of prediction iterations.
5. A device for detecting prohibited drugs using X-ray absorption spectroscopy based on the Transformer mechanism, characterized in that, include: At least one processor, and a memory communicatively connected to the processor, wherein, The memory stores instructions that can be executed by at least one processor, which, when executed by at least one of the processors, perform the novel X-ray absorption spectroscopy method for detecting prohibited drugs based on the Transformer mechanism as described in any one of claims 1 to 2.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the novel method for detecting prohibited drugs based on X-ray absorption spectroscopy according to any one of claims 1 to 2.
Citation Information
Patent Citations
Method for rapidly quantitatively predicting medicine stability
CN107255646A
Vision-attribute-based X-ray security inspection contraband identification method
CN110018524A