A method for automatically identifying fine scratches on the surface of luggage under adaptive lighting

By using an adaptive illumination system and a spectral gradient response module, the problems of substrate reflection differences and channel redundancy in multispectral scratch recognition are solved, achieving high-precision and low-power scratch detection.

CN122223508APending Publication Date: 2026-06-16GUANGDONG AOYONGXING LEATHER GOODS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG AOYONGXING LEATHER GOODS CO LTD
Filing Date
2026-03-26
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing multispectral scratch recognition technologies suffer from problems such as strong black-box behavior of AI models, the impact of substrate reflectivity differences on generalization performance, and redundant configuration of multispectral channels, leading to unstable detection results and wasted computing resources.

Method used

By constructing an adaptive illumination system, eliminating substrate reflection differences through a lookup table of Lambertian reflectance coefficients, and generating an attribution heatmap using a spectral gradient response module and an attribution consistency constraint loss function, the system dynamically adjusts the combination of light source bands to achieve interpretability and efficient detection.

Benefits of technology

It significantly improves the accuracy and robustness of scratch recognition across different material scenarios, reduces the false detection rate and false negative rate, reduces hardware power consumption and computational burden, and achieves efficient scratch detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122223508A_ABST
    Figure CN122223508A_ABST
Patent Text Reader

Abstract

The present application provides a kind of self-adapting light luggage surface micro scratch automatic identification method, through programmable multi-spectrum narrowband LED light source and accurate timing control, seven waveband high-resolution image is collected, and base material normalization processing is carried out to multi-waveband image in combination with Lambert body reflection coefficient look-up table;Using the one-dimensional convolution kernel of shared weight adjustable bias, spectral gradient response module is constructed to realize waveband specificity gradient feature extraction and normalization;Cross-waveband attention weighting mechanism is used to aggregate discriminant response, generate attribution mask and gate multi-scale spatial features, improve the discriminant ability of scratch area;Consistency constraint loss is introduced in training stage to optimize scratch and background separation, and physical waveband attribution heat map is output during inference to realize explainability visualization, and the waveband combination of light source is dynamically optimized accordingly, the present application significantly eliminates substrate interference, improves multi-waveband scratch discrimination precision and efficiency, realizes multi-spectrum acquisition strategy intelligent self-adaptation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent visual inspection and multispectral image processing technology, and in particular to an automatic identification method for minute scratches on the surface of bags under adaptive lighting. Background Technology

[0002] In the current field of scratch recognition and multispectral image processing, mainstream visual inspection solutions mostly employ image segmentation and classification methods based on deep convolutional networks or machine learning, leveraging multi-channel optical information to improve the detection capability of subtle defects on the surface of items such as bags. Typical publicly available technologies focus on feature extraction, band fusion, and classification algorithm optimization of multispectral or hyperspectral images, with some methods improving the robustness of defect discrimination under various materials and lighting conditions. For example, in traditional machine vision industrial defect detection, mainstream solutions often employ three types of multispectral fusion strategies: early fusion of images from different bands, mid-term feature integration, and late-term decision integration. These strategies combine U-Net, ResNet, and lightweight MobileNet structures to perform end-to-end extraction and judgment of scratch features, and have achieved certain engineering applications in industries such as leather goods, bags, and plastic coverings. In recent years, with the improvement of the accuracy and acquisition efficiency of multispectral imaging equipment, the recognition of fine scratches based on multispectral images has been widely studied. Some studies have introduced multi-scale pyramid structures, attention mechanisms, and Transformer architectures to enhance the model's ability to integrate features of different scales and spectroscopic dimensions. Other studies have utilized generative adversarial networks (GANs) to improve the generation of false scratches and the generalization of the model, or used autoencoders to reconstruct errors to achieve anomaly region detection. These approaches typically focus on improving the accuracy and robustness of the detection results, expanding the industrial application boundaries of scratch recognition. However, in practical applications, existing multispectral scratch recognition technologies have the following typical problems: (1) AI models are relatively black boxes and lack effective explanations of "which band or feature has the greatest impact on the scratch segmentation results". Most models in the industry only output segmentation or discrimination results, and users cannot know the specific contribution of different spectral bands, fusion weights or microstructure responses to the final recognition results. (2) To address the problem of impaired image contrast caused by the intrinsic differences in reflectivity of various substrates such as PU, PVC, and nylon, most existing technologies employ simple normalization or data augmentation, failing to establish consistent constraints between the optical physical mechanism at the material level and AI feature extraction, thus affecting the generalization performance of the algorithm under different batches and working conditions. (3) The activation and weight configuration of multispectral channels are usually determined by experience or a large number of experiments, making it difficult to achieve systematic adaptive control. This results in some redundant bands participating in the inference process, increasing system energy consumption and computational burden. Summary of the Invention

[0003] In order to solve the above-mentioned technical problems, the present invention provides an automatic identification method for minor scratches on the surface of bags and luggage based on adaptive lighting.

[0004] The technical solution of this invention is implemented as follows: A method for automatic identification of minor scratches on the surface of bags based on adaptive lighting, comprising: S1: Control the light source system to sequentially light up 7 discrete narrowband LEDs covering the range of 400–1000 nm according to a preset timing sequence, and simultaneously acquire 7 channels of original image sequences of the same area on the surface of the bag, with each channel image having a resolution of 1280×960; S2: Based on the Lambertian reflectance coefficient lookup table of three types of substrates (PU, PVC, and nylon) for bags, the pixel value normalization process is performed on the 7-channel original image sequence output by S1 to eliminate the interference of intrinsic reflectance differences of the substrates and generate a normalized image sequence. S3: Based on the normalized image sequence output by S2, a spectral gradient response module is constructed according to the parameter configuration of a one-dimensional convolution kernel with shared weights but adjustable bias. The local gradient response tensor of each band is extracted through 7 sets of convolution kernels. S4: Using the spectral gradient response module constructed in S3, cross-band attention weighted aggregation is performed on the local gradient response tensor to generate a gradient attribution mask, which characterizes the band response intensity that is most discriminative for scratch discrimination at each pixel location. S5: The gradient attribution mask output by S4 is fused with multi-scale spatial features through channel-level gating to generate a fused feature tensor, ensuring that the spatial context information is preserved in the low attribution region. S6: Based on the manually labeled ground truth mask for scratches, introduce the attribution consistency constraint loss to force the gradient attribution mask to have a pixel mean of no less than 0.85 in the scratch area and a pixel mean of no more than 0.15 in the background area. S7: While outputting the surface scratch segmentation results of the bag, it generates a high-resolution attribution heatmap mapped to the physical band dimension, indicating the gradient response characteristics of each band to the scratch edge. S8: Analyze the band contribution based on the attribution heatmap output by S7, dynamically shut down redundant band light sources and lock the optimal three-band combination to achieve real-time optimization of the multispectral acquisition strategy.

[0005] The present invention provides an automatic identification method for minor scratches on the surface of bags under adaptive lighting, which has the following beneficial effects: (1) This invention models the physical reflection characteristics of bag materials as differentiable prior knowledge and embeds it into the neural network training process. This solution effectively overcomes the problem of unstable scratch contrast caused by the difference in intrinsic reflection of substrate in traditional multispectral visual detection. A lookup table library of band-related Lambertian reflectance coefficients is established for common materials such as PU, PVC, and nylon. Pixel-level nonlinear correction is implemented in the preprocessing stage, which significantly improves the consistent expression ability of scratch features in cross-material scenarios. This enables the model to maintain a high sensitivity response when facing unknown material combinations, greatly reducing the false detection rate and false negative rate. In particular, it shows stronger robustness in the task of weak contrast scratch (such as shallow scratches and blurred edge cracks), fundamentally solving the technical bottleneck of existing methods that rely on post-processing enhancement or large amount of data re-labeling to adapt to new materials. (2) This invention proposes a dual-path interpretable feature encoding architecture to achieve a leap from "black box decision-making" to "physical causal tracing". The main spatial feature extraction path and the attribution path based on spectral gradient response work together. The most discriminative feature regions are dynamically weighted and retained through a channel-level gating fusion mechanism. While ensuring segmentation accuracy, an attribution heatmap with clear optical semantics is generated. An attribution consistency constraint loss function is introduced and combined with a gradient reversal layer optimization strategy to force the attention distribution learned by the model to be highly aligned with the manually labeled scratch area. This ensures that the attribution mask A output by the SGRM module not only reflects spatial saliency but also reflects the differentiated contribution of different wavelength light sources to the defect response. This enables AI judgment to have interpretable basis for specific wavelengths, breaking through the technical limitation of traditional deep learning models that are difficult to trace the source of judgment, and providing reliable decision support for industrial quality inspection systems. (3) Based on the closed-loop feedback capability of the attribution heatmap, this invention can dynamically identify and lock the optimal band combination (such as 470nm+650nm+850nm) that is most sensitive to the current scratch type during the inference stage, guide the front-end light source control system to shut down redundant LED channels, significantly reduce hardware power consumption and image acquisition latency, and at the same time reduce the amount of data processed in the subsequent process, thereby improving the overall detection efficiency. This mechanism realizes the transformation from "static full spectrum acquisition" to "dynamic sparse perception", and can complete the energy efficiency ratio optimization without the need to deploy additional complex algorithm modules, avoiding the waste of computing resources and system response lag problems that are common in traditional solutions. Attached Figure Description

[0006] Figure 1 This is a flowchart of an automatic identification method for minor scratches on the surface of a bag under adaptive lighting, according to the present invention. Figure 2 This is a sub-flowchart of an adaptive illumination method for automatic identification of minor scratches on the surface of bags according to the present invention; Figure 3This is another sub-flowchart of the method for automatic identification of minor scratches on the surface of bags under adaptive lighting according to the present invention. Detailed Implementation

[0007] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0008] The following disclosure provides many different embodiments or examples for implementing different structures of the invention. To simplify the disclosure, specific examples of components and arrangements are described below. Of course, these are merely examples and are not intended to limit the invention. Furthermore, reference numerals and / or letters may be repeated in different examples; such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.

[0009] like Figure 1 As shown, this invention provides an automatic identification method for minor scratches on the surface of bags based on adaptive lighting, specifically including: S1: Control the light source system to sequentially light up 7 discrete narrowband LEDs covering the range of 400–1000 nm according to a preset timing sequence, and simultaneously acquire 7 channels of original image sequences of the same area on the surface of the bag, with each channel image having a resolution of 1280×960; S2: Based on the Lambertian reflectance coefficient lookup table of three types of substrates (PU, PVC, and nylon) for bags, the pixel value normalization process is performed on the 7-channel original image sequence output by S1 to eliminate the interference of intrinsic reflectance differences of the substrates and generate a normalized image sequence. S3: Based on the normalized image sequence output by S2, a spectral gradient response module is constructed according to the parameter configuration of a one-dimensional convolution kernel with shared weights but adjustable bias. The local gradient response tensor of each band is extracted through 7 sets of convolution kernels. S4: Using the spectral gradient response module constructed in S3, cross-band attention weighted aggregation is performed on the local gradient response tensor to generate a gradient attribution mask, which characterizes the band response intensity that is most discriminative for scratch discrimination at each pixel location. S5: The gradient attribution mask output by S4 is fused with multi-scale spatial features through channel-level gating to generate a fused feature tensor, ensuring that the spatial context information is preserved in the low attribution region. S6: During the model training phase, based on the manually labeled ground truth mask for scratches, an attribution consistency constraint loss is introduced to force the average pixel value of the gradient attribution mask in the scratch area to be no less than 0.85 and the average pixel value in the background area to be no more than 0.15. S7: While outputting the scratch segmentation results of the bag surface during the inference stage, a high-resolution attribution heatmap mapped to the physical band dimension is generated to indicate the gradient response characteristics of each band to the scratch edge. S8: Analyze the band contribution based on the attribution heatmap output by S7, dynamically shut down redundant band light sources and lock the optimal three-band combination to achieve real-time optimization of the multispectral acquisition strategy.

[0010] Step S1: Control the light source system to sequentially illuminate 7 discrete narrowband LEDs covering the 400–1000 nm range according to a preset timing sequence, and simultaneously acquire 7-channel raw image sequences of the same area on the surface of the bag, with each channel image having a resolution of 1280×960. Specifically, this includes: S1.1: Based on industrial standard LED driver circuits and microcontroller units, a light source control system is constructed. This system integrates seven discrete narrowband LED light source modules with center wavelengths of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm and 850nm, respectively, to generate a programmable multispectral lighting environment covering the range of 400–1000 nm. Based on the input conditions of the industrial standard LED driver circuit and microcontroller unit, a modular circuit design method is adopted (parameters: driving voltage 24V, constant current output 700mA) to realize the independent current control function of multi-channel narrowband LED light source; Furthermore, by configuring a multi-channel constant current driver chip (parameters: number of channels ≥ 7, current adjustment step 10mA), the center wavelength matching output current stability control of the 7 discrete narrowband LED light source modules is achieved, and the channel output drive signal data at the device end is obtained; The microcontroller firmware program (parameters: bus clock frequency 8MHz, data frame length 16 bits) via the SPI bus protocol enables the register-level PWM duty cycle adjustment function of the driver chip to precisely control the linear change of the light intensity of the LED light source. Furthermore, using a wavelength selection matrix mapping algorithm (parameter: matrix dimension 7×N, where N is the number of adjustable light intensity levels of the LED light source), independent light intensity settings are achieved for seven LED light source modules with center wavelengths of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm, and a wavelength-light intensity control table is generated. A thermal management optimization algorithm (parameters: thermal sensor sampling period 200ms, temperature threshold 65℃) is adopted to achieve automatic current limiting of the drive circuit when the temperature exceeds the limit and automatic activation of the fan cooling module, ensuring the stability of the light source output during long-term band switching. Furthermore, by utilizing a dual closed-loop control method of constant current drive and thermal feedback (parameters: feedback coefficient 0.85, temperature control lag time 1.2s), the stability of the output current and light source temperature under load changes at the device end is achieved, and hardware status monitoring data is generated. Through the joint configuration of the above multi-channel driving circuit and microcontroller firmware, the center wavelength setting result of the previous step is converted into a hardware-level programmable multispectral lighting control signal, realizing a programmable lighting environment covering the range of 400–1000 nm. For example, in a luggage scratch detection platform, the LED driver chip model LT3965 is selected, the channel current is set to 700mA, and the corresponding drive channels of LED modules with center wavelengths of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm are configured with constant current output. The microcontroller model is STM32F407, with an SPI bus operating frequency of 8MHz, a data frame length of 16 bits, and a PWM adjustment range of 0–1023 steps per channel, corresponding to a linear light intensity adjustment range of 0–100%. Temperature detection uses an NTC thermistor probe with a sampling period of 200ms. The temperature threshold is set to 65℃. When the temperature exceeds the threshold, the drive current is automatically limited to 500mA and a 40mm diameter cooling fan is activated. The wavelength selection matrix mapping algorithm generates a matrix with a dimension of 7×256, and the output wavelength-light intensity control table is used for subsequent timing module calls. During execution, the system maintains LED output light intensity fluctuations within ±2 lux and temperature fluctuations within ±0.5℃ even under long-term band switching, achieving a stable programmable multispectral illumination environment and meeting the optical input requirements for subsequent image acquisition and scratch feature enhancement. S1.2: Based on the hardware interface parameters output by the light source control system, configure a preset timing signal generation module. This module defines the order, duration, and interval of LED lighting to ensure precise timing control of the multispectral lighting process. The hardware interface parameters of the light source control system output from S1.1 are used as input conditions, and a timing signal parameterization configuration method is adopted (parameters include: LED lighting sequence index array, single lighting duration). Band switching interval This allows for the initial configuration loading of the preset timing signal generation module. Furthermore, the encapsulation method is driven by the hardware abstraction layer (parameter: SPI bus speed). GPIO trigger delay This enables the synchronous binding of LED lighting commands with physical output ports, and yields a port mapping table data structure that accurately reflects the status of the control system. Furthermore, a time-series vector synthesis algorithm is employed (parameter: sequential index array). Duration array Interval array This enables vectorized encoding of switching signals between different frequency bands and generates a periodic control matrix for internal timers in FPGAs or MCUs. Furthermore, through a clock synchronization calibration method (parameter: external reference clock frequency) Error compensation coefficient This achieves phase alignment between the timing signal and the trigger pulse of the acquisition system, and generates a timing deviation index. ; Through the above-mentioned timing signal generation and calibration processing, the hardware interface parameters of the previous step are converted into precise timing control commands that can directly drive the light source control system, thereby ensuring the stability and repeatability of the multispectral illumination process. For example, in a rapid inspection system for the appearance of bags and luggage, the preset timing signal generation module adopts... Set to 40ms With a 20ms setting, the lighting sequence of the seven-band LEDs is [420nm, 470nm, 530nm, 590nm, 650nm, 730nm, 850nm]. The SPI bus rate is configured to 4MHz, and the GPIO trigger delay has been fine-tuned to 1.8ms through actual testing. The periodic control matrix is ​​constructed in the MCU timer with a resolution of 1ms, and the external reference clock frequency is 10MHz. =1.0003 compensation, making Deviation control within The configuration ensures that the illumination switching of each band remains in phase with the trigger signal of the industrial camera during actual operation, and the error between the light source switching and the acquisition time does not exceed 0.2%, significantly improving the spectral consistency and temporal stability of the multispectral acquisition sequence, and providing high-quality optical input data for subsequent scratch feature analysis; S1.3: Based on the timing control command output by the preset timing signal generation module, the light source control system is driven to light up each narrowband LED light source module in sequence to generate a single-band illumination sequence with sequential switching. Based on the timing control instructions output by the preset timing signal generation module, a multi-channel SPI bus driving method (parameters: bus frequency 1MHz, data width 8bit) is adopted to realize the multi-channel transmission of control signals to the corresponding narrowband LED driving units of the light source control system. Furthermore, by using the PWM duty cycle modulation method (parameters: duty cycle range 10%-100%, resolution 1%), the luminous intensity of each narrowband LED light source module is precisely set according to the preset band illuminance curve, and the brightness control data of the corresponding time slice is obtained. Furthermore, by using a pulse-triggered sequential scheduling algorithm (parameters: trigger delay 2ms, inter-module switching delay 5ms), the sequential lighting control of each narrowband LED is achieved, ensuring that other bands are completely turned off during a single band of illumination, generating an illumination state without spectral overlap. Furthermore, using a timing synchronization verification method (parameters: verification window 1ms, synchronization error threshold 0.1ms), the executed lighting command is compared with the preset timing template channel by channel to generate a timing synchronization deviation index, which is used to ensure the repeatability and consistency of lighting time in different bands. By using sequential lighting control and timing synchronization verification, the timing instructions from the previous step are transformed into a stable, non-overlapping single-band illumination sequence, thereby enabling the construction of single-channel image acquisition conditions under multispectral illumination environments. For example, in a bag inspection task, the control command output by the timing signal generation module defines the lighting sequence of the seven bands as 420nm→470nm→530nm→590nm→650nm→730nm→850nm, with a single band duration set to 50ms and an interval switching time set to 5ms. After receiving the SPI bus data, the light source control system controls the luminous intensity of each LED band to 20%, 35%, 50%, 60%, 70%, 80%, and 90% respectively, according to the gradient setting of the PWM duty cycle from small to large. During operation, the pulse trigger sequence scheduling algorithm ensures that the switching delay between adjacent bands is stable at 5ms, and that other bands are completely turned off during the switching process. The timing synchronization verification method measures that the actual lighting time of each band deviates from the preset value by no more than 0.05ms, meeting the synchronization error threshold requirement. The final output single-band illumination sequence is stable and has no spectral overlap, providing a precise physical lighting basis for subsequent synchronous acquisition by industrial cameras. S1.4: During each illumination of the narrowband LED light source module, the industrial camera image acquisition device is synchronously triggered to capture a single-channel raw image frame of the same area on the surface of the bag, with each frame having a fixed resolution of 1280×960 pixels; S1.5: Perform serialization and storage operations on the 7 single-channel raw image frames output by the synchronously triggered image acquisition device to generate structured 7-channel raw image sequence data, which serves as the input source for subsequent pixel value normalization processing.

[0011] Step S2: Based on the Lambertian reflectance coefficients of three substrates (PU, PVC, and nylon) for bags, a lookup table is used to perform pixel value normalization processing on the 7-channel original image sequence output from S1, eliminating interference from intrinsic reflectance differences in the substrates and generating a normalized image sequence. Specifically, this includes: S2.1: Based on standard samples and laboratory measurement data of three types of substrates for bags (PU, PVC, and nylon), a lookup table library of Lambertian reflectance coefficients is constructed. This lookup table library stores the reflectance coefficient values ​​of each substrate at seven discrete narrowband wavelengths in the range of 400-1000nm, so as to provide a basis for querying the reflectance characteristics of substrates. Based on the 7-channel original image sequence obtained from step S1 and the standard sample characteristic parameters output by the bag material information acquisition system, the laboratory high-precision integrating sphere reflectance measurement method (parameters: spectral range 400-1000nm, resolution 2nm) was used to sample and test the reflectance coefficients of PU, PVC and nylon substrates under seven discrete narrowband center wavelengths, thereby achieving high-confidence material spectral reflectance data acquisition. Furthermore, the multi-point reflection coefficient measurements of each type of substrate in the same band are reduced by a multi-point averaging algorithm (parameters: number of sampling points ≥ 10, statistical method is arithmetic mean), and first-order linear correction is performed in combination with the equipment calibration curve to eliminate the deviation between the experimental measurement values ​​and the physical true values. Furthermore, an interpolation fitting algorithm (parameters: piecewise linear interpolation, nodes are the measured center values ​​of the bands) is used to extend the corrected reflection coefficient curve into a continuous response dataset covering the entire 400-1000nm range, and precise sampling is performed at the seven target bands to obtain the discrete vector of the seven-band reflection coefficient of each substrate. Furthermore, by using the lookup table construction module, the discrete band reflection coefficients of the three types of substrates are mapped and bound to the "substrate type identifier" through key-value correspondence, forming three sets of mapping table structures to ensure that the corresponding band coefficient can be quickly located according to the material type in the subsequent retrieval process; Using the database construction method described above, the processed laboratory measurement results are transformed into a structured Lambertian reflectance coefficient lookup table library, which enables high-precision quantitative storage of the reflectance characteristics of different materials at specific wavelengths and meets the physical parameter call requirements of the normalization processing stage. For example, in one implementation, flat samples of 100mm×100mm were prepared for three types of bag materials: PU, PVC, and nylon. Spectral reflectance was tested using an integrating sphere reflectance measurement system equipped with a spectral response calibration module. The measured reflectance of PU material in the 650nm band was 0.72, after calibration by the equipment's linear correction factor. The corrected value is obtained after correction. = The measured reflectance of PVC material at 530nm is 0.65, with a correction factor of [missing value]. The correction result is = The measured reflectance of nylon material at 470nm is 0.58, with a correction factor of [missing value]. The correction result is = The corrected reflectance of the three materials at seven target narrowband wavelengths was stored sequentially in a lookup table. The seven-band reflectance vectors for PU material were {0.7416, 0.712, 0.695, 0.684, 0.721, 0.702, 0.689}, for PVC material {0.702, 0.676, 0.663, 0.655, 0.682, 0.668, 0.650}, and for nylon {0.660, 0.635, 0.620, 0.612, 0.640, 0.623, 0.610}. During the verification process, this lookup table effectively eliminated the differences in baseline reflectance between materials when called in the subsequent normalization step. The normalized image showed a significant improvement in multi-band scratch contrast compared to the unnormalized condition. S2.2: Obtain the substrate type identifier of the bag to be inspected. This identifier is based on the bag production information preset by the system or determined by the material identification sensor to clarify the category of the substrate being processed. S2.3: Based on the substrate type identifier obtained in S2.2 and the Lambertian reflectance lookup table library constructed in S2.1, retrieve the Lambertian reflectance of the corresponding substrate in each band and generate a band reflectance sequence as the parameter input for normalization processing; Based on the substrate type identifier obtained in S2.2, a lookup table retrieval method (parameters: substrate type identifier, Lambertian reflectance coefficient lookup table library) is used to locate the band reflectance coefficient record that matches the substrate type from the lookup table library; Furthermore, by using an index matching algorithm (parameters: band center wavelength list, substrate type index), the reflection coefficients of the seven discrete narrowband bands are read one by one, and the original set of reflection coefficients arranged in band order is obtained. Furthermore, a data verification method (parameters: original set of reflection coefficients, range of physical valid values) is adopted to verify the physical rationality of the read reflection coefficients and remove outliers that exceed the valid range, thereby improving the stability of normalization processing. Furthermore, by using a linear interpolation algorithm (parameters: missing band index, adjacent valid band reflection coefficient), the missing or abnormal band reflection coefficients are repaired, and a complete set of band reflection coefficients is generated, ensuring that the data structure is consistent for subsequent processing. Furthermore, the vector recombination method (parameters: complete set of band reflection coefficients, band sorting rules) is applied to recombine the reflection coefficients of each band into a band reflection coefficient sequence in the order of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm, which serves as the input parameter for the normalization formula. By using table lookup and index matching, the substrate type identifier of S2.2 is converted into the corresponding band reflection coefficient sequence, thus preparing the parameter input for subsequent pixel value normalization. For example, when the object to be tested is a PU substrate, the substrate type identifier "PU" is entered. A lookup table of Lambertian reflectance coefficients records that the reflectance coefficients of PU in the 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm wavelength bands are 0.62, 0.58, 0.55, 0.50, 0.48, 0.45, and 0.43, respectively. This sequence is directly obtained using a lookup table method. If the reflectance coefficient in the 530nm band is missing during the testing process, linear interpolation is performed using the adjacent band coefficients of 0.58 and 0.50. The repair value of 0.54 was obtained, and the outlier was replaced. The final band reflection coefficient sequence is [0.62, 0.58, 0.54, 0.50, 0.48, 0.45, 0.43]. This result is used as the denominator parameter in the normalization formula and is directly used to eliminate the intrinsic reflection difference of the PU substrate. The normalized pixel values ​​significantly improve the scratch contrast in multiple bands. S2.4: For each pixel in the 7-channel original image sequence output by S1, perform pixel value normalization correction processing based on the band reflectance coefficient sequence retrieved by S2.3 to generate normalized pixel values ​​that eliminate the intrinsic reflectance differences of the substrate. S2.5: The normalized pixel values ​​output from S2.4 are recombined into a 7-channel image sequence to generate a normalized image sequence. This sequence eliminates the interference of substrate reflection differences and provides consistent optical input for subsequent scratch feature extraction.

[0012] like Figure 2 As shown, step S3 involves constructing a spectral gradient response module based on the normalized image sequence output from S2, according to the parameter configuration of a one-dimensional convolution kernel with shared weights but adjustable bias. This module extracts the local gradient response tensor for each band using seven sets of convolution kernels. Specifically, this includes: S3.1: Based on the normalized image sequence output by S2 as input conditions, and according to the band response characteristics of the bag material reflectance lookup table, the network architecture of the spectral gradient response module is constructed: Seven sets of one-dimensional convolution kernel parameters with shared weights but adjustable biases are initialized. The size of each set of convolution kernels is configured as 1×1 and the number of output channels is fixed at 16, so as to establish an explicit mapping relationship between the wavelength center point and the pixel gradient, and generate a differentiable feature extraction unit with band-specific adjustment capability; Using the normalized image sequence output by S2 as input conditions, a band response characteristic matching method (parameters: material reflectance lookup table, seven center wavelengths) is adopted to realize the functional setting of the spectral gradient response module structure. Furthermore, through the convolution kernel parameter initialization algorithm (parameters: shared weight strategy, adjustable bias mechanism, convolution kernel size 1×1, number of output channels 16), seven band-specific convolution kernels are constructed, and initial weight matrix data with explicit mapping relationship between wavelength center point and pixel gradient is obtained. Furthermore, a convolution kernel parameter mapping configuration method (parameter: correspondence between band index and module input channel) is adopted to achieve one-to-one binding of normalized image input channels and convolution kernel groups, and generate a band-specific input channel mapping table; Furthermore, by using a differentiable feature extraction unit generation algorithm (parameters: weight sharing, bias independent adjustment), the convolutional kernel retains the ability to extract general spatial gradients while establishing an independent material response adjustment path for each band, and generating a network topology that can be quickly optimized for different bands. By configuring the above convolution kernel parameter architecture, the input conditions of the normalized image sequence in the previous step are transformed into differentiable feature extraction units with band-specific adjustment capabilities, thereby achieving accurate capture of local gradient responses in each band and ensuring the interpretability of subsequent gradient attribution calculations. For example, during the testing of PU material samples for bags, the normalized image sequence output by S2 has seven channels, corresponding to wavelengths of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm. According to the material reflectance lookup table, the reflectance coefficient of PU material is 0.82 at 420nm, 0.79 at 470nm, and 0.75, 0.73, 0.70, 0.68, and 0.65 for the remaining wavelengths. A shared weight initialization strategy is adopted, setting the initial values ​​of the weight matrices of the seven convolutional kernels to... to Gaussian distributed random values ​​within a range, with initial bias values ​​set as follows: To ensure stable initial gradient magnitudes, the kernel size for each convolutional group is fixed. The number of output channels is Each input channel is bound to a specific wavelength band. For example, the first group of convolutional kernels processes only the 420nm channel normalized image, and the second group processes only the 470nm channel normalized image. The initialization parameters are input into the spectral gradient response module, and a weight sharing and independent bias adjustment mechanism is implemented. The resulting convolutional kernel group can dynamically optimize the bias value for different wavelength bands during training iterations, thus adapting to the grayscale variation characteristics of scratch microstructures and backgrounds in different wavelength bands of the PU material. In actual operation, after 30 training iterations, the bias of each convolutional kernel group is within ± With dynamic fine-tuning, the output band-specific feature tensor shows significant local gradient enhancement in the scratch region, ensuring the stability and efficiency of subsequent gradient magnitude calculation and attention weight allocation. S3.2: Input the normalized image sequence into the spectral gradient response module constructed in S3.1, and perform cross-band feature mapping processing based on one-dimensional convolution kernel parameters: Input the seven-channel normalized image into the convolution kernel group of the corresponding band respectively, calculate the gray level change rate of each pixel in the local neighborhood through convolution operation, and obtain the original feature tensor set containing the band response characteristics as the basic input data for gradient response calculation; The normalized image sequence output by S2 is used as the input data of the spectral gradient response module. A one-dimensional convolutional feature mapping method (parameters: convolution kernel size 1×1, number of output channels 16, shared weight structure, adjustable band bias) is used to realize the pixel-wise correspondence between the input channels of each band and the receptive field of the network. Furthermore, by binding band indexes with convolution kernel groups (parameters: corresponding band center wavelengths 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, 850nm), parallel matching of the input seven-channel normalized image with seven groups of convolution kernels is achieved to ensure that the convolution operation results retain band-specific features; Furthermore, a local grayscale change rate calculation method is employed to calculate the pixel position in the convolution output of each band. The convolution operation is performed on the neighborhood window, and the convolution formula is expressed as: ,in The convolution kernel for the λ-th band is... For the pixel neighborhood of the input image corresponding to the band, This is the output of a convolution; Furthermore, utilizing the above convolution results, cross-band feature mapping processing is performed, and the convolution outputs of different bands are classified and stored according to the input channel λ, forming a set of original feature tensors with explicit grouping of band response characteristics { , ,..., }; By explicitly grouping band responses and constructing feature tensor sets, the convolution processing results are transformed into raw feature data containing local gray-level change rates and band response characteristics, thus preparing the basic data for gradient response calculation. For example, in one specific implementation, the input data is a seven-channel normalized image sequence output by S2. Each channel image has a resolution of 1280×960 pixels, corresponding to center wavelengths of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm, respectively. Each channel image is sequentially input into its corresponding 1×1 convolution kernel. The number of output channels of the convolution kernel is set to 16. Weights are shared, but biases are set independently according to band characteristics. For example, the bias value is 0.012 when λ=650nm, and the biases for other bands are configured decreasing according to material sensitivity. Convolution calculations are performed at pixel positions. Output results The value is 0.278, indicating a strong feature response reflecting the abrupt change in grayscale at the scratch edge within the corresponding neighborhood. After cross-band feature mapping, the original feature tensor set is obtained, where the mean response of the λ=650nm band is significantly higher than that of other bands. This verifies the high sensitivity of this band to scratch features under this material type and lighting conditions, providing strong data support for subsequent gradient magnitude calculation and interpretability analysis. S3.3: Based on the original feature tensor set output by S3.2, the gradient magnitude calculation is performed using the central difference algorithm: For the feature tensor of each band, the first-order partial derivatives are calculated along the horizontal and vertical directions of the image respectively. The bidirectional gradient components are fused by Euclidean norm to generate a gradient magnitude response map that characterizes the intensity of pixel gray-level abrupt changes. This response map quantifies the sensitivity of each band to changes in surface microstructure. Using the original feature tensor set output by S3.2 as input data, the central difference algorithm is employed (parameter: difference step size). =1 pixel =1 pixel), to realize the function of calculating local gray-level gradient along the horizontal direction; Furthermore, the local gray-level gradient calculation function along the vertical direction is realized through the center difference algorithm (with the same parameters as above), and the gray-level change rate feature map of each pixel in the vertical direction is obtained. Furthermore, a Euclidean norm fusion method (parameter: square root operation) is employed to achieve the fusion of horizontal gradient components. gradient components in the vertical direction The amplitude is fused, and a pixel-level gradient amplitude response map is generated, as shown in the following formula: in, The first-order partial derivative in the horizontal direction, The first-order partial derivative in the vertical direction, This represents the gradient magnitude. Furthermore, by using a band-independent calculation method, the above fusion operation is performed on the feature tensors of the seven bands respectively, generating a set of gradient magnitude response maps for the seven corresponding bands. By using gradient magnitude calculation and fusion processing, the directional gradient component results from the previous step are transformed into a gradient magnitude response map that quantifies the intensity of pixel gray-level abrupt changes, thereby achieving accurate quantification of the sensitivity of each band to changes in the microstructure of the bag surface. For example, in the scenario of detecting the surface of bags, a difference step size is set for the band feature tensor with a center wavelength of 650nm. =1 pixel =1 pixel, using the center difference formula: The result and Substituting into the gradient magnitude formula, we obtain the value of each pixel in the 650nm band. The gradient magnitude at the scratch edge is significantly higher than that in the smooth area of ​​the bag surface, indicating a significant improvement in the response intensity to microstructural changes. This provides fundamental data for enhanced sensitivity in subsequent band normalization and cross-band attention aggregation. S3.4: Perform band response normalization processing on the gradient amplitude response map generated in S3.3: Based on the preset Lambertian reflectance coefficient benchmark value, divide the gradient amplitude of each band by the material reflectance coefficient of the corresponding band to eliminate the response deviation caused by the intrinsic difference of the substrate, and output the standardized gradient response tensor corrected by the physical model to ensure that the scratch characteristics of different material surfaces are comparable. S3.5: Based on the normalized gradient response tensor output by S3.4, perform channel dimension feature aggregation processing: stack the normalized gradient response tensors of the seven bands along the channel axis to generate a three-dimensional gradient feature cube. This cube is output as a local gradient response tensor to the subsequent cross-band attention weighting module, fully preserving the differentiated contribution information of each band to scratch discrimination. Based on the normalized gradient response tensor output by S3.4 as input condition, the channel dimension stacking method is adopted (parameters: number of input tensors = 7, channel axis index = 3rd dimension) to sequentially concatenate the normalized gradient response tensors of the seven bands in the channel dimension and obtain a temporary stacked tensor containing gradient response information of all bands. Furthermore, by using a channel axis integrity verification algorithm (parameter: expected number of channels = 7 × C, where C is the number of channels of a single-band gradient response tensor), the structural consistency of the spliced ​​temporary stacked tensor is checked, and a verification result is generated confirming that there are no omissions in the channel dimension of each band data. Furthermore, a tensor dimension reconstruction method (parameter: output dimension order = height × width × channel) is adopted to rearrange the channel dimension stacking results into a three-dimensional gradient feature cube structure and generate multi-band gradient feature cube data with the same spatial resolution as the original input. Furthermore, through the band index mapping algorithm (parameters: band order list = 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, 850nm), the explicit labeling of the correspondence between the cube channel index and the physical band is realized, and a gradient feature cube with band labels is generated, providing an interpretable basis for the subsequent cross-band attention weighting module; By using the gradient feature cube output interface, the result of the previous step is converted into a local gradient response tensor, thus achieving the technical effect of fully preserving the differentiated contribution information of each band to scratch discrimination. For example, in a bag surface inspection task, the input is the standardized seven-band gradient response tensor output by S3.4, each tensor having a size of 128×128×16. Each band corresponds to a narrowband LED acquisition image at 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm, respectively. After performing channel dimension stacking processing, a temporary stacked tensor with a size of 128×128×112 is obtained. A channel axis integrity verification algorithm is used: let the number of channels per band C = The expected total number of channels is = The verification results showed consistency with the actual situation. After dimensional reconstruction, a three-dimensional gradient feature cube was obtained, and the physical band identifiers of each channel were mapped according to the seven-band center wavelength list. In the test, this feature cube significantly improved the response intensity of the scratch edge region under the optimal band combination in the subsequent cross-band attention weighted aggregation module. Compared with the single-band feature input before stacking processing, the segmentation map output by the scratch recognition module showed a significant improvement in noise suppression and edge continuity, verifying the effectiveness of this step in preserving the differences of multi-band features and optimizing subsequent discrimination performance.

[0013] like Figure 3 As shown, step S4 involves using the spectral gradient response module constructed in S3 to perform cross-band attention-weighted aggregation on the local gradient response tensor, generating a gradient attribution mask that characterizes the band response intensity at each pixel location that is most discriminative for scratch detection. Specifically, this includes: S4.1: Perform channel dimension compression on the local gradient response tensor output by S3, calculate the L2 norm based on the feature map of each band, and generate a single-channel response map for each band to eliminate channel redundancy and quantify the discriminative response intensity of each band at the pixel level. S4.2: Based on the single-channel response map of each band, calculate the cross-band attention score. By linearly combining the response values ​​of each band and applying the Sigmoid activation function, generate the attention score matrix to characterize the contribution of each band to the discrimination ability of the scratch area. Using the single-channel response maps of each band output by S4.1 as input conditions, a pixel-by-pixel linear combination algorithm (parameter: the length of the response value vector of each band is set to 7, corresponding to seven narrowband bands) is adopted to realize the weighted summation of the cross-band response of each pixel position. Furthermore, by setting initial weighting coefficients Based on the physical band priority (parameters derived from the stability ranking of band response in a lookup table of bag material reflectivity), the response values ​​of each band are... The weighted summation calculation is performed using the following formula: in, This is the cross-band linear combination value of the pixel. This refers to the band weighting coefficient. This is the normalized single-band response value; Furthermore, the linear combination values ​​mentioned above are processed using the Sigmoid activation function to achieve a non-linear mapping of the response values, as shown in the following formula: in, The pixel value of the attention score matrix ranges from [0,1] and is used to characterize the contribution of the pixel position to the overall discrimination ability across all bands. Furthermore, by performing the aforementioned weighted summation and sigmoid activation process on all pixel locations through matrix operations, a two-dimensional attention score matrix is ​​obtained. The dimension of this matrix is ​​the same as that of the original single-channel response. Figure 1 To; By using a matrix storage and indexing mechanism, the attention score matrix is ​​bound to the corresponding band index, providing an input data structure for the softmax normalization process in S4.3 and achieving continuity in attention weight calculation. For example, when performing this step on the surface of a PU material bag, the input seven-band single-channel response value matrix, after weight optimization using a physical lookup table, has a weight coefficient sequence of [0.12, 0.15, 0.18, 0.1, 0.2, 0.15, 0.1], where the response value of band 5 at 650nm is significantly higher than other bands. For a specific scratch pixel, its single-band response value vector is [0.45, 0.5, 0.53, 0.4, 0.75, 0.55, 0.42], and a linear combination value is obtained using a weighted summation formula. The attention score after Sigmoid mapping is The attention score matrix calculated across the entire image shows a concentrated high-value distribution in the scratch region and a low-value distribution in the background region, which significantly improves the ability of subsequent soft-normalized weight calculation to highlight scratch features; S4.3: Perform softmax normalization on the attention score matrix to generate cross-band attention weights, so as to constrain the sum of the band weights at each pixel position to 1, ensuring that the distribution of the relative importance of each band to scratch detection is represented. S4.4: Use cross-band attention weights to perform weighted summation on the single-channel response maps of each band to generate an aggregated response map, so as to integrate multi-band discrimination information and highlight the response characteristics of high-discrimination areas; The cross-band attention weight matrix output by S4.3 and the single-channel response maps of each band generated by S4.1 are combined using a pixel-wise weighted summation algorithm (parameter: the band weight at each pixel position is determined by the softmax normalization result) to achieve linear weighted fusion of the discrimination response values ​​of each band according to their pixel-level importance. Furthermore, through matrix multiplication (parameter: the input matrix is ​​the attention weight matrix), Response matrix This implements parallel weighted computation across the entire pixel range and obtains the fused two-dimensional aggregated response matrix. Ensure spatial resolution and input response Figure 1 To; Furthermore, by applying a combination of element-wise addition and multiplication, the response values ​​of different bands at the same pixel location are multiplied by their corresponding attention weights, and a summation process is performed along the band dimension. The calculation formula is as follows: in This is the aggregate response value. For attention weights, These are the response values ​​for each band. For band indexing; Furthermore, by using a neighborhood average smoothing algorithm (parameters: kernel size 3×3, boundary processing mode is zero padding), the high-frequency noise peaks after weighted summation are suppressed, thereby improving the continuity and stability of the aggregated response map in the scratch edge region. Through the above weighted fusion operation, the attention weights of S4.3 and the single-channel response maps of each band of S4.1 are transformed into an aggregated response matrix covering the entire image, thereby achieving effective integration of multispectral discrimination information and highlighting the response features of high-discrimination regions. For example, in a bag surface inspection scenario, cross-band attention weight fusion is applied to the single-channel response maps of each band with H=1280 and W=960. Let the weight matrix at a certain pixel location (x=512, y=384) have seven band weights of [0.05, 0.12, 0.08, 0.18, 0.26, 0.20, 0.11], corresponding to single-channel response values ​​of [15, 25, 10, 40, 60, 55, 30]. Based on the weighted summation formula, the aggregated response value of this pixel is calculated as follows: The calculated result is 41.61, and after 3×3 neighborhood average smoothing, the smoothed response value is 39.87. Applying this algorithm to the entire image can significantly improve the feature contrast between the effective scratch region and the background region in the aggregated response map, providing a more stable input basis for the subsequent attribution mask normalization processing of S4.5. S4.5: Perform min-max normalization on the aggregated response map, map it to the range of [0,1], and generate a gradient attribution mask to characterize the band response intensity of each pixel position that is most discriminative for scratch discrimination and to meet the input requirements of subsequent gated fusion.

[0014] Step S5: The gradient attribution mask output from S4 is fused with multi-scale spatial features using channel-level gating to generate a fused feature tensor, ensuring that low-attribution regions retain spatial context information. Specifically, this includes: S5.1: Based on the normalized image sequence output by S2, multi-scale feature extraction processing is performed through a lightweight ConvNeXt-Tiny network structure to generate multi-scale spatial feature tensors; Using the normalized image sequence output by S2 as the input data source, a lightweight ConvNeXt-Tiny network structure is used to perform multi-scale spatial feature extraction processing to obtain an efficient spatial representation for scratch detection. A feature pyramid construction method with normalized image sequence input (parameters: ConvNeXt-Tiny stage combination, resolution reduction ratio of 1 / 4, 1 / 8, 1 / 16) is adopted to realize the stepwise convolutional feature calculation from the original resolution to the low resolution, and retain the multi-scale feature layers. Furthermore, a feature enhancement unit combining depthwise separable convolution and LayerNorm normalization (parameters: kernel size 7×7, stride 2, channel expansion ratio 4) is used to simultaneously represent scratch detail texture and background structure at different spatial scales, and obtain a multi-scale feature map set. Furthermore, through a cross-scale pixel-wise residual connection mechanism (parameters: residual connections maintain channel consistency, and skip connections use nearest neighbor interpolation to scale-align low-resolution features), the fusion and transfer of detailed information is achieved, generating feature layer outputs that maintain texture sensitivity at all scales; Furthermore, through the global average pooling and channel-wise adaptive weight allocation module (parameters: the global pooling window covers the entire feature map, and the weight calculation adopts Softmax normalization), the importance weighting of features at different scales is realized, and an integrated multi-scale spatial feature tensor is generated for subsequent channel-level gated fusion processing. By using the ConvNeXt-Tiny network for multi-scale feature extraction and weighted fusion, the normalized image sequence is transformed into a feature tensor with spatial texture and structural information, thereby achieving multi-resolution representation of the difference between scratches and background. For example, in the input scenario of a normalized image sequence of PU material samples for bags, the ConvNeXt-Tiny network's Stage 1 convolutional kernel size is configured as 7×7 with a stride of 2, and the number of output channels is 64; the Stage 2 convolutional kernel size is configured as 3×3 with a stride of 2, and the number of output channels is 128; the Stage 3 convolutional kernel size is configured as 3×3 with a stride of 2, and the number of output channels is 256; the Stage 4 convolutional kernel size is configured as 3×3 with a stride of 2, and the number of output channels is 512. In the feature enhancement unit, the depthwise convolutional kernel size of the depthwise separable convolution is set to 7×7, and the number of output channels of the pointwise convolution is set to 4 times the original number of channels to improve the nonlinear representation capability. The cross-scale alignment of residual connections uses nearest neighbor interpolation, and the interpolation factor is 2 when aligning from Stage 4 features to Stage 3 scale. Global average pooling generates single-channel descriptors on feature maps at each scale. Softmax normalization yields the weight values ​​for each scale, for example, a weight distribution of Stage 1: 0.25, Stage 2: 0.30, Stage 3: 0.20, and Stage 4: 0.25. The weighted fused multi-scale spatial feature tensor significantly improves the detail of scratch edge texture on independent validation sets, demonstrating a clear separation between feature texture and noise, effectively supporting the subsequent gradient attribution mask gating fusion process. S5.2: Perform channel dimension mean calculation on the multi-scale spatial feature tensor output by S5.1 to generate a channel dimension mean tensor; S5.3: Perform channel-level pixel-wise multiplication on the gradient attribution mask output by S4 and the multi-scale spatial feature tensor output by S5.1 to generate the first weighted feature tensor; S5.4: Perform channel-level pixel-wise multiplication on the result of subtracting the gradient attribution mask from 1 and the channel dimension mean tensor output by S5.2 to generate a second weighted feature tensor; When the gradient attribution mask A output by S4 and the channel dimension mean tensor output by S5.2 are received as input conditions, a feature suppression operator is constructed based on the pixel-by-pixel reverse gating idea to achieve the spatial context preservation function for low attribution regions. A pixel-wise univariate linear transformation method (parameters: constant 1 and gradient attribution mask A) is used to perform inverse weight calculation on the gradient attribution mask, generating a pixel-level suppression coefficient matrix R, where each element r(x,y) satisfies the following calculation formula: in, This is the gradient attribution mask matrix, with a value range of [0,1]. It is the inverse weight matrix, and its range is also [0,1]. Furthermore, a pixel-by-pixel channel-level broadcast multiplication method is used (parameter: R, channel dimension mean tensor). The inverse weight matrix R is broadcast to channels along the channel dimension. Using the same tensor size and performing element-wise multiplication, we obtain the second weighted feature tensor. The formula is as follows: in This represents an element-wise multiplication operation; Furthermore, the tensor normalization method relies on The pixel value range is linearly mapped to the preset weight normalization range [0,1] to ensure that the weighted feature and the first weighted feature maintain the same numerical domain in the subsequent gated fusion. By employing a channel-by-channel energy preservation strategy, the normalized calculations are performed. The sum of the squared energies of each channel, and with If the difference exceeds the tolerance threshold, the sum of the squared energy of the channels will be compared. Then scale proportionally. To match energy levels, thereby maintaining the overall characteristic energy stability after fusion; Through this algorithm chain, the inverse weight matrix and the spatial mean feature tensor are transformed into a second weighted feature tensor that suppresses the spatial context information of the high attribution region and retains the low attribution region, thereby achieving the expected technical effect of context compensation in the feature fusion stage. For example, in a detection scenario targeting the surface of a black PU bag, the pixel values ​​of the gradient attribution mask A are concentrated in the scratch area (0.9~1.0) and the background area (0.05~0.1); the channel dimension mean tensor... The dimensions are 1280×960×64, and the background area has significant texture features. Using the formula... The calculated inverse weight matrix R ranges from 0 to 0.1 in the scratch region and from 0.9 to 0.95 in the background region. R is then broadcast to 64 channels and synchronized with... Element-by-element multiplication yields The original mean feature values ​​were retained at over 90% in the background region, while the feature values ​​in the scratch region were significantly suppressed to less than 10% of their original value. After normalization, this ensured... The numerical domain is in the range [0,1], and the channel squared energy deviation is controlled within 0.005, meeting the energy stability requirements of subsequent fusion. Finally, in the S5.5 fusion stage, It supplements the low attribution region with stable spatial context information, enabling the scratch recognition model to have clear edges and smooth background on the surface of PU bags, which significantly improves the edge integrity and background suppression effect of the recognition results. S5.5: The first weighted feature tensor output from S5.3 and the second weighted feature tensor output from S5.4 are summed element-wise to generate a fused feature tensor. The fused feature tensor enhances the features of high-discriminative regions through the gradient attribution mask and retains the spatial context information of low-attribution regions.

[0015] Step S6: During the model training phase, based on the manually annotated ground truth mask for scratches, an attribution consistency constraint loss is introduced to force the average pixel value of the gradient attribution mask in the scratch region to be no less than 0.85 and in the background region to be no more than 0.15. Specifically, this includes: S6.1: Parse the manually annotated ground truth mask and gradient attribution mask, and construct an attribution consistency constraint loss function based on the pixel distribution characteristics of the scratch region and the background region to generate a loss function structure for quantifying the degree of deviation between the gradient attribution mask and the real scratch region. Using the manually annotated ground truth mask M for scratches and the gradient attribution mask A output by S4 as input conditions, a mask parsing algorithm (parameter: pixel classification threshold = 0.5) is adopted to determine the regional attributes of each pixel position in the image plane and generate scratch region index set and background region index set. Furthermore, by using a regional pixel distribution statistical method (parameter: region type ∈ {scratches, background}), the spatial connectivity of the scratch region index set and the background region index set is detected, and a separate and non-overlapping region mask matrix is ​​obtained to ensure the accuracy of region definition in the loss function calculation. Furthermore, a region weight mapping algorithm is adopted (parameter: the initial value of the region weight is set to 1.0) to map the mask matrix to a weight matrix of the same size as the gradient attribution mask and generate a region weighted gradient map, in which each pixel value is obtained by multiplying the attribution mask value by the corresponding region weight; Furthermore, the difference in attribution value distribution between the scratch region and the background region is calculated using a difference metric formula, thereby constructing the core term of the loss function. This formula is defined as follows: in, The output value of the loss function. This is the pixel index set for the scratched area. For the background region pixel index set, and These represent the number of pixels in the scratched area and the background area, respectively. The target mean attribution value for the scratched area is 0.85. The target mean for the background region attribution value is 0.15. ( ) represents the value of the attribution mask at pixel i. The value of the attribution mask at pixel j; Furthermore, through this loss function framework, the attribution bias of the scratch region and the attribution bias of the background region are incorporated into the same optimization objective, generating a loss function structure for quantifying the degree of deviation between the attribution mask and the real scratch region, thereby realizing a numerical constraint on the reliability of model feature attribution. By using the aforementioned region analysis and loss calculation algorithms, the input data from the previous step is transformed into a differentiable loss function structure, thereby achieving precise constraints on the spatial distribution of the attribution mask during the model training phase and improving the specificity of scratch detection. For example, in a bag detection scenario, the input original scratch truth mask M has a size of 1280×960, and the gradient attribution mask A also has a size of 1280×960. The mask parsing algorithm classifies M pixels above a threshold of 0.5 as scratch regions and pixels below that as background regions. The resulting index set S for scratch regions contains 35780 pixels, and the background region index set B contains 1202340 pixels. After region connectivity detection removes isolated single-point noise, scratch region mask matrices and background region mask matrices are generated. The region weight mapping algorithm transforms the two types of mask matrices into a region weighted gradient map of the same size as A. The gradient mask value A(i) is multiplied by the weight to form the input gradient map used for loss calculation. Substituting into the formula, let τ=0.85, β=0.15, n=35780, m=1202340. The mean value of L obtained by summing the squared differences shows a large positive value, indicating a deviation between the attribution mask and the true scratch distribution. This loss value, as a differentiable signal, is backpropagated during training to optimize the parameters of the spectral gradient response module. S6.2: Based on the constructed attribution consistency constraint loss function, the pixel value averaging operation is performed on the gradient attribution mask in the scratch region identified by the scratch truth mask, and the pixel mean of the scratch region is obtained as the key parameter for the consistency evaluation between the gradient attribution mask and the real scratch region. For the pixel values ​​of the corresponding regions of the scratch truth mask and gradient attribution mask in the input of the attribution consistency constraint loss function constructed in S6.1, the mean calculation method of region mask weighting (parameter: mask weight = 1, non-mask weight = 0) is adopted to achieve effective filtering of attribution mask pixel values ​​in the scratch region. Furthermore, the scratch truth mask and the gradient attribution mask are multiplied element-wise at the pixel level by a logical AND operation to generate a pixel value matrix of the scratch region, and obtain an attribution mask pixel set that completely corresponds to the real scratch region. Furthermore, a weighted arithmetic mean formula is used to perform a mean operation on the pixel value matrix of the scratch region, where the denominator is the number of effective pixels in the scratch region and the numerator is the sum of the attribution mask pixel values ​​of all scratch regions, obtaining a single parameter characterizing the overall response intensity of the scratch region. The formula is as follows: in, Let be the attribution value of the i-th pixel within the scratch area. This represents the total number of valid pixels within the scratched area. Furthermore, by comparing this mean parameter with a preset scratch area response threshold, an intermediate quantity is generated to determine the consistency between the current attribution mask and the true value mask in the scratch area, providing a key input for constrained loss calculation; By using this pixel value averaging calculation method, the attribution pixel set of the scratch area extracted in the previous step is transformed into a measurable mean index, thereby achieving a basic quantitative effect for evaluating the consistency between the attribution mask and the real scratch area. For example, when inspecting PU material bags, the scratch ground truth mask marks 1850 pixels as scratch areas in a 1280×960 resolution image, and the pixel values ​​at the corresponding positions of the gradient attribution mask range from 0.81 to 0.94. In the scratch area pixel value matrix obtained by logical AND operation, the numerator is the sum of the attribution values ​​of all pixels. The denominator is the total number of valid pixels. Substituting into the formula, the mean value is obtained. ≈ The mean value is higher than the preset threshold of 0.85, indicating that the response intensity of the attribution mask in the scratch region meets the training requirements, realizing a high sensitivity measurement of the spectral gradient response module in the scratch region, and providing an effective reference benchmark for the subsequent calculation of the mean value of the background region in S6.3; S6.3: Perform pixel value averaging on the gradient attribution mask within the background area marked by the scratch truth mask to obtain the average pixel value of the background area as a benchmark metric for separating the gradient attribution mask from the background noise. S6.4: Calculate the attribution consistency constraint loss value based on the calculated pixel mean of the scratch area and the pixel mean of the background area. This loss value forces the pixel mean of the scratch area to be no less than 0.85 and the pixel mean of the background area to be no more than 0.15, so as to generate the differentiable consistency constraint signal required for model training. S6.5: The attribution consistency constraint loss value is backpropagated to the spectral gradient response module through the gradient inversion layer to optimize the sensitivity of the spectral gradient response module to the scratch region and suppress background noise interference, thereby obtaining updated spectral gradient response module parameters to improve the specificity of scratch recognition.

[0016] Step S7: While outputting the scratch segmentation results on the bag surface during the inference phase, a high-resolution attribution heatmap mapped to the physical band dimension is generated to indicate the gradient response characteristics of each band to the scratch edge. Specifically, this includes: S7.1: Perform bilinear upsampling on the gradient response tensor sequences of each band output by the updated spectral gradient response module to improve the spatial resolution from the feature layer level to the original image acquisition resolution of 1280×960 pixels, generating high-resolution gradient response tensor sequences of each band. S7.2: Based on the high-resolution gradient response tensor sequence of each band, perform a maximum value comparison operation of cross-band response intensity for each pixel position to determine the dominant band index that contributes the most to scratch discrimination and generate a dominant band index map. S7.3: The dominant band index map is mapped by using a preset seven-band center wavelength lookup table to convert the band index into the corresponding physical band center wavelength value and generate a physical band dimension heat map. S7.4: Apply HSV color space encoding and local contrast enhancement processing to the physical band dimension heatmap to improve the visual recognizability of the band response characteristics of the scratch edge area and generate a high-resolution attribution heatmap. Using the physical band dimension heatmap output by S7.3 as input data, the HSV color space encoding method (parameters: H channel is the physical band center wavelength mapping value, S channel is the attribution intensity normalized value, and V channel is the response amplitude) is adopted to realize the transformation of multi-band attribution information into a visualization space. Furthermore, through a channel remapping algorithm (parameters: H channel mapping range of 0°-300° corresponding to wavelength 420–850nm, S channel mapping range of 0–1 corresponding to attention attribution weight, V channel mapping range of 0–1 corresponding to response amplitude), the attribution characteristics of each band are accurately located in the color space, and preliminary encoded image data is obtained; Furthermore, by using a local contrast enhancement algorithm (parameters: region window size is 5×5 pixels, contrast gain coefficient is 1.5), the color saturation and brightness of the scratch edge region are improved, and an HSV encoding matrix with enhanced visual recognition is generated. Furthermore, a color space conversion process is performed to convert the enhanced HSV encoding matrix into an RGB color space matrix to meet the hardware adaptation requirements of the subsequent display interface and generate three-channel high-resolution thermal image data. By using pixel-by-pixel weighted fusion processing, the response amplitude of the RGB color space matrix is ​​superimposed with the original physical band dimension heatmap to form a high-resolution attribution heatmap that displays both color and physical characteristics, thereby significantly improving the visual recognizability of the band response characteristics in the scratch edge region. For example, in the scenario of bag surface inspection, the input physical band dimension heatmap has a resolution of 1280×960 pixels. The H channel value range corresponding to the band center wavelength lookup table is 0°-300°, where 420nm is mapped to 0° and 850nm is mapped to 300°. The S channel value comes from the attribution weight matrix and ranges from 0 to 1, while the V channel value comes from the band response amplitude range of 0 to 1. A local contrast enhancement algorithm with a 5×5 pixel window is used, setting the local brightness enhancement coefficient of the scratch area to 1.5 and the color saturation enhancement coefficient to 1.2 to generate an HSV encoding matrix. After performing HSV to RGB conversion, the resulting RGB matrix shows more obvious color changes in the scratch edge area, with red corresponding to a significant response in the 650nm band and blue corresponding to a weaker response in the 470nm band. The final output high-resolution attribution heatmap achieves significantly improved edge visualization under manual observation conditions, providing a high-precision visual basis for S8 band contribution analysis. S7.5: The generated high-resolution attribution heatmap and scratch segmentation results are output to the user interface simultaneously to achieve real-time interpretable visualization of the model decision-making process.

[0017] Step S8: Based on the attribution heatmap output in S7, analyze the band contribution, dynamically shut down redundant band light sources, and lock the optimal three-band combination to achieve real-time optimization of the multispectral acquisition strategy. Specifically, this includes: S8.1: Obtain the high-resolution attribution heatmap of S7 output mapped to the physical band dimension. This heatmap characterizes the gradient response characteristics of each band to the scratch edge. Calculate the pixel-level band contribution index based on the attribution heatmap to quantify the distinguishing power of each band in scratch discrimination. S8.2: Based on the band contribution index generated in S8.1, a preset threshold judgment method is used to identify redundant bands with a contribution of less than 0.15, so as to eliminate light source channels that do not contribute significantly to scratch identification. Using the band contribution index calculated by S8.1 as input data, a contribution vector is formed by selecting the band index and the corresponding contribution value, and the data structure of the vector is defined to support threshold determination calculation. A preset threshold judgment method (parameter: contribution threshold T=0.15) is adopted to realize the element-by-element comparison of the contribution values ​​of each band and generate a binary judgment result set, where a value of 1 indicates that the contribution of the band is higher than the threshold and a value of 0 indicates that it is lower than the threshold. Furthermore, the band index is filtered using a logical filtering algorithm (parameter: binary decision set), and a list of low-contribution band indexes is obtained. This list is used to identify redundant band light source channels to be removed. Furthermore, by using a band redundancy marker mapping table, the low contribution band index list is mapped to the actual hardware module number of the light source system, thereby realizing the association between the index and the physical light source port; The set difference operation (parameters: the set of all band indices and the set of redundant band indices) is used to generate the set of remaining valid bands and provide input band set data for subsequent three-band combination optimization. By using a preset threshold determination method and set operations, the contribution results of the previous step are transformed into a list of redundant bands and a set of effective bands, thereby achieving preliminary optimization and screening of the light source channels and laying a data foundation for real-time optimization of the multispectral acquisition strategy. For example, in a bag inspection test case, the band contribution vector output by S8.1 is [0.12, 0.18, 0.35, 0.10, 0.40, 0.25, 0.05], where each element corresponds to a center wavelength of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm, and 850nm, respectively. Using a preset threshold judgment method, the resulting binary set is [0,1,1,0,1,1,0], corresponding to the removal of band indices {0,3,6}, i.e., the removal of the 420nm, 590nm, and 850nm light source modules. The set difference operation yields the remaining effective band set {470nm, 530nm, 650nm, 730nm}, which enters the combinatorial optimization stage of S8.3. In the test, the system acquisition time was significantly shortened after removing redundant bands, and the scratch segmentation accuracy of the recognition model was improved under the same training conditions, which verified the effectiveness of the threshold determination method in contribution screening in this step. S8.3: Based on the list of redundant bands identified in S8.2 and the contribution index of the remaining bands, a three-band combination optimization algorithm is executed to determine the optimal band combination in order to maximize the difference between the mean of the attribution map of the scratch area and the mean of the attribution map of the background area. Based on the redundant band list and the contribution index of the remaining bands output by S8.2, a combined optimization algorithm (parameter: contribution array) is adopted. Target difference To achieve the selection of the optimal band combination; Furthermore, an exhaustive method is used to generate a set of combinations of any three bands from the remaining bands (parameter: the number of combinations is determined by the number of remaining bands and the combination formula), and within each combination, the average pixel value of the scratch area is calculated based on the attribution map data. Average pixel value of the background area ; Furthermore, a difference calculation algorithm is adopted (formula: difference). Each three-band combination is quantitatively evaluated, where the calculation of the mean values ​​of the scratch area and the background area depends on the pixel-level weighted aggregation results of the cross-band attribution map; Furthermore, by maximizing the objective function of difference, the combination with the largest difference value is selected, denoted as... While recording the band index of the combined members, the difference value and attribution plot statistical parameters of the combined are saved to form the optimal combined parameter set; By using a combinatorial optimization algorithm, the redundancy removal results from the previous step are transformed into hardware light source configuration data, thereby achieving a three-band combination locking effect that maximizes the difference in the multispectral acquisition strategy. For example, in a bag inspection task, the redundant band list is {530nm, 730nm}, and the remaining bands are {420nm, 470nm, 590nm, 650nm, 850nm}, with the following contribution index array: ={0.42,0.37,0.46,0.52,0.49}. Generated using an exhaustive search method. All three-band combinations, where n is the number of remaining bands, and k=3 indicates the selection of 3 bands: for example, (420, 470, 590), (420, 470, 650), etc., the total number of combinations is . ,in =5, =3. For the combination (420, 650, 850), the mean pixel value of the scratch area is obtained in the attribution map statistics. =0.91, average pixel value of the background area =0.05, then the degree of difference is =0.86, significantly higher than the difference of other combinations. Therefore, the optimal combination is determined. =(420nm,650nm,850nm), after the implementation of this combination, a high signal-to-noise ratio scratch attribution map was obtained in actual detection, the scratch contour and background distinction were significantly improved, and the number of hardware light sources was reduced to three, which improved the system acquisition efficiency and energy efficiency ratio. S8.4: Generate a dynamic control command sequence for the light source system. This command sequence includes redundant band light source shutdown operations and optimal three-band light source activation commands to achieve hardware-level reconstruction of the multispectral acquisition strategy. S8.5: Executes the light source control command sequence generated by S8.4, switches the narrowband LED light source configuration in real time and locks the optimal three-band combination, and completes the closed-loop optimization of the multispectral acquisition strategy.

[0018] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will all fall within the scope of protection of the present invention.

[0019] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and rules of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for automatic identification of minor scratches on the surface of bags and luggage based on adaptive lighting, characterized in that, Includes the following steps: S1: The drive light source control system sequentially illuminates discrete narrowband LEDs according to a preset timing sequence, and synchronously acquires the original image sequence of the same area on the surface of the bag; S2: Based on the Lambertian reflectance coefficient lookup table, perform pixel value normalization processing on the original image sequence to generate a normalized image sequence; S3: Based on the normalized image sequence, construct a spectral gradient response module, and use the spectral gradient response module to extract the local gradient response tensor of each band; S4: Use the spectral gradient response module to perform cross-band attention weighted aggregation on the local gradient response tensor to generate a gradient attribution mask; S5: The gradient attribution mask is fused with multi-scale spatial features at the channel level to generate a fused feature tensor. The fused feature tensor enhances the features of high-discrimination regions through the gradient attribution mask and retains the spatial context information of low-attribution regions. S6: Based on the manually annotated scratch truth mask, the attribution consistency constraint loss function is introduced to calculate the attribution consistency constraint loss value. The attribution consistency constraint loss value is then backpropagated to the spectral gradient response module to obtain the updated spectral gradient response module. S7: Based on the updated spectral gradient response module, output the scratch segmentation results on the surface of the bag and generate an attribution heatmap at the same time. S8: Analyze the band contribution based on the attribution heatmap, dynamically shut down redundant band light sources and lock the optimal three-band combination to achieve real-time optimization of the multispectral acquisition strategy.

2. The method for automatic identification of minor scratches on the surface of bags under adaptive illumination according to claim 1, characterized in that, The light source control system is built on industrial standard LED driving circuits and microcontroller units, and integrates seven discrete narrowband LED light source modules with center wavelengths of 420nm, 470nm, 530nm, 590nm, 650nm, 730nm and 850nm respectively.

3. The method for automatic identification of minute scratches on the surface of bags under adaptive illumination according to claim 1, characterized in that, The Lambertian reflectance lookup table is constructed based on standard samples and laboratory measurement data of three types of substrates: PU, PVC, and nylon for bags and luggage.

4. The method for automatic identification of minor scratches on the surface of bags under adaptive illumination according to claim 1, characterized in that, Step S3 specifically includes: Based on the normalized image sequence output in step S2, and according to the band response characteristics of the bag material reflectance lookup table, a network architecture for the spectral gradient response module is constructed. The normalized image sequence is input into the spectral gradient response module, and cross-band feature mapping processing based on one-dimensional convolution kernel parameters is performed to obtain the original feature tensor set. Based on the original feature tensor set, the gradient magnitude calculation process is performed using the central difference algorithm to generate a gradient magnitude response map. The gradient magnitude response map is subjected to band response normalization processing to output a standardized gradient response tensor. Based on the standardized gradient response tensor, channel dimension feature aggregation processing is performed to generate a three-dimensional gradient feature cube.

5. The method for automatic identification of fine scratches on the surface of bags under adaptive illumination according to claim 4, characterized in that, The network architecture for constructing the spectral gradient response module is as follows: Seven sets of one-dimensional convolutional kernel parameters with shared weights but adjustable biases are initialized. Each set of convolutional kernels is configured with a size of 1×1 and the number of output channels is fixed at 16, so as to establish an explicit mapping relationship between the wavelength center point and the pixel gradient, and generate a differentiable feature extraction unit with band-specific adjustment capability.

6. The method for automatic identification of minor scratches on the surface of bags under adaptive illumination according to claim 1, characterized in that, Step S4 specifically includes: Perform channel dimension compression on the local gradient response tensor output in step S3, and calculate the single-channel response map for each band based on the L2 norm of the feature map of each band. Based on the single-channel response maps of each band, cross-band attention scores are calculated, and an attention score matrix is ​​generated by linearly combining the response values ​​of each band and applying the Sigmoid activation function. Perform softmax normalization on the attention score matrix to generate cross-band attention weights; The cross-band attention weights are used to perform weighted summation on the single-channel response maps of each band to generate an aggregated response map. The aggregated response map is subjected to max-min normalization to map it to a uniform range, generating a gradient attribution mask.

7. The method for automatic identification of minor scratches on the surface of bags under adaptive illumination according to claim 6, characterized in that, The gradient attribution mask is used to characterize the band response intensity at each pixel location that is most discriminative in terms of scratch detection.

8. The method for automatic identification of minor scratches on the surface of bags under adaptive illumination according to claim 1, characterized in that, Step S5 specifically includes: Based on the normalized image sequence output in step S2, multi-scale feature extraction processing is performed to generate a multi-scale spatial feature tensor. Perform channel dimension mean calculation on the multi-scale spatial feature tensor to generate a channel dimension mean tensor; The gradient attribution mask output in step S4 is multiplied by the multi-scale spatial feature tensor at the channel level pixel by pixel to generate the first weighted feature tensor. Based on the result of subtracting the gradient attribution mask from 1, a channel-level pixel-wise multiplication process is performed on the channel dimension mean tensor to generate a second weighted feature tensor. The first weighted feature tensor and the second weighted feature tensor are summed element by element to generate a fused feature tensor.

9. The method for automatic identification of fine scratches on the surface of bags under adaptive illumination according to claim 8, characterized in that, The multi-scale feature extraction process is performed using a ConvNeXt-Tiny network structure and a feature pyramid construction method. The resolution decreases by 1 / 4, 1 / 8, and 1 / 16, preserving multi-scale feature layers. The importance of features at different scales is weighted by cross-scale pixel-wise residual connections and global average pooling, and integrated into a multi-scale spatial feature tensor.

10. The method for automatic identification of fine scratches on the surface of bags under adaptive illumination according to claim 1, characterized in that, The attribution consistency loss function, which integrates the forced gradient attribution mask, ensures that the average pixel value in the scratch region is no less than 0.85 and the average pixel value in the background region is no more than 0.

15. The loss signal is then passed back to the gradient response module for updating and optimization.