Diesel oil Raman spectrum detection method, device and equipment based on convolutional neural network
By extracting the Raman spectral features of diesel fuel using a multi-scale convolutional branch structure of a convolutional neural network, the problem of rapid and accurate detection of alcohol doping in diesel fuel was solved, achieving efficient identification on low-cost equipment and meeting on-site testing needs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-11
- Publication Date
- 2026-04-10
AI Technical Summary
Existing technologies are insufficient for quickly and accurately identifying alcohol adulteration in diesel fuel in scenarios such as gas stations, oil depots, and mobile testing vehicles. Traditional detection methods involve large and complex equipment, and existing optical detection methods are prone to losing trace information and being affected by strong fluorescence background interference.
A diesel Raman spectroscopy detection method based on convolutional neural networks is adopted. A multi-scale convolutional branch structure is used to extract spectral features, including three parallel convolutional branches that capture narrowband, medium-width and broadband background features respectively, which improves the ability to identify weak signals and preserves the physical continuity of the spectrum.
It enables efficient and accurate identification of alcohol adulteration in diesel fuel on low-cost equipment, reducing hardware costs, expanding application scenarios, and meeting the needs of rapid on-site testing.
Smart Images

Figure CN121830628A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of oil detection, and in particular to a diesel Raman spectrum detection method and device based on a convolutional neural network, a computer device, and a computer program product. BACKGROUND
[0002] In the current product oil market, it is a common adulteration behavior to add alcohol substances such as methanol and ethanol to diesel. Although such adulteration behavior is not easy to be detected in a short period of time, it will reduce the fuel heat value, exacerbate engine corrosion, and cause emission to exceed the standard, thereby threatening vehicle safety and polluting the environment.
[0003] In view of the above behavior, the traditional detection method relies on laboratory physicochemical analysis methods, such as gas chromatography-mass spectrometry (GC-MS) or high-performance liquid chromatography (HPLC), but the detection equipment of the above method is bulky and needs complex pretreatment, and can only be realized in a professional laboratory, which cannot meet the needs of application scenarios such as gas stations, oil depots, and mobile detection vehicles.
[0004] In order to solve the above problems and break through this limitation, rapid detection technology based on optical principles has attracted widespread attention in recent years. However, the characteristic signals of alcohol adulterants in diesel are extremely weak and are easily covered by strong fluorescence background and noise. Existing methods mostly rely on detection models for identification, and usually use manual screening of wavebands or one-dimensional spectrum dimensionality processing to improve the extraction ability of characteristic signals. However, such processing destroys the physical continuity of the spectrum data, which is easy to cause the loss of key trace information, and it is difficult to balance between detection accuracy and model generalization ability.
[0005] Therefore, there is an urgent need for a detection method that is widely applicable and easy to implement to realize efficient and accurate identification of alcohol adulteration behavior in diesel. SUMMARY
[0006] The present application provides a diesel Raman spectrum detection method based on a convolutional neural network, which realizes efficient and accurate identification of alcohol adulteration behavior in diesel.
[0007] In order to achieve the above purpose, the main technical solution adopted by the present application includes: In a first aspect, the present application provides a diesel Raman spectrum detection method based on a convolutional neural network, which comprises: obtaining the Raman spectrum of the diesel to be detected; input the Raman spectrum into a pre-trained diesel detection model, obtain a detection result output by the model, and the detection result represents a possibility that the diesel to be detected is doped with alcohol substances; The diesel detection model comprises a multi-scale convolution branch structure, the multi-scale convolution branch structure comprises three parallel convolution branches with different convolution kernel sizes, a convolution kernel size of a first convolution branch in the parallel convolution branches is associated with a narrow-band characteristic peak in the spectrum, a convolution kernel size of a second convolution branch in the parallel convolution branches is larger than the convolution kernel size of the first convolution branch and is associated with a medium-width characteristic peak in the spectrum, and a convolution kernel size of a third convolution branch in the parallel convolution branches is larger than the convolution kernel size of the second convolution branch and is associated with a wide-frequency background trend of the spectrum.
[0008] The diesel Raman spectrum detection method based on the convolution neural network comprises a parallel multi-scale convolution branch structure with three convolution kernels of different sizes. The structure is executed in parallel through the three branches, and can synchronously extract characteristic information of multiple scales in the spectrum: the small convolution kernel branch captures the narrow-band characteristic peak corresponding to the special chemical bond of alcohol, the medium convolution kernel branch extracts the medium-width characteristic peak corresponding to the complete chemical bond, and the large convolution kernel branch focuses on the wide-frequency background trend reflecting the overall trend of the spectrum. The structure significantly enhances the recognition and extraction ability of the model for weak signal characteristics, improves the recognition sensitivity of low-concentration alcohol doping, and solves the missed detection problem caused by strong fluorescent background and noise interference. The input data of the model in the method provided by the application do not need artificial wave band screening, the physical continuity and original information integrity of the spectrum are preserved, and the method has the advantages of easy deployment and can meet the actual application requirements of on-site rapid detection.
[0009] In a second aspect, the embodiments of the application provide a diesel Raman spectrum detection device based on a convolution neural network, and the device comprises: A spectrum acquisition module is configured to acquire a Raman spectrum of diesel to be detected. An inference detection module is configured to input the Raman spectrum into a pre-trained diesel detection model, obtain a detection result output by the model, and the detection result represents a possibility that the diesel to be detected is doped with alcohol substances. The diesel detection model comprises a multi-scale convolution branch structure, the multi-scale convolution branch structure comprises three parallel convolution branches with different convolution kernel sizes, a convolution kernel size of a first convolution branch in the parallel convolution branches is associated with a narrow-band characteristic peak in the spectrum, a convolution kernel size of a second convolution branch in the parallel convolution branches is larger than the convolution kernel size of the first convolution branch and is associated with a medium-width characteristic peak in the spectrum, and a convolution kernel size of a third convolution branch in the parallel convolution branches is larger than the convolution kernel size of the second convolution branch and is associated with a wide-frequency background trend of the spectrum.
[0010] In a third aspect, an embodiment of the present application provides a computer device, comprising: a memory and a processor, which are connected in communication with each other, and the memory stores computer instructions, and the processor executes the computer instructions to perform the diesel Raman spectrum detection method based on the convolutional neural network according to the first aspect.
[0011] In a fourth aspect, an embodiment of the present application provides a computer program product, comprising computer instructions for causing a computer to perform the diesel Raman spectrum detection method based on the convolutional neural network according to the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0012] In order to more clearly illustrate the technical solutions of the specific embodiments or prior art in the present application, the drawings needed in the description of the specific embodiments or prior art will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor on the basis of these drawings.
[0013] Figure 1 A step diagram of a diesel Raman spectrum detection method based on a convolutional neural network provided by an embodiment of the present application is provided. Figure 2 An internal structure schematic diagram of a multi-scale residual feature extraction layer provided by an embodiment of the present application is provided. Figure 3 A data processing principle schematic diagram of a data preprocessing layer provided by an embodiment of the present application is provided. Figure 4 A structure schematic diagram of a diesel detection model provided by an embodiment of the present application is provided. Figure 5 A structure schematic diagram of a diesel Raman spectrum detection device based on a convolutional neural network provided by an embodiment of the present application is provided. Figure 6 A structure schematic diagram of a computer device provided by an embodiment of the present application is provided. Figure 7 A schematic diagram of a computer device provided by an embodiment of the present application performing a diesel Raman spectrum detection method based on a convolutional neural network is provided. DETAILED DESCRIPTION
[0014] To make the purposes, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0015] As an important power fuel for industrial production and transportation, the quality safety of diesel oil is directly related to the service life of engines and the control of air pollution. In recent years, with the fluctuation of the petrochemical market, driven by huge economic benefits, the phenomenon of adulteration in the refined oil market has been repeated. Unscrupulous businessmen often mix low-cost alcohol chemical raw materials such as methanol and ethanol into regular national standard diesel oil to make huge profits. Although the mixing of alcohol substances can maintain the operation of the engine in a short time, due to its low calorific value, strong corrosion and easy water absorption, long-term use will lead to engine power decline, fuel pump corrosion and wear, rubber seal swelling failure, and even engine knock and serious exhaust emission exceeding the standard. Therefore, it is of great significance to realize rapid and accurate detection of alcohol substances mixed in diesel oil for the protection of consumer rights and interests, the safety of vehicles and the supervision of the order of the refined oil market.
[0016] At present, the detection technology for oil components mainly relies on traditional laboratory physicochemical analysis methods, such as gas chromatography-mass spectrometry or high-performance liquid chromatography. Although these methods have very high detection accuracy and can accurately determine the content of various components in oil, their defects are that the detection equipment is expensive and bulky, and can usually only be used in professional laboratories, and the sample pretreatment process is complicated and time-consuming, which cannot meet the urgent needs of on-site rapid screening and online real-time monitoring in gas stations, oil depots, mobile detection vehicles and other places.
[0017] To solve the problem of on-site detection, rapid detection techniques based on optical principles have emerged. In existing detection techniques based on optical principles, some schemes attempt to use deep learning to process spectral data, usually by reshaping one-dimensional spectral data into a two-dimensional or three-dimensional matrix, and then inputting the 2D or 3D convolution network after screening specific bands using the uninformative variable elimination (UVE) algorithm. However, this processing method has obvious defects: first, the Raman characteristic peaks of alcohol adulteration in diesel oil are extremely weak and distributed throughout the spectrum, and manual screening of bands can easily lead to the loss of trace characteristic information, resulting in missed detection; second, the forced dimensionality processing of spectral data, which is essentially a one-dimensional sequence, not only destroys the continuity of the physical meaning of the spectral wavelength, but also introduces a large number of redundant parameters, leading to a dramatic increase in model calculation, making it difficult to deploy on low-cost, low-power portable terminals. In addition, in the face of the complex strong fluorescence background of diesel oil, simple band screening cannot effectively separate the background and signal. Second, industrial-grade diesel oil has complex matrix components, containing a large amount of polycyclic aromatic hydrocarbons and gum. These substances will produce extremely strong fluorescence background under laser excitation. In contrast, the Raman characteristic peaks of trace adulteration of alcohol substances (such as adulteration ratio between 1% and 10%) are extremely weak and often submerged in the strong fluorescence background and environmental thermal noise, resulting in extremely low signal-to-noise ratio. Traditional baseline correction and peak searching algorithms often fail in the face of such "strong background, weak signal" scenarios, resulting in high missed detection rate.
[0018] The diesel Raman spectrum detection method based on the convolutional neural network provided in the embodiments of the present application solves the above problems. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0019] A diesel Raman spectrum detection method based on a convolutional neural network is provided in the embodiments, as shown in Figure 1 The method comprises the following steps: Step 110, acquiring the Raman spectrum of the diesel oil to be detected.
[0020] In the embodiments, the data input into the diesel detection model needs to be acquired first, specifically the Raman spectrum of the diesel oil to be detected.
[0021] Since the method provided in the embodiments improves the feature extraction capability through the multi-scale convolution branch structure, the requirement for the resolution of the Raman spectrum is reduced, and the spectral data meeting the detection requirements can be obtained by scanning the diesel oil to be detected using a common portable Raman spectrometer.
[0022] In one embodiment, a low-resolution photoelectric detection module is selected, a stable frequency semiconductor laser with a center wavelength of 785 nm is used as the excitation light source, the laser power is preferably set to 350 mW to balance the Raman signal intensity and sample heat damage, and the integration time is set to 12000 ms. The detector uses a non-cooled linear array CCD or CMOS sensor with an effective pixel number of =512. This means that the spectrometer discretizes the continuous wavelength range (for example, 200 wave numbers to 3000 wave numbers) into 512 data points, and a one-dimensional array with a length of 512 is obtained in a single acquisition, which is denoted as the original spectrum sequence .
[0023] Compared with the common 2048 pixel configuration of the research-level equipment, the amount of spectral data obtained in the embodiment of the application is reduced by 75%, which greatly reduces the subsequent calculation load, but also brings the challenge of reduced spectral resolution, that is, the characteristic peak is widened and the overlap is serious, which requires the detection method to have stronger feature extraction capability.
[0024] In one embodiment, the spectral acquisition device can also be a device capable of providing the required original light intensity and dark current data in the embodiment of the application, such as a discrete photodiode array or a CMOS sensor with a specific optical filter.
[0025] Step 120, inputting the Raman spectrum into a pre-trained diesel detection model to obtain a detection result output by the model, the detection result representing a possibility that the diesel to be detected exists alcohol substance doping; wherein the diesel detection model comprises a multi-scale convolution branch structure, the multi-scale convolution branch structure comprising three parallel convolution branches with different convolution kernel sizes; the convolution kernel size of a first convolution branch in the parallel convolution branch is associated with a narrow-band characteristic peak in the spectrum; the convolution kernel size of a second convolution branch in the parallel convolution branch is greater than the convolution kernel size of the first convolution branch, and is associated with a medium-width characteristic peak in the spectrum; the convolution kernel size of a third convolution branch in the parallel convolution branch is greater than the convolution kernel size of the second convolution branch, and is associated with a wide-frequency background trend of the spectrum.
[0026] In this embodiment, the obtained Raman spectrum is input into a pre-trained diesel detection model, and the detection result output by the model includes the possibility that the diesel to be detected exists alcohol substance doping.
[0027] Specifically, the diesel detection model used in this embodiment has a multi-scale convolution branch structure as its core. Based on the fact that the "alcohol characteristic peak is narrow (about )" in the Raman spectrum and the "diesel background is wide (greater than In the case of "), the multi-scale convolutional branch structure internally designs three parallel convolutional branches with different receptive fields: the kernel size of the first convolutional branch is associated with narrow-band characteristic peaks in the spectrum, with a smaller receptive field, focusing on capturing sharp, abrupt single-point noise or extremely narrow Raman peaks, especially the special chemical bonds of alcohols, such as the characteristic peak generated by the CO stretching vibration of methanol; the kernel size of the second convolutional branch is larger than that of the first convolutional branch, and it is associated with medium-width characteristic peaks in the spectrum. The term "medium-width characteristic peak" has two meanings: the first meaning is that the length of the characteristic peak associated with the kernel of this branch is between that of the other branch. The characteristic peak lengths associated with the two branches are in a "medium" position. This means that the receptive field of the convolution kernel size of this branch is moderate, just enough to extract complete vibrational peak clusters of medium-sized chemical bonds, such as the peak clusters of hydrocarbon compounds in diesel fuel matrices. The third convolution branch has a larger convolution kernel size than the second branch and is associated with the broadband background trend of the spectrum. Its larger receptive field is used to perceive the overall trend of the spectrum and the broadband fluorescence background trend, providing background suppression and reference for the extraction of narrow peak features. By executing these three branches in parallel, feature information at multiple scales in the spectrum can be extracted simultaneously.
[0028] In one embodiment, the obtained Raman spectrum is 512 pixels, and in the corresponding multi-scale convolutional branch structure, the first convolutional branch adopts... 3 convolution kernels; the second convolution branch uses Convolution kernel; the third convolution branch uses Convolution kernel.
[0029] In one embodiment, the size of the convolution kernel of each convolution branch can be adjusted according to the resolution of the Raman spectrum so that the kernel size matches the characteristic peaks formed on the spectrum by the chemical bonds of interest to each branch.
[0030] The method proposed in this embodiment utilizes a multi-scale convolutional branching structure, enabling the diesel detection model to accurately capture the optical characteristics of trace amounts of alcohols in diesel fuel. This improves the sensitivity for identifying low-concentration alcohol doping and solves the problem of missed detection caused by strong fluorescence background and noise interference. The input data of the model provided in this application does not require manual band selection, preserving the physical continuity of the spectrum and the integrity of the original information. It also has the advantage of easy deployment, meeting the practical application needs of rapid on-site detection. By improving the model's feature recognition and extraction capabilities, this method also effectively reduces the requirements for spectrometer hardware resolution, allowing the use of low-pixel, inexpensive detectors to achieve the analytical effects of research-grade equipment, reducing hardware costs and expanding application scenarios.
[0031] In practical applications, the trained model can be deployed on a detection terminal. The detection terminal collects data in real time. If the probability of the model outputting "alcohol adulteration" is greater than a set threshold, for example, the set threshold is 90%, an alarm signal is sent.
[0032] Experiments show that the method proposed in this embodiment has much higher recognition accuracy for trace adulteration samples than traditional models under complex concentration gradients. The relevant experimental data will be listed in the following text.
[0033] The second embodiment of the present application further defines the diesel Raman spectrum detection method based on the convolutional neural network in the first embodiment in more detail and concretely. Part or all of the technical features in the second embodiment can be combined, replaced, etc. with the first embodiment, so as to obtain more kinds of feasible diesel Raman spectrum detection methods based on the convolutional neural network.
[0034] The diesel Raman spectrum detection method based on the convolutional neural network in the second embodiment of the present application will be described in detail as follows: Optionally, the diesel detection model comprises at least one multi-scale residual feature extraction layer and at least one feature pooling layer; the multi-scale residual feature extraction layer comprises a multi-scale convolution branch structure, and the input data of the multi-scale residual feature extraction layer are input into each convolution branch; the feature pooling layer is located after the multi-scale residual feature extraction layer and is used for down-sampling the extracted feature data.
[0035] This embodiment further limits the structure of the diesel detection model.
[0036] Specifically, this embodiment proposes that the model comprises at least one multi-scale residual feature extraction layer (MS-Res-Block). The multi-scale residual feature extraction layer comprises the aforementioned multi-scale convolution branch structure, and the input data thereof are sent into three convolution branches with different convolution kernel sizes in parallel, which are respectively used for extracting multi-scale spectral features such as narrowband, medium width and wide background; the features extracted by each branch are output after convolution processing.
[0037] The model further comprises at least one feature pooling layer. The feature pooling layer is arranged after the multi-scale residual feature extraction layer and is used for down-sampling the feature data extracted by the multi-scale residual feature extraction layer, reducing the data dimension and enhancing the robustness of the model to local translation disturbance.
[0038] In one embodiment, the feature pooling layer adopts a maximum pooling operation, and the pooling window size is 2 and the step is 2.
[0039] To further improve the feature extraction effect, the number of layers of the multi-scale residual feature extraction layer can be increased, that is, multiple repeated "multi-scale residual feature extraction layer-feature pooling layer" structures are set to analyze the data multiple times to further improve the feature extraction effect. In one embodiment, three multi-scale residual feature extraction layers-feature pooling layers in series are set in the model for feature extraction.
[0040] The model structure in this embodiment further enhances the analysis and extraction capability of the model for weakly doped signals by introducing the pooling mechanism and the multi-layer feature extraction mechanism.
[0041] Optionally, the multi-scale residual feature extraction layer further includes a data format conversion module, a branch data fusion module, a squeezing excitation module, and an output data fusion module. The data format conversion module is configured to process input data of the multi-scale residual feature extraction layer through convolution operation when the input data format and the output data format of the multi-scale residual feature extraction layer are different, to generate first intermediate data conforming to the output data format. The branch data fusion module is configured to splice and compress the outputs of the three convolution branches in the multi-scale convolution branch structure through convolution, to generate second intermediate data conforming to the output data format. The squeezing excitation module is configured to generate channel weights based on the second intermediate data through global average pooling and a fully connected layer. The output data fusion module is configured to multiply the channel weights back to the second intermediate data to generate third intermediate data, and then add the input data format or the first intermediate data of the multi-scale residual feature extraction layer to the third intermediate data to generate the output of the multi-scale residual feature extraction layer.
[0042] This embodiment further limits the structure of the multi-scale residual feature extraction layer.
[0043] Specifically, for the purpose of feature extraction, the multi-scale residual feature extraction layer discards the general residual network with a large number of parameters or the 2D / 3D network that needs dimensionality processing, and specially designs a lightweight structure of a full convolution structure. As shown in Figure 2 When the input data enters the multi-scale residual feature extraction layer, it will be sent to the data format conversion module and the multi-scale convolution branch structure simultaneously and in parallel.
[0044] wherein, it is assumed that the input channel number of the module is , the target output channel number is When the input channel number is not equal to the output channel , the data format conversion module will generate an The convolutional layer processes the input data to generate first intermediate data. This first intermediate data conforms to the output data format of the multi-scale residual feature extraction layer and can be directly added to the third intermediate data generated by another branch. Furthermore, if the input data format is the same as the output data format, the data format transformation module will not process the input data.
[0045] In another branch, the input data is fed into a multi-scale convolutional branch structure. Figure 2 Branches A, B, and C correspond to the first, second, and third convolutional branches mentioned above, respectively. The three convolutional branches perform convolution operations, and the resulting data is sent to the branch data fusion module.
[0046] The branch data fusion module concatenates the outputs of the three convolutional branches in the multi-scale convolutional branch structure and compresses them through convolution. Specifically, after directly concatenating the outputs of the three convolutional branches along the channel dimension, the number of channels becomes 3. Then through a containing 3 convolution kernel Convolutional layers (i.e.) Figure 2 The Fusion layer in the middle), recompressed to The channel generates second intermediate data that conforms to the output data format.
[0047] The second intermediate data then enters the Squeeze-and-Excitation (SE) module. This module employs a side-branch structure, where global average pooling and two fully connected layers squeeze the second intermediate data into a condensed vector and generate a set of channel importance weights between 0 and 1. In one embodiment, the scaling ratio of the fully connected layers in the Squeeze-and-Excitation module can be set to r=16.
[0048] Subsequently, the output data fusion module multiplies the weight coefficients back onto the second intermediate data. Without changing the feature map size and number of channels, it amplifies the data channels containing key impurity information and suppresses the noise channels, generating the third intermediate data. Then, through a residual connection (Shortcut), the original input data or the processed first intermediate data is added to the third intermediate data to generate the output of the multi-scale residual feature extraction layer, ensuring effective gradient propagation.
[0049] It should be noted that the division of the above data format conversion module, branch data fusion module, extrusion excitation module and output data fusion module is for clearly describing the data flow and processing logic inside the multi-scale residual feature extraction layer, and does not limit the function of the layer structure. In actual application, the above modules can be split, reorganized or integrated according to specific implementation requirements, and the naming does not constitute a limitation on the protection scope. The core of the embodiment is the data flow path and processing mode defined by each module.
[0050] Optionally, the diesel detection model further comprises a data preprocessing layer; the data preprocessing layer is configured to perform normalization processing on the Raman spectrum to generate first channel data, perform first-order difference calculation on the first channel data to generate second channel data, stack the first channel data and the second channel data, and perform convolution operation on the stacked data through at least one convolution kernel to expand the channel number of the data to generate an output of the data preprocessing layer; and the output of the data preprocessing layer is configured to be input into the first multi-scale residual feature extraction layer for feature extraction.
[0051] The embodiment further limits the data preprocessing process after the model receives the Raman spectrum.
[0052] Specifically, the model performs data processing on the Raman spectrum through the data preprocessing layer. The data preprocessing layer performs data processing in a dual-flow data preprocessing manner.
[0053] Since diesel has strong fluorescence characteristics, and the fluorescence background of different batches of diesel differs greatly, directly using the original light intensity for training will cause the model to be difficult to converge. The data preprocessing layer constructs a dual-channel input of "original flow + difference flow", as shown in Figure 3 , to retain the full spectrum information while enhancing the weak signal features.
[0054] First, the Raman spectrum data is normalized. In order to eliminate the absolute value difference of light intensity caused by different measurement distances and integration times, the original spectrum is mapped to the interval of 0 to 1, and the calculation formula is: As mentioned above, the data form of the Raman spectrum is the original spectrum sequence . represents the minimum value of the original spectrum sequence, represents the maximum value 0 of the original spectrum sequence, represents the i-th element in the original spectrum sequence, represents the i-th element in the first channel data. The normalization operation retains the relative shape information of the spectrum, which is the basis for qualitative analysis of the spectrum.
[0055] Then, first channel data is subjected to first-order difference calculation, and a first-order derivative of normalized spectrum is calculated by using the high-pass filtering characteristic of the difference operation (for discrete data, the first-order difference can be understood as the first-order derivative) to obtain second channel data , and the formula is: The purpose of introducing the second channel data is to effectively suppress the low-frequency broadband fluorescence background by using the first-order difference, while significantly enhancing the edge gradient information of the high-frequency Raman characteristic peaks (especially the fingerprint peaks of alcohol substances). Through this double-channel stacking instead of simple mathematical addition and subtraction, the subsequent neural network can simultaneously receive macro baseline trend information and micro feature peak mutation information, and automatically learn the weight relationship between the two through the convolution layer. Compared with the existing technology of removing "non-information variables", this processing method completely retains the full spectrum data, effectively avoids the loss of trace signals caused by manual screening of wavebands, and is crucial for realizing accurate detection of 1% low-concentration doping.
[0056] Then, the and the are stacked in the channel dimension to form data of 2 channels. The stacked data is further passed through a convolution layer, and at least one convolution kernel is set in the convolution layer to further expand the channel number of the data through convolution operation.
[0057] In one embodiment, the model inputs a Raman spectrum of 512 pixels, and forms a tensor with a dimension of after data preprocessing layer. Then, the tensor with a dimension of passes through a convolution layer containing 32 convolution kernels, and each convolution kernel has a size of 7 in the length dimension and a step of 1. The convolution layer expands the channel number from 2 to 32 by convolution operation, combining the BatchNorm layer and the ReLU activation function therein, while keeping the spectrum length of 512 unchanged, and outputs a preliminary shallow feature map with a dimension of .
[0058] Optionally, the diesel detection model further includes a result classification layer; the result classification layer is located after the last feature pooling layer; the result classification layer converts the input data into a confidence score of whether the diesel to be detected is doped with alcohol substances by using global average pooling and a fully connected layer, and generates a detection result based on the confidence score.
[0059] In this embodiment, the way in which the model analyzes the extracted features to generate a detection result is limited.
[0060] Specifically, the result classification layer is located after the last feature pooling layer. First, a global average pooling (GAP) layer is used to perform an irreversible average operation on the data in the length dimension of each channel, completely erasing the length dimension and compressing it into a feature tensor with multiple channels, but the data length of each channel is 1. Then, the tensor is flattened into a one-dimensional vector and input to a fully connected (FC) layer, which linearly maps the vector to an output vector containing two values, namely Logits, which are unnormalized logarithmic probabilities. These two values correspond to the confidence scores of "pure diesel" and "alcohol impurities", respectively. Finally, the two confidence scores are converted into the percentage probability of the diesel to be detected containing alcohol impurities, i.e., the detection result.
[0061] In one embodiment, the confidence score is converted into the percentage probability of the diesel to be detected containing alcohol impurities by a Softmax function.
[0062] Optionally, during the training phase of the diesel detection model, before the training data is input into the diesel detection model, the training data is transformed based on a preset probability, and the transformation manner includes at least one of the following manners: randomly shifting the training data left and right by a preset number of pixel points; superimposing Gaussian white noise; superimposing a random linear background.
[0063] To solve the problem that the diesel mixing scene is complex and variable in actual application and it is difficult to cover all aspects through limited samples, the embodiment proposes to use a physical simulation enhancement strategy to expand the data amount during model training. This physical simulation enhancement strategy is different from the common enhancement methods such as flipping and cropping in image processing, but randomly shifts the training data, i.e., the pre-acquired spectral data, left and right by a preset number of pixel points to simulate the grating thermal drift of the spectrometer during each reading of the data for training, so as to force the model to learn the relative position of the characteristic peak rather than the absolute coordinate. The preset number of pixel points can be 1 or 2 pixel points. Or superimpose Gaussian white noise obeying a distribution to simulate the dark current fluctuation of the detector at different temperatures. In one embodiment, the superimposed Gaussian white noise obeys a distribution ; or superimposes a random linear background to simulate the random change of the fluorescence intensity of different oil substrates.
[0064] In one embodiment, the preset probability is set to 50%, i.e., 50% of the sample data in the training may be subjected to the above online transformation during input.
[0065] Through the physical simulation enhancement strategy proposed in the embodiment, the model sees "completely new" samples that conform to the physical law in each training round, thereby forcing the model to learn the essential features of the spectrum.
[0066] Optionally, during the training phase of the diesel detection model, the loss function used is the focus loss function.
[0067] This embodiment proposes that, during the training phase of the diesel detection model, the FocalLoss function (also known as the hard example mining loss function) is used, which takes the following form: In one embodiment, a focus factor is set. The value is 2.0. This is when the model is very confident in identifying a particular sample. When it is close to 1), When the value approaches 0, the loss weight of the sample is significantly reduced; conversely, for samples with trace amounts of low-concentration doping (difficult cases) with indistinct features and low model prediction probabilities, the loss weight is retained. A balance factor is also set. The weight is set to 0.6 (for doped classes), giving a larger weight to minority classes to address the class imbalance problem.
[0068] like Figure 4 The diagram shown is a schematic of data format transformation during detection based on the diesel Raman spectroscopy detection method based on convolutional neural networks described in the second embodiment.
[0069] Specifically, the Raman spectrum of the input model is 512 pixels. In the data preprocessing layer, a set of 2×512 tensors is generated through normalization and first-order difference calculation. Then, it is passed through a Stem convolutional layer with 32 convolutional kernels, each with a length dimension of 7 and a stride of 1. The final output of the data preprocessing layer is data with a dimension of 32×512.
[0070] The data is then processed through a three-tiered multi-scale residual feature extraction layer-feature pooling layer structure. The first multi-scale residual feature extraction layer (MS-Res-Block) has the same input and output formats, performing only feature extraction. The second and third multi-scale residual feature extraction layers double the number of channels through convolution operations. The feature pooling layer uses max pooling for downsampling, with a pooling window size of 2 and a stride of 2, halving the length of the data each time it passes through.
[0071] Finally, the data is input into the classification layer. A global average pooling layer performs an irreversible averaging operation on the 128×64 data along its length dimension, completely eliminating the length dimension and compressing it into a feature tensor, which is then flattened into a one-dimensional vector of length 128. This vector is input to the fully connected layer and linearly mapped to an output vector containing two values, corresponding to the confidence scores for "pure diesel" and "alcohol-adulterated impurities," respectively. During prediction, these scores are converted into percentage probabilities using the Softmax function.
[0072] To verify the effectiveness of the method provided in the embodiments of the present application, the following experimental data is provided: First, a dataset containing 10 concentration gradients (1% to 10%) of alcohol-doped diesel oil is constructed, with a total of 349 samples, and is divided into a training set and a validation set in a 7:3 ratio. SVM, Random Forest (RF), AlexNet, LeNet, and the diesel detection model provided in the embodiments of the present application are selected for comparative experiments. The training parameters of all deep learning models (AlexNet, LeNet, MSResNet) are kept consistent to ensure fairness: the optimizer is Adam, the initial learning rate is set to 0.001, the batch size is set to 16, and the total number of training epochs is uniformly set to 50. Among them, the SVM uses the RBF kernel function; the number of decision trees of RF is set to 100; AlexNet and LeNet are adjusted to adapt to 512-dimensional vectors, and the standard cross-entropy loss function (Cross Entropy Loss) is used; and the diesel detection model provided in the embodiments of the present application uses the above-mentioned difficult case mining loss function (Focal Loss).
[0073] The experimental results are shown in Table 1 below. AlexNet has a deep network structure (containing 5 layers of convolution and 3 layers of full connection) and a huge number of parameters, and has a serious overfitting phenomenon on a small dataset with only 200 training samples. Although it can achieve a high accuracy on the training set, the accuracy on the validation set is only 77.5%, and the precision (Precision) and recall (Recall) for the minority class (doped oil) are both 0.00. This indicates that the model has "collapsed", that is, it tends to predict all samples as the majority class (pure diesel) to obtain a high accuracy on the surface, and cannot extract effective chemical features from the spectral data.
[0074] Table 1 Comparison of performance of various models on the validation set The results of Table 1 are analyzed as follows: the accuracy of SVM on the validation set is 78.75%, and the F1 score of the adulterated oil F1 is only 0.26, indicating that the traditional shallow model is difficult to handle the complex nonlinear relationship of high-dimensional spectral data. Random Forest performs well, with a validation set accuracy of 93.75%, but the recall rate is only 72% when dealing with extremely low concentration adulteration, indicating that it is easy to miss the sample with a trace amount of feature that is not obvious. LeNet, as a lightweight network, has a validation set accuracy of 93.00%, but due to its single convolution kernel size, it is difficult to balance the wide frequency fluorescence background and narrowband Raman characteristic peaks. In contrast, the diesel detection model provided in the present application achieves the highest accuracy of 97.50% on the validation set. In particular, in the most critical indicator - the recognition of alcohol adulterated samples, the precision (Precision) reaches 94%, the recall (Recall) reaches 94%, and the F1 score reaches 0.94. This fully proves that the multi-scale feature extraction combined with the physical simulation enhancement strategy can effectively solve the problem of small sample, multi-gradient, and trace adulteration detection.
[0075] The third embodiment of the present application also provides a diesel Raman spectrum detection device based on a convolutional neural network, as shown in Figure 5 The device comprises: A spectrum acquisition module 510 is configured to acquire the Raman spectrum of the diesel to be detected. An inference detection module 520 is configured to input the Raman spectrum into a pre-trained diesel detection model to obtain a detection result output by the model, the detection result representing the possibility of the diesel to be detected being adulterated with alcohol substances; wherein the diesel detection model comprises a multi-scale convolution branch structure, and the multi-scale convolution branch structure comprises three parallel convolution branches with different convolution kernel sizes; the convolution kernel size of a first convolution branch in the parallel convolution branches is associated with a narrowband characteristic peak in the spectrum; the convolution kernel size of a second convolution branch in the parallel convolution branches is greater than that of the first convolution branch, and is associated with a medium-width characteristic peak in the spectrum; and the convolution kernel size of a third convolution branch in the parallel convolution branches is greater than that of the second convolution branch, and is associated with a wide frequency background trend of the spectrum. The further function description of each module and unit is the same as the corresponding embodiment described above, and will not be repeated here.
[0076] The diesel Raman spectrum detection device based on the convolutional neural network in the present embodiment is presented in the form of functional units, where the unit refers to an ASIC (Application Specific Integrated Circuit, Application Specific Integrated Circuit) circuit, a processor and a memory executing one or more software or fixed programs, and / or other devices that can provide the above functions.
[0077] Please refer to Figure 6 ,Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application, such as... Figure 6 As shown, the computer device includes one or more processors 610, memory 620, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 6 Take the 610 processor as an example.
[0078] The processor 610 may be a central processing unit, a network processor, or a combination thereof. The processor 610 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0079] The memory 620 stores instructions executable by at least one processor 610 to cause the at least one processor 610 to perform the method shown in the above embodiments.
[0080] The memory 620 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 620 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 620 may optionally include memory remotely located relative to the processor 610, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0081] The memory 620 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 620 may also include a combination of the above types of memory.
[0082] The computer device also includes a communication interface 630 for the computer device to communicate with other devices or communication networks.
[0083] In one embodiment, the computer device provided by the embodiment can be used to Figure 7 In the example shown, the spectral acquisition device is arranged at the oil to be detected, and data is transmitted to the computer terminal by wireless or wired mode, the model is deployed on the computer terminal and detection is performed, and the detection result is displayed.
[0084] The embodiments of the present application also provide a computer readable storage medium, and the method according to the embodiments of the present application can be implemented in hardware, firmware, or recorded in a storage medium, or be implemented as computer code stored in a remote storage medium or a non-transitory machine readable storage medium and stored in a local storage medium through network downloading, so that the method described herein can be processed by such software on a storage medium using a general computer, a special processor or programmable or special hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk or a solid state disk, etc. Further, the storage medium can also include a combination of the above-mentioned memories. It can be understood that the computer, the processor, the microprocessor controller or the programmable hardware include a storage component that can store or receive software or computer code, when the software or computer code is accessed and executed by the computer, the processor or the hardware, the method shown in the above embodiments is implemented.
[0085] The embodiments of the present application provide a computer program product, which includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method of any embodiment of the present application.
[0086] Although the embodiments of the present application are described in conjunction with the accompanying drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes fall within the scope defined by the appended claims.
[0087] It can be understood that the data (including but not limited to the data itself, the acquisition or use of the data) involved in the technical solution should comply with the requirements of the corresponding laws, regulations and relevant provisions.
[0088] The method, device, computer device, computer readable storage medium and computer program product illustrated by the above embodiments can be implemented by a computer chip or entity, or by a product having certain functions. A typical implementation device is a computer. Specifically, the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0089] For the sake of clarity, the above device is described by dividing it into various units in terms of functions. Of course, the functions of the units can be implemented in software and / or hardware in the same or more than one software and / or hardware.
[0090] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, device, computer device, computer readable storage medium and computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage etc.) containing computer-usable program code.
[0091] The present application is described with reference to the flowcharts and / or block diagrams according to the methods, devices, computer devices, computer readable storage media and computer program products of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device implemented in the flowcharts and / or block diagrams. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks.
[0092] These computer program instructions can also be stored in a computer readable storage medium that can direct the computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable storage medium produce a product including an instruction device that implements the flowcharts and / or block diagrams. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks. Figure 1 The device that implements the function specified in one flow or multiple flows and / or blocks.
[0093] These computer program instructions can also be loaded into a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 Figure 1
[0094] It should also be noted that the term "comprising" or "comprises" when used in this specification is taken to mean the term "including" or "includes" such that the process, method, article, or apparatus that comprises items includes at least those items, but not excluding others. However, the term "comprising" when used in this specification also encompasses the terms "consisting of" and "consisting essentially of".
[0095] Each of the embodiments in the present specification is described in a progressive manner, and the same or similar parts between the embodiments can be mutually referred to, and each of the embodiments mainly explains the difference from other embodiments. In particular, for the device, computer device, computer readable storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the part of the method embodiment.
[0096] The above only describes the embodiments of the present application and is not intended to limit the present application. The present application can have various modifications and changes for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the scope of the claims of the present application.
[0097] Although the embodiments of the present application are described in conjunction with the drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes shall fall within the scope defined by the appended claims.
Claims
1. A diesel Raman spectrum detection method based on a convolutional neural network, characterized in that, The method comprises: obtaining a Raman spectrum of diesel to be detected; inputting the Raman spectrum into a pre-trained diesel detection model to obtain a detection result output by the model, the detection result representing a possibility of existence of alcohol adulteration in the diesel to be detected; wherein the diesel detection model comprises a multi-scale convolution branch structure, the multi-scale convolution branch structure comprising three parallel convolution branches with different convolution kernel sizes; a convolution kernel size of a first convolution branch in the parallel convolution branches is associated with a narrow-band characteristic peak in the spectrum; a convolution kernel size of a second convolution branch in the parallel convolution branches is larger than the convolution kernel size of the first convolution branch and is associated with a medium-width characteristic peak in the spectrum; a convolution kernel size of a third convolution branch in the parallel convolution branches is larger than the convolution kernel size of the second convolution branch and is associated with a wide-frequency background trend of the spectrum.
2. The method of claim 1, wherein, The diesel detection model comprises at least one multi-scale residual feature extraction layer and at least one feature pooling layer; the multi-scale residual feature extraction layer comprises the multi-scale convolution branch structure, and input data of the multi-scale residual feature extraction layer are input into each convolution branch respectively; the feature pooling layer is located after the multi-scale residual feature extraction layer and is used for downsampling the extracted feature data.
3. The method of claim 2, wherein, The multi-scale residual feature extraction layer further comprises a data format conversion module, a branch data fusion module, a squeeze excitation module and an output data fusion module; the data format conversion module is used for processing input data of the multi-scale residual feature extraction layer through convolution operation when an input data format of the multi-scale residual feature extraction layer is different from an output data format, to generate first intermediate data conforming to the output data format; the branch data fusion module is used for splicing and compressing outputs of the three convolution branches in the multi-scale convolution branch structure through convolution, to generate second intermediate data conforming to the output data format; the squeeze excitation module is used for generating channel weights through global average pooling and a fully connected layer based on the second intermediate data; the output data fusion module is used for multiplying the channel weights back to the second intermediate data to generate third intermediate data, and adding the input data of the multi-scale residual feature extraction layer or the first intermediate data to the third intermediate data to generate an output of the multi-scale residual feature extraction layer.
4. The method of claim 2, wherein, The diesel detection model further comprises a data preprocessing layer; the data preprocessing layer is used for performing normalization processing on the Raman spectrum to generate first channel data, performing first-order difference calculation on the first channel data to generate second channel data, stacking the first channel data and the second channel data, performing convolution operation on the stacked data through at least one convolution kernel to expand the number of channels of the data, and generating an output of the data preprocessing layer; the output of the data preprocessing layer is used for inputting into a first multi-scale residual feature extraction layer for feature extraction.
5. The method of claim 2, wherein, The diesel detection model further comprises a result classification layer; the result classification layer is located after a last feature pooling layer; The result classification layer converts the input data into a confidence score of whether the diesel to be detected is mixed with alcohol by global average pooling and a fully connected layer, and generates the detection result based on the confidence score.
6. The method of claim 1, wherein, In the training phase of the diesel detection model, before inputting the training data into the diesel detection model, the training data is transformed based on a preset probability, and the transformation manner includes at least one of the following manners: randomly shifting the training data left and right by a preset number of pixel points; superimposing Gaussian white noise; superimposing a random linear background.
7. The method of claim 1, wherein, In the training phase of the diesel detection model, the loss function used is a focal loss function.
8. A diesel Raman spectrum detection device based on a convolutional neural network, characterized in that, The device comprises: a spectrum acquisition module configured to acquire a Raman spectrum of diesel to be detected; an inference detection module configured to input the Raman spectrum into a pre-trained diesel detection model, and acquire a detection result output by the model, the detection result representing a possibility of the diesel to be detected being mixed with alcohol; wherein the diesel detection model comprises a multi-scale convolution branch structure, the multi-scale convolution branch structure comprising three parallel convolution branches with different convolution kernel sizes; a convolution kernel size of a first convolution branch in the parallel convolution branches is associated with a narrow-band characteristic peak in the spectrum; a convolution kernel size of a second convolution branch in the parallel convolution branches is larger than the convolution kernel size of the first convolution branch, and is associated with a medium-width characteristic peak in the spectrum; a convolution kernel size of a third convolution branch in the parallel convolution branches is larger than the convolution kernel size of the second convolution branch, and is associated with a wide-frequency background trend of the spectrum.
9. A computer device, comprising: comprise: a memory and a processor, which are communicatively connected, and the memory stores computer instructions, and the processor executes the computer instructions to perform the diesel Raman spectrum detection method based on the convolutional neural network according to any one of claims 1 to 7.
10. A computer program product, characterised in that, comprise computer instructions for causing a computer to perform the diesel Raman spectrum detection method based on the convolutional neural network according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method for rapidly detecting methanol content in methanol gasoline based on Raman-near-infrared spectroscopy fusion technology
CN110361373A
Drug Raman spectrum identification method based on convolutional neural network
CN113030060A
PDRN quality evaluation classification system based on multi-branch convolutional neural network
CN119027387A
Meat freshness nondestructive testing method based on deep learning and hyperspectral technology
CN120043979A
Raman spectrum and near infrared spectrum feature fusion method, device and equipment
CN120296397A