Diesel fuel Raman spectroscopy detection method, apparatus and equipment based on convolutional neural networks

By using a multi-scale convolutional branch structure based on convolutional neural networks, the problem of rapid and accurate identification of alcohol doping in diesel fuel was solved, enabling efficient identification of low-concentration alcohol doping on low-cost equipment and meeting the needs of rapid on-site detection.

CN121830628BActive Publication Date: 2026-07-31CHINESE PEOPLES ARMED POLICE FORCE NON-COMMISSIONED OFFICER SCHOOL
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINESE PEOPLES ARMED POLICE FORCE NON-COMMISSIONED OFFICER SCHOOL
Filing Date
2026-03-11
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

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 feature information and are susceptible to interference from strong fluorescence background.

Method used

A diesel Raman spectroscopy detection method based on convolutional neural networks is adopted. Multi-scale convolutional branch structure is used to extract multi-scale feature information in the spectrum, including narrow band, medium width feature peaks and broadband background trends, which improves the model's recognition sensitivity and noise resistance, and preserves the physical continuity of the spectrum.

Benefits of technology

It enables efficient identification of low-concentration alcohol doping on low-cost equipment, reduces hardware costs, expands application scenarios, meets the needs of rapid on-site detection, and improves detection accuracy and sensitivity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121830628B_ABST
    Figure CN121830628B_ABST
Patent Text Reader

Abstract

This application relates to the field of oil product testing technology, and more particularly to a method, apparatus, computer equipment, and computer program product for diesel fuel Raman spectroscopy detection based on convolutional neural networks. The method provided in this application includes: acquiring the Raman spectrum of the diesel fuel to be tested; inputting the Raman spectrum into a pre-trained diesel fuel detection model, obtaining the detection result output by the model, the detection result characterizing the possibility of alcohol doping in the diesel fuel; wherein, the diesel fuel detection model includes a multi-scale convolutional branch structure, which includes three parallel convolutional branches with different kernel sizes. The method provided in this application, through the parallel execution of the three convolutional branches, can simultaneously extract feature information at multiple scales in the spectrum, significantly enhancing the model's ability to identify and extract weak signal features, and achieving efficient and accurate identification of alcohol doping behavior in diesel fuel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of oil product testing technology, and in particular to a method, apparatus, computer equipment, and computer program product for detecting diesel fuel using convolutional neural networks in Raman spectroscopy. Background Technology

[0002] In the current refined oil market, adulteration with methanol, ethanol, and other alcohols is a common practice. Although such adulteration is not easily detected in the short term, it reduces the calorific value of the fuel, accelerates engine corrosion, and causes problems such as excessive emissions, threatening vehicle safety and polluting the environment.

[0003] Traditional detection methods for the aforementioned behaviors rely on laboratory physicochemical analysis techniques, such as gas chromatography-mass spectrometry (GC-MS) or high-performance liquid chromatography (HPLC). However, the detection equipment for these methods is bulky and requires complex pretreatment, and can usually only be implemented in specialized laboratories, which cannot meet the needs of application scenarios such as gas stations, oil depots, and mobile testing vehicles.

[0004] To address these issues and overcome these limitations, rapid detection technologies based on optical principles have received widespread attention in recent years. However, the characteristic signals of alcohol adulterants in diesel fuel are extremely weak and easily masked by strong fluorescence background and noise. Existing methods mostly rely on detection models for identification, typically employing manual selection of wavelength bands or dimensionality enhancement of one-dimensional spectra to improve the extraction capability of characteristic signals. However, such processing disrupts the physical continuity of spectral data, easily leading to the loss of crucial trace information, and making it difficult to achieve a 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, in order to achieve efficient and accurate identification of alcohol adulteration in diesel fuel. Summary of the Invention

[0006] This application provides a diesel Raman spectroscopy detection method based on convolutional neural networks, which enables efficient and accurate identification of alcohol doping behavior in diesel fuel.

[0007] To achieve the above objectives, the main technical solutions adopted in this application include: In a first aspect, embodiments of this application provide a method for detecting diesel fuel using Raman spectroscopy based on a convolutional neural network, the method comprising: Obtain the Raman spectrum of the diesel fuel to be tested; The Raman spectrum is input into a pre-trained diesel detection model to obtain the detection result output by the model. The detection result characterizes the possibility that the diesel to be detected contains alcohol substances. The diesel detection model includes a multi-scale convolutional branch structure, which comprises three parallel convolutional branches with different kernel sizes. The kernel size of the first convolutional branch is associated with narrow-band characteristic peaks in the spectrum. The kernel size of the second convolutional branch is larger than that of the first convolutional branch and is associated with medium-width characteristic peaks in the spectrum. The kernel size of the third convolutional branch is larger than that of the second convolutional branch and is associated with the broadband background trend of the spectrum.

[0008] The diesel Raman spectroscopy detection method based on convolutional neural networks proposed in this application includes a parallel multi-scale convolutional branch structure with three different kernel sizes. This structure executes in parallel through three branches, simultaneously extracting feature information at multiple scales in the spectrum: the small kernel branch captures narrow-band feature peaks corresponding to specific chemical bonds in alcohols; the medium kernel branch extracts medium-width feature peaks corresponding to common intact chemical bonds; and the large kernel branch focuses on the broadband background trend reflecting the overall spectral trend. This structure significantly enhances the model's ability to identify and extract weak signal features, improves the sensitivity for identifying low-concentration alcohol doping, and solves the problem of missed detections 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 and integrity of the original spectral information, while also possessing the advantage of easy deployment, meeting the practical application needs of rapid on-site detection.

[0009] Secondly, embodiments of this application provide a diesel Raman spectroscopy detection device based on a convolutional neural network, the device comprising: The spectrum acquisition module is used to acquire the Raman spectrum of the diesel fuel to be tested; The inference detection module is used to input the Raman spectrum into a pre-trained diesel detection model and obtain the detection result output by the model. The detection result characterizes the possibility that the diesel to be detected contains alcohol doping. The diesel detection model includes a multi-scale convolutional branch structure, which includes three parallel convolutional branches with different kernel sizes. The kernel size of the first convolutional branch is associated with narrow-band characteristic peaks in the spectrum. The kernel size of the second convolutional branch is larger than that of the first convolutional branch and is associated with medium-width characteristic peaks in the spectrum. The kernel size of the third convolutional branch is larger than that of the second convolutional branch and is associated with a broadband background trend in the spectrum.

[0010] Thirdly, embodiments of this application provide a computer device, including: The system includes a memory and a processor, which are interconnected. The memory stores computer instructions, and the processor executes these computer instructions to perform the diesel fuel Raman spectroscopy detection method based on a convolutional neural network as described in the first aspect.

[0011] Fourthly, embodiments of this application provide a computer program product, including computer instructions, which are used to cause a computer to execute the diesel Raman spectroscopy detection method based on a convolutional neural network as described in the first aspect. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0013] Figure 1 A step diagram illustrating a diesel fuel Raman spectroscopy detection method based on a convolutional neural network, provided in an embodiment of this application; Figure 2 This is a schematic diagram of the internal structure of a multi-scale residual feature extraction layer provided in an embodiment of this application; Figure 3 This application provides a schematic diagram illustrating the data processing principle of a data preprocessing layer in an embodiment of the present application. Figure 4 This is a schematic diagram of the structure of a diesel detection model provided in an embodiment of this application; Figure 5 A schematic diagram of a diesel fuel Raman spectroscopy detection device based on a convolutional neural network is provided for an embodiment of this application; Figure 6 A schematic diagram of the structure of a computer device provided in an embodiment of this application; Figure 7 This is a schematic diagram illustrating a diesel Raman spectroscopy detection method based on a convolutional neural network implemented using a computer device provided in an embodiment of this application. Detailed Implementation

[0014] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0015] Diesel fuel, a crucial power fuel for industrial production and transportation, directly impacts engine lifespan and air pollution control. In recent years, driven by substantial economic interests and fluctuating petrochemical markets, adulteration in the refined oil market has become rampant. Unscrupulous merchants often adulterate standard diesel fuel with low-cost alcohols such as methanol and ethanol to reap exorbitant profits. While the addition of alcohols may temporarily keep the engine running, their low calorific value, high corrosiveness, and hygroscopic nature lead to decreased engine power, accelerated corrosion and wear of fuel pumps, swelling and failure of rubber seals, and even engine knocking and severely excessive exhaust emissions. Therefore, achieving rapid and accurate detection of alcohol adulteration in diesel fuel is of paramount importance for protecting consumer rights, ensuring vehicle safety, and regulating the refined oil market.

[0016] Currently, 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 extremely high detection accuracy and can accurately determine the content of various components in oil, their drawbacks are that the detection equipment is expensive and bulky, usually only usable in specialized laboratories, and the sample pretreatment process is cumbersome and time-consuming, which cannot meet the urgent needs of rapid on-site screening and online real-time monitoring at gas stations, oil depots, and mobile testing vehicles.

[0017] To address the challenges of on-site detection, rapid detection technologies based on optical principles have emerged. Among existing optical-based detection technologies, some solutions attempt to utilize deep learning to process spectral data. This typically involves reshaping one-dimensional spectral data into a two- or three-dimensional matrix, combining this with a no-information variable removal (UVE) algorithm to select specific bands before inputting the data into a 2D or 3D convolutional network for classification. However, this approach has significant drawbacks: First, the Raman characteristic peaks of alcohol dopants in diesel fuel are extremely weak and distributed across the entire spectrum; manually selecting bands can easily lead to the loss of minute feature information, resulting in missed detections. Second, forcibly upscaling the essentially one-dimensional spectral data not only disrupts the physical continuity of spectral wavelengths but also introduces a large number of redundant parameters, drastically increasing the computational load of the model and making it difficult to deploy on low-cost, low-computing-power portable terminals. Furthermore, facing the complex strong fluorescence background of diesel fuel, simple band selection is insufficient to effectively separate the background from the signal. Secondly, industrial-grade diesel fuel has a complex matrix composition, containing large amounts of polycyclic aromatic hydrocarbons and gums, which produce extremely strong fluorescence backgrounds under laser excitation. In contrast, the Raman characteristic peaks of trace-doped alcohols (such as those with a doping ratio between 1% and 10%) are extremely weak and are often submerged in strong fluorescence background and environmental thermal noise, resulting in a very low signal-to-noise ratio. Traditional baseline correction and peak-finding algorithms often fail in this "strong background, weak signal" scenario, leading to a high false negative rate.

[0018] This application provides a diesel Raman spectroscopy detection method based on a convolutional neural network to solve the above-mentioned problems. It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowcharts, in some cases, the steps shown or described may be performed in a different order than that shown here.

[0019] This embodiment provides a diesel fuel Raman spectroscopy detection method based on convolutional neural networks, such as... Figure 1 As shown, it includes the following steps: Step 110: Obtain the Raman spectrum of the diesel fuel to be tested.

[0020] In this embodiment, it is necessary to first obtain the data of the input diesel detection model, specifically the Raman spectrum of the diesel to be detected.

[0021] Since the method provided in this embodiment improves the feature extraction capability through a multi-scale convolutional branch structure, it reduces the requirement for Raman spectral resolution. The spectral data that meets the detection requirements can be obtained by scanning the diesel fuel to be tested using a common portable Raman spectrometer.

[0022] In one embodiment, a low-resolution photoelectric detection module is selected, and the excitation source is a frequency-stabilized semiconductor laser with a center wavelength of 785nm. The laser power is preferably set to 350mW to balance the Raman signal intensity and sample thermal damage, and the integration time is set to 12000ms. The detector is an uncooled linear CCD or CMOS sensor with an effective pixel count of [missing information]. =512. This means that the spectrometer discretizes a continuous wavelength range (e.g., 200 to 3000 wavenumbers) into 512 data points, and a single acquisition yields a one-dimensional array of length 512. Let this array be the original spectral sequence. .

[0023] Compared to the 2048-pixel configuration commonly found in scientific research equipment, the configuration in this embodiment reduces the amount of spectral data acquired by 75%, greatly reducing the computational load. However, it also brings the challenge of reduced spectral resolution, i.e., wider and more overlapping feature peaks, requiring the detection method to have stronger feature extraction capabilities.

[0024] In one embodiment, the spectral acquisition device may also be a device capable of providing the raw light intensity and dark current data required by the embodiments of this application, such as a discrete photodiode array or a CMOS sensor equipped with a specific filter.

[0025] Step 120: Input the Raman spectrum into a pre-trained diesel detection model and obtain the detection result output by the model. The detection result characterizes the possibility that the diesel to be detected contains alcohol doping. The diesel detection model includes a multi-scale convolutional branch structure, which includes three parallel convolutional branches with different kernel sizes. The kernel size of the first convolutional branch is associated with narrow-band characteristic peaks in the spectrum. The kernel size of the second convolutional branch is larger than that of the first convolutional branch and is associated with medium-width characteristic peaks in the spectrum. The kernel size of the third convolutional branch is larger than that of the second convolutional branch and is associated with the broadband background trend of the spectrum.

[0026] This embodiment proposes that the acquired Raman spectrum be input into a pre-trained diesel detection model, and the detection results output by the model include the possibility that the diesel to be detected is doped with alcohols.

[0027] Specifically, the core of the diesel detection model used in this embodiment is a multi-scale convolutional branch structure. This is based on the narrow characteristic peaks of alcohols in Raman spectroscopy (approximately...). "Diesel background width (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 in 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, and if the model outputs a probability of "alcohol doping" greater than a set threshold, for example, a threshold of 90%, an alarm signal is issued.

[0032] Experiments show that the method proposed in this embodiment has a much higher accuracy in identifying trace doped samples under complex concentration gradients than traditional models. The relevant experimental data will be listed later.

[0033] The second embodiment of this application further specifies the diesel Raman spectroscopy detection method based on convolutional neural networks in the first embodiment in a more detailed and specific way. Some or all of the technical features in the second embodiment can be combined with or replaced by the first embodiment, either individually or in combination, to obtain more feasible diesel Raman spectroscopy detection methods based on convolutional neural networks.

[0034] The diesel fuel Raman spectroscopy detection method based on convolutional neural networks in the second embodiment of this application is described in detail below: Optionally, the diesel detection model includes at least one multi-scale residual feature extraction layer and at least one feature pooling layer; the multi-scale residual feature extraction layer includes a multi-scale convolutional branch structure, and the input data of the multi-scale residual feature extraction layer is respectively input to each convolutional branch; the feature pooling layer is located after the multi-scale residual feature extraction layer and is used to downsample the extracted feature data.

[0035] This embodiment further defines the structure of the diesel detection model.

[0036] Specifically, this embodiment proposes that the model includes at least one multi-scale residual feature extraction layer (MS-Res-Block). The multi-scale residual feature extraction layer includes the aforementioned multi-scale convolutional branch structure, and its input data is fed in parallel into three convolutional branches with different kernel sizes, which are used to extract multi-scale spectral features such as narrowband, medium width and broadband background respectively; after convolution processing, each branch outputs the extracted features.

[0037] The model also includes at least one feature pooling layer. The feature pooling layer is placed after the multi-scale residual feature extraction layer and is used to downsample the feature data extracted by the multi-scale residual feature extraction layer, thereby reducing the data dimensionality and enhancing the model's robustness to local translational perturbations.

[0038] In one embodiment, the feature pooling layer employs max pooling with a pooling window size of 2 and a stride of 2.

[0039] To further improve feature extraction performance, the number of multi-scale residual feature extraction layers can be increased. This involves setting up multiple repeated "multi-scale residual feature extraction layer-feature pooling layer" structures to analyze the data multiple times, thereby enhancing feature extraction efficiency. In one embodiment, three cascaded multi-scale residual feature extraction layers-feature pooling layers are used in the model for feature extraction.

[0040] The model structure in this embodiment further enhances the model's ability to analyze and extract weak doping signals by introducing a pooling mechanism and a multi-layer feature extraction mechanism.

[0041] Optionally, the multi-scale residual feature extraction layer further includes a data format transformation module, a branch data fusion module, a squeezing excitation module, and an output data fusion module. The data format transformation module is used to process the input data of the multi-scale residual feature extraction layer through convolution operations when the input data format and output data format of the multi-scale residual feature extraction layer are different, generating first intermediate data that conforms to the output data format. The branch data fusion module is used to concatenate the outputs of the three convolution branches in the multi-scale convolution branch structure and compress them through convolution to generate second intermediate data that conforms to the output data format. The squeezing excitation module is used 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 used to multiply the channel weights back to the second intermediate data to generate third intermediate data, and then add the input data format of the multi-scale residual feature extraction layer or the first intermediate data to the third intermediate data to generate the output of the multi-scale residual feature extraction layer.

[0042] This embodiment further defines the structure of the multi-scale residual feature extraction layer.

[0043] Specifically, based on the goal of feature extraction, the multi-scale residual feature extraction layer abandons the general residual network with huge parameter numbers or the 2D / 3D network that requires dimensionality increase, and specially designs a lightweight structure with a fully convolutional structure. For example... Figure 2 As shown, when the input data enters the multi-scale residual feature extraction layer, it is simultaneously fed into the data format transformation module and the multi-scale convolution branch structure in parallel.

[0044] Here, we assume the number of input channels of the module is The target number of output channels is When the number of input channels With output channel When they are not equal, the data format conversion module will be based on a 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 into the data format transformation module, branch data fusion module, squeezing excitation module, and output data fusion module is intended to clearly describe the data flow and processing logic within the multi-scale residual feature extraction layer, rather than to limit the functional structure of this layer. In practical applications, these modules can be split, reorganized, or integrated according to specific implementation requirements, and their naming does not constitute a limitation on the scope of protection. The core of this embodiment lies in the data flow path and processing method defined by each module.

[0050] Optionally, the diesel detection model also includes a data preprocessing layer; the data preprocessing layer is used to normalize the Raman spectrum to generate first channel data, and to 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 number of channels of the data, generating the output of the data preprocessing layer; the output of the data preprocessing layer is used as input to the first multi-scale residual feature extraction layer for feature extraction.

[0051] This embodiment further defines the data preprocessing procedure after the model receives Raman spectra.

[0052] Specifically, the model processes Raman spectra through a data preprocessing layer. This preprocessing layer uses a two-stream data preprocessing method.

[0053] Because diesel fuel exhibits strong fluorescence, and the fluorescence background varies significantly between different batches, directly using the raw light intensity for training can lead to model convergence difficulties. The data preprocessing layer constructs a dual-channel input of "raw stream + differential stream," such as... Figure 3 As shown, this is done to enhance weak signal features while preserving full-spectrum information.

[0054] First, the Raman spectral data is normalized. To eliminate differences in absolute light intensity caused by variations in measurement distance and integration time, the original spectrum is mapped to the 0-1 interval. The calculation formula is as follows: As explained earlier, Raman spectroscopy data is in the form of raw spectral sequences. . Represents the minimum value of the original spectral sequence. The maximum value 0 represents the original spectral sequence. Represents the i-th element in the original spectral sequence. This represents the i-th element in the first channel data. Normalization preserves the relative shape information of the spectrum and is the foundation of qualitative spectral analysis.

[0055] Then, a first-order difference calculation is performed on the first channel data. Utilizing the high-pass filtering characteristic of the difference operation, the first derivative of the normalized spectrum is calculated (for discrete data, the first-order difference can be understood as the first derivative) to obtain the second channel data. The formula is: The purpose of introducing the second channel data is to effectively suppress low-frequency broadband fluorescence background using first-order difference, while significantly enhancing the edge gradient information of high-frequency Raman characteristic peaks (especially fingerprint peaks of alcohols). This dual-channel stacking, rather than simple mathematical addition and subtraction, allows the subsequent neural network to simultaneously receive macroscopic baseline trend information and microscopic characteristic peak abrupt change information, and automatically learns the weight relationship between the two through convolutional layers. Compared to existing techniques that remove "uninformative variables," this processing method completely preserves the full-spectrum data, effectively avoiding the loss of trace signals caused by manual band selection, which is crucial for achieving accurate detection of low-concentration doping (1%).

[0056] Then, and The data is stacked along the channel dimension to form two channels. The stacked data is then passed through a convolutional layer with at least one convolutional kernel to further expand the number of channels through convolution operations.

[0057] In one embodiment, the model input is a Raman spectrum of 512 pixels, which is then processed by a data preprocessing layer to form a dimension of... The tensor. Then. The tensor is passed through a convolutional layer containing 32 kernels, each with a length dimension of 7 and a stride of 1. The convolutional layer, through convolution operations combined with a BatchNorm layer and a ReLU activation function, expands the number of channels from 2 to 32 while maintaining the spectral length of 512, resulting in an output dimension of... Preliminary shallow feature map.

[0058] Optionally, the diesel detection model also includes a result classification layer; the result classification layer is located after the last feature pooling layer; the result classification layer, through global average pooling and fully connected layers, transforms the input data into a confidence score for whether the diesel to be detected contains alcohols, and generates the detection result based on the confidence score.

[0059] In this embodiment, the method by which the model analyzes the extracted features to generate detection results is limited.

[0060] Specifically, the classification layer follows the last feature pooling layer. First, a Global Average Pooling (GAP) layer irreversibly averages the data along the length dimension of each channel, completely eliminating the length dimension and compressing it into a feature tensor with multiple channels, each with a data length of 1. Then, the tensor is flattened into a one-dimensional vector and input to a fully connected (FC) layer. The FC layer linearly maps the vector into an output vector containing two values: Logits, the unnormalized log probabilities. These two values ​​correspond to the confidence scores for "pure diesel" and "adulterated with alcohol impurities," respectively. Finally, these two confidence scores are converted into the percentage probability of alcohol adulteration in the detected diesel, i.e., the detection result.

[0061] In one embodiment, the confidence score is converted into a percentage probability of alcohol adulteration in the diesel fuel to be detected using the Softmax function.

[0062] Optionally, during 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. The transformation method includes at least one of the following: randomly shifting the training data left and right by a preset number of pixels; superimposing Gaussian white noise; superimposing a random linear background.

[0063] To address the challenges of complex and varied diesel adulteration scenarios in practical applications, which are difficult to fully cover with limited samples, this embodiment proposes a physical simulation enhancement strategy to expand the data volume during model training. This strategy differs from commonly used image processing enhancement methods such as flipping and cropping. Instead, during each data read for training, the training data (i.e., pre-acquired spectral data) is randomly shifted left and right by a preset number of pixels to simulate the thermal drift of the spectrometer grating. This forces the model to learn the relative positions of feature peaks rather than their absolute coordinates. The preset number of pixels can be one or two. Alternatively, Gaussian white noise following a distribution can be superimposed to simulate the dark current fluctuations of the detector at different temperatures. In one embodiment, the superimposed Gaussian white noise follows a distribution... ; or superimposed random linear background To simulate the random variation of fluorescence intensity in different oil matrices.

[0064] In one embodiment, the preset probability is set to 50%, meaning that there is a 50% chance that the sample data in the training will undergo the above-mentioned online transformation when input.

[0065] The physical simulation enhancement strategy proposed in this embodiment ensures that the model sees "new" samples that conform to physical laws in each round of training, thereby forcing the model to learn the essential characteristics 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 this application, the following experimental data is provided: First, a dataset of 349 alcohol-adulterated diesel fuels with 10 concentration gradients (1% to 10%) was constructed and hierarchically divided into training and validation sets in a 7:3 ratio. Comparative experiments were conducted using SVM, Random Forest (RF), AlexNet, LeNet, and the diesel fuel detection model provided in this embodiment. All deep learning models (AlexNet, LeNet, and MSResNet) maintained consistent training parameters to ensure fairness: the optimizer was Adam, the initial learning rate was set to 0.001, the batch size was set to 16, and the total number of training epochs was uniformly set to 50. Specifically, SVM used the RBF kernel function; the number of decision trees in RF was set to 100; AlexNet and LeNet adjusted their input layers to fit 512-dimensional vectors and used the standard cross-entropy loss function; while the diesel fuel detection model provided in this embodiment used the aforementioned hard example mining loss function (Focal Loss).

[0073] The experimental results are shown in Table 1 below. Due to its excessively deep network structure (containing 5 convolutional layers and 3 fully connected layers) and massive number of parameters, AlexNet exhibited severe overfitting on a small dataset with only about 200 training samples. Although it achieved high accuracy on the training set, its accuracy on the validation set was only 77.5%, and both precision and recall for the minority class (adulterated oil) were 0.00. This indicates that the model "collapsed," tending to predict all samples as the majority class (pure diesel) to achieve a superficially high accuracy, failing to extract effective chemical features from the spectral data.

[0074] Table 1. Performance Comparison of Each Model on the Validation Set The results in Table 1 are analyzed as follows: SVM achieved an accuracy of 78.75% on the validation set, but its F1 score for doped oil was only 0.26, indicating that traditional shallow models struggle to handle the complex nonlinear relationships in high-dimensional spectral data. Random Forest performed reasonably well, achieving an accuracy of 93.75% on the validation set, but its recall was only 72% when dealing with extremely low concentrations of doping, suggesting it is prone to missing samples with subtle, inconspicuous features. LeNet, as a lightweight network, achieved an accuracy of 93.00% on the validation set, but due to its single convolutional kernel scale, it struggles to simultaneously handle both broadband fluorescence background and narrowband Raman characteristic peaks. In contrast, the diesel detection model provided in this application achieved the highest accuracy of 97.50% on the validation set. Particularly noteworthy is its performance in the most critical metric—identification of alcohol doped samples—achieving a precision of 94%, a recall of 94%, and an F1 score of 0.94. This demonstrates that multi-scale feature extraction combined with physical simulation enhancement strategies can effectively solve the challenges of detecting small samples, multiple gradients, and trace amounts of doping.

[0075] The third embodiment of this application also proposes a diesel Raman spectroscopy detection device based on a convolutional neural network, such as... Figure 5 As shown, the device includes: The spectrum acquisition module 510 is used to acquire the Raman spectrum of the diesel fuel to be tested; The inference detection module 520 is used to input Raman spectra into a pre-trained diesel detection model and obtain the detection results output by the model. The detection results characterize the possibility of alcohol doping in the diesel to be detected. The diesel detection model includes a multi-scale convolutional branch structure, which includes three parallel convolutional branches with different kernel sizes. The kernel size of the first convolutional branch in the parallel convolutional branches is associated with narrow-band characteristic peaks in the spectrum. The kernel size of the second convolutional branch in the parallel convolutional branches is larger than that of the first convolutional branch and is associated with medium-width characteristic peaks in the spectrum. The kernel size of the third convolutional branch in the parallel convolutional branches is larger than that of the second convolutional branch and is associated with the broadband background trend of the spectrum. Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0076] In this embodiment, the diesel Raman spectroscopy detection device based on convolutional neural networks is presented in the form of functional units. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0077] Please see 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 communicating with other devices or communication networks.

[0083] In one embodiment, the computer device provided in this embodiment can be used through... Figure 7 The example shown involves placing the spectral acquisition device at the oil sample to be tested and transmitting the data to a computer terminal via wireless or wired means. The model is then deployed on the computer terminal for testing, and the test results are displayed.

[0084] This application also provides a computer-readable storage medium. The methods described in this application can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and subsequently stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the methods shown in the above embodiments are implemented.

[0085] This application provides a computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method of any embodiment of this application.

[0086] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and all such modifications and variations fall within the scope defined by the appended claims.

[0087] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.

[0088] The methods, apparatus, computer devices, computer-readable storage media, and computer program products described in the above embodiments can be implemented by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0089] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.

[0090] Those skilled in the art will understand that embodiments of this application can be provided as methods, apparatus, computer devices, computer-readable storage media, and computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-readable program code.

[0091] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, computer devices, computer-readable storage media, and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations 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, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0092] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0093] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0094] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0095] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, computer equipment, computer-readable storage media, and computer program products are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0096] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

[0097] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method for detecting diesel fuel using Raman spectroscopy based on convolutional neural networks, characterized in that, The method includes: Obtain the Raman spectrum of the diesel fuel to be tested; The Raman spectrum is input into a pre-trained diesel detection model to obtain the detection result output by the model. The detection result characterizes the possibility that the diesel to be detected contains alcohol substances. The diesel detection model includes a multi-scale convolutional branch structure, which comprises three parallel convolutional branches with different kernel sizes. The kernel size of the first convolutional branch is associated with narrow-band characteristic peaks in the spectrum. The kernel size of the second convolutional branch is larger than that of the first convolutional branch and is associated with medium-width characteristic peaks in the spectrum. The kernel size of the third convolutional branch is larger than that of the second convolutional branch and is associated with the broadband background trend of the spectrum. The diesel detection model includes at least one multi-scale residual feature extraction layer, and the multi-scale residual feature extraction layer includes the multi-scale convolutional branch structure; The multi-scale residual feature extraction layer also includes a data format transformation module, a branch data fusion module, a squeezing excitation module, and an output data fusion module; The data format conversion module is used to process the input data of the multi-scale residual feature extraction layer through convolution operation when the input data format and output data format of the multi-scale residual feature extraction layer are different, and generate first intermediate data that conforms to the output data format. The branch data fusion module is used to concatenate the outputs of the three convolutional branches in the multi-scale convolutional branch structure and compress them through convolution to generate second intermediate data that conforms to the output data format. The squeezing incentive module is used 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 used to multiply the channel weights back to the second intermediate data to generate the third intermediate data, and then add the input data format of the multi-scale residual feature extraction layer or the first intermediate data to the third intermediate data to generate the output of the multi-scale residual feature extraction layer.

2. The method according to claim 1, characterized in that, The diesel detection model includes at least one multi-scale residual feature extraction layer and at least one feature pooling layer; The input data of the multi-scale residual feature extraction layer is respectively input to each convolutional branch; The feature pooling layer is located after the multi-scale residual feature extraction layer and is used to downsample the extracted feature data.

3. The method according to claim 2, characterized in that, The diesel detection model also includes a data preprocessing layer; The data preprocessing layer is used to normalize 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 number of channels of the data, thereby generating the output of the data preprocessing layer. The output of the data preprocessing layer is used as input to the first multi-scale residual feature extraction layer for feature extraction.

4. The method according to claim 2, characterized in that, The diesel fuel detection model also includes a result classification layer; The result classification layer is located after the last feature pooling layer; The result classification layer, through global average pooling and a fully connected layer, transforms the input data into a confidence score indicating whether the diesel fuel to be detected contains alcohols, and generates the detection result based on the confidence score.

5. The method according to claim 1, characterized in that, During 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. The transformation method includes at least one of the following: randomly shifting the training data left and right by a preset number of pixels; superimposing Gaussian white noise; superimposing a random linear background.

6. The method according to claim 1, characterized in that, During the training phase of the diesel detection model, the loss function used is the focus loss function.

7. A diesel fuel Raman spectroscopy detection device based on a convolutional neural network, characterized in that, The device includes: The spectrum acquisition module is used to acquire the Raman spectrum of the diesel fuel to be tested; The inference detection module is used to input the Raman spectrum into a pre-trained diesel detection model and obtain the detection result output by the model. The detection result characterizes the possibility that the diesel to be detected contains alcohol doping. The diesel detection model includes a multi-scale convolutional branch structure, which includes three parallel convolutional branches with different kernel sizes. The kernel size of the first convolutional branch is associated with narrow-band characteristic peaks in the spectrum. The kernel size of the second convolutional branch is larger than that of the first convolutional branch and is associated with medium-width characteristic peaks in the spectrum. The kernel size of the third convolutional branch is larger than that of the second convolutional branch and is associated with a broadband background trend in the spectrum. The diesel detection model includes at least one multi-scale residual feature extraction layer, and the multi-scale residual feature extraction layer includes the multi-scale convolutional branch structure; The multi-scale residual feature extraction layer also includes a data format transformation module, a branch data fusion module, a squeezing excitation module, and an output data fusion module; The data format conversion module is used to process the input data of the multi-scale residual feature extraction layer through convolution operation when the input data format and output data format of the multi-scale residual feature extraction layer are different, and generate first intermediate data that conforms to the output data format. The branch data fusion module is used to concatenate the outputs of the three convolutional branches in the multi-scale convolutional branch structure and compress them through convolution to generate second intermediate data that conforms to the output data format. The squeezing incentive module is used 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 used to multiply the channel weights back to the second intermediate data to generate the third intermediate data, and then add the input data format of the multi-scale residual feature extraction layer or the first intermediate data to the third intermediate data to generate the output of the multi-scale residual feature extraction layer.

8. A computer device, characterized in that, include: The system includes a memory and a processor, which are interconnected. The memory stores computer instructions, and the processor executes the computer instructions to perform the diesel fuel Raman spectroscopy detection method based on any one of claims 1 to 6.

9. A computer program product, characterized in that, Includes computer instructions for causing a computer to execute the diesel Raman spectroscopy detection method based on a convolutional neural network as described in any one of claims 1 to 6.