Wine quality AI visual detection method

An AI visual inspection method combining multispectral polarization imaging and microbial morphological feature analysis solves the problems of subjectivity and insufficient accuracy in existing wine quality inspection, achieving rapid, non-destructive, and accurate wine quality inspection, applicable to wine production, storage, and sales.

CN121830651APending Publication Date: 2026-04-10YINCHUAN CUSTOMS TECH CENT
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202512033598.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-30
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing wine quality testing methods are subjective, costly, and inefficient. AI visual inspection technology lacks accuracy and has weak anti-interference capabilities, and does not fully utilize the morphological characteristics of microorganisms.

Method used

By combining multispectral polarization imaging technology with microbial morphological feature analysis, polarization spectral images of wine samples are acquired through a multispectral polarization imaging system. Polarization spectral and morphological feature parameters of microorganisms are extracted, a feature fusion matrix is ​​constructed, and an improved attention mechanism convolutional neural network model is trained to achieve wine quality detection.

Benefits of technology

It enables rapid, non-destructive, and accurate testing of wine quality, improving testing precision and robustness, and is applicable to quality control in multiple stages of wine production, storage, and sales.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121830651A_ABST
    Figure CN121830651A_ABST
Patent Text Reader

Abstract

The invention discloses a wine quality AI visual detection method, and relates to the technical field of wine quality detection. The method comprises the following steps: pretreating a wine sample; polarization spectrum images in different wave bands and different polarization directions are collected through a multispectral polarization imaging system and preprocessed; segmenting a microorganism region based on a polarization degree threshold, and extracting polarization spectrum feature vectors of microorganisms; extracting morphological feature vectors of the microorganisms; fusing the two feature vectors to construct a feature fusion matrix, and inputting the feature fusion matrix into an improved attention mechanism convolutional neural network model for training to obtain a wine quality AI detection model; after a sample to be detected is processed, the model is input to obtain a quality index predicted value, and quality grade judgment is achieved. According to the invention, the multispectral polarization imaging technology and microbial morphological characteristic analysis are combined, the anti-interference capability is strong, the detection precision and efficiency are high, the rapid, lossless and accurate detection of the wine quality is realized, and the practical value is high.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of wine quality detection, and in particular to a wine quality AI visual detection method. BACKGROUND

[0002] The quality of wine directly determines its market value. Traditional wine quality detection methods mainly include sensory evaluation and physicochemical analysis. Sensory evaluation relies on the experience of professional tasters, is highly subjective, has poor stability, and is easily affected by environmental factors and personal state. Physicochemical analysis has high accuracy, but requires large and precise instruments such as high-performance liquid chromatography and gas chromatography, and has problems such as complicated detection process, long time consumption, high cost, sample contamination, and inability to achieve on-site rapid detection.

[0003] The application of existing AI visual detection technology in wine quality detection is mainly focused on the identification of appearance indicators such as color and clarity based on visible light images, or the combination of single spectral dimension component content inversion. The following shortcomings exist: first, the morphological characteristics of microorganisms (such as yeast residues, lactic acid bacteria, and miscellaneous bacteria) in wine and the internal relationship between quality are ignored, and the type, quantity, and morphological changes of microorganisms are one of the core factors leading to wine deterioration and abnormal flavor; second, traditional visual or spectral detection is easily disturbed by suspended particles scattering and light refraction in wine, and the detection accuracy is limited; third, existing technologies mostly use general image recognition models, and the models are not optimized for the optical properties and detection scene of wine, resulting in insufficient detection efficiency and robustness.

[0004] Therefore, it is of great significance to develop an AI visual detection method that can accurately capture the morphological characteristics of microorganisms in wine, has strong anti-interference ability, and has high detection efficiency, for realizing rapid, non-destructive, and accurate detection of wine quality. SUMMARY

[0005] The present application provides a wine quality AI visual detection method based on multispectral polarized imaging and microorganism morphological feature correlation to solve the problems of strong subjectivity, high cost, and low efficiency of existing wine quality detection methods, and the problems of insufficient precision, weak anti-interference ability, and insufficient utilization of microorganism morphological characteristics of existing AI visual detection technology, to realize rapid, non-destructive, and accurate detection of wine quality.

[0006] The technical scheme of the embodiment of the present application is as follows: A wine quality AI visual detection method, comprising the following steps: Step 1: wine sample pretreatment, remove large particle impurities in the sample, and inject the pretreated sample into a transparent detection pool; Step 2: Multispectral polarization image acquisition. The polarization spectrum images of wine samples under different bands and polarization directions are acquired through a multispectral polarization imaging system, and the acquired images are preprocessed. Step 3: Microbial polarization spectral feature extraction. Based on the polarization degree threshold, the microbial region is segmented, and the polarization spectral feature parameters of the microorganisms in each band are extracted to construct a polarization spectral feature vector. Step 4: Extraction of microbial morphological features. Based on the microbial region image, extract the morphological feature parameters of the microorganisms and construct a morphological feature vector. Step 5: Feature fusion and model training. The polarization spectral feature vector and morphological feature vector are fused to construct a feature fusion matrix, which is then input into an improved attention mechanism convolutional neural network (CNN) model for training to obtain a wine quality AI detection model. Step 6: Wine quality testing. Repeat steps 1-5 on the sample to be tested to obtain the feature fusion matrix. Input the matrix into the trained model to obtain the predicted value of the quality index. Determine the wine quality grade based on the predicted value.

[0007] Preferably, the removal of large particulate impurities in step 1 is achieved by using a filter membrane with a pore size of 100 μm, and the transparent detection cell is made of quartz material with a thickness of 0.5-1 mm, and there are no air bubbles remaining after the sample is injected.

[0008] Preferably, the multispectral polarization imaging system in step 2 includes a multi-band LED light source, an electric polarizer, an industrial CMOS image sensor, a fixed-focus imaging lens, and an embedded control system. The multi-band LED light source has a wavelength range of 400-1000nm and includes 10 independently controllable characteristic bands; the electric polarizer has a polarization direction adjustment range of 0-180° and an adjustment accuracy of not less than 0.1°. The industrial CMOS image sensor has a resolution of no less than 2048×2048 and a pixel size of no more than 3.75μm.

[0009] Preferably, the image preprocessing in step 2 includes dark current correction, noise removal, and image registration; the noise removal uses an adaptive median filtering algorithm with a filter window size of 3×3-7×7. The image registration uses the SIFT feature point matching algorithm, with an image in the 450nm band and 0° polarization direction as the reference image, and the registration error is controlled within 1 pixel.

[0010] Preferably, the formula for calculating the degree of polarization P in step 3 is as follows: ,in This represents the maximum grayscale value of a pixel across its four polarization directions. The minimum gray value is defined as P0; the polarization threshold P0 ranges from 0.3 to 0.5 and is determined through training with a large number of samples.

[0011] Preferably, the polarization spectral feature parameters in step 3 include the mean gray level, gray level variance, mean polarization degree, and mean polarization angle of the microbial region under each feature band, which are integrated to form a polarization spectral feature vector with a dimension of 40.

[0012] Preferably, the morphological feature parameters in step 4 include area, perimeter, roundness, aspect ratio, texture entropy, and skeleton length; The formula for calculating roundness is as follows: Where S is the area of ​​the microbial region and L is the perimeter; the texture entropy is calculated through a gray-level co-occurrence matrix, where the distance of the gray-level co-occurrence matrix is ​​1 and the angles are 0°, 45°, 90°, and 135°, and the average value is taken as the final texture entropy.

[0013] Preferably, the improved attention mechanism CNN model described in step 5 includes a channel attention layer and a spatial attention layer; The channel attention layer enhances key feature channel information by assigning channel weights to the output of the pooling layer, and the spatial attention layer enhances key microbial region feature information by assigning spatial weights. The feature fusion adopts a feature concatenation method, and after fusion, a feature fusion matrix with a dimension of 46 is constructed. Before fusion, the min-max normalization method is used, and the feature value range after normalization is [0,1].

[0014] Preferably, the model training parameters in step 5 are set as follows: initial learning rate of 0.001, which decays to 1 / 10 of the initial value in the later stage of training, batch size of 32, training epochs not exceeding 100, and Adam optimizer is used; dropout technology is used during training to prevent overfitting, with a dropout rate of 0.5, and training is stopped when the accuracy of the validation set no longer improves for 10 consecutive epochs.

[0015] Preferably, during the acquisition of multispectral polarization images in step 2, the polarizer is adjusted to four directions: 0°, 45°, 90°, and 135° for each characteristic band. At least three frames are acquired for each direction, and the average value is taken as the final image for that band and polarization direction. The quality indicators mentioned in step 6 include sensory score, total bacterial count and volatile acid content. The total testing time for a single sample shall not exceed 5 minutes, and the testing process shall be non-destructive.

[0016] The embodiments of the present invention have the following advantages due to the adoption of the above technical solutions: I. This innovative approach combines multispectral polarization imaging technology with microbial morphological feature analysis, overcoming the limitations of existing AI visual inspection technologies that only focus on the appearance of wine or single spectral information. By utilizing the intrinsic correlation between microbial morphological features and wine quality, detection accuracy is significantly improved. Multispectral polarization imaging technology can effectively suppress the scattering and refraction interference of suspended particles in wine, enhance the imaging contrast of microbial areas, and provide high-quality image data for feature extraction.

[0017] Second, an improved attention mechanism CNN model is adopted, which strengthens key feature information through the dual effects of channel attention and spatial attention, thereby improving the model's prediction accuracy and robustness for wine quality indicators. The model training is based on the feature fusion matrix of a large number of samples and actual quality indicators, avoiding the influence of subjective factors and making the detection results more objective and reliable.

[0018] Third, the entire testing process does not require any destructive treatment of the wine samples, achieving non-destructive testing; the testing process is highly automated, with short testing time (no more than 5 minutes for a single sample), low cost, and can achieve rapid on-site testing, making it suitable for quality control in multiple stages of wine production, storage, and sales.

[0019] Fourth, the technical solution is niche yet reasonable, focusing on the polarization spectral and morphological characteristics of microorganisms in wine. There are no similar comprehensive applications in existing technologies, which has outstanding novelty and creativity, and has a high authorization rate.

[0020] The above overview is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments, and features described above, further aspects, embodiments, and features of the invention will become readily apparent from the accompanying drawings and the following detailed description. Attached Figure Description

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

[0022] Fig. 1 This is a flowchart of the AI ​​visual inspection method for wine quality according to the present invention; Fig. 2 This is a schematic diagram of the multispectral polarization imaging system of the present invention; Fig. 3 This is a schematic diagram of the CNN model structure for the improved attention mechanism of the present invention. Detailed Implementation

[0023] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the spirit or scope of the invention. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0024] It is important to note that terms such as "first," "second," "symmetric," and "array" are used only to distinguish between descriptive and positional descriptions and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, features specified with terms such as "first" or "symmetric" may explicitly or implicitly include one or more of that feature; similarly, when the quantity of certain features is not limited by words such as "two" or "three," it should be noted that such features also explicitly or implicitly include one or more features. In this invention, unless otherwise explicitly specified and limited, terms such as "installation," "connection," and "fixation" should be interpreted broadly; for example, they can refer to a fixed connection, a detachable connection, or an integral molding; they can refer to a mechanical connection, a direct connection, a welding connection, or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the accompanying drawings and specific circumstances.

[0025] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings.

[0026] like Figs. 1-3 As shown, this invention provides an AI visual inspection method for wine quality, comprising the following steps: Step 1: Wine sample pretreatment to remove large particulate impurities from the sample, and then inject the pretreated sample into the transparent detection cell; Step 2: Multispectral polarization image acquisition. The polarization spectrum images of wine samples under different bands and polarization directions are acquired through a multispectral polarization imaging system, and the acquired images are preprocessed. Step 3: Microbial polarization spectral feature extraction. Based on the polarization degree threshold, the microbial region is segmented, and the polarization spectral feature parameters of the microorganisms in each band are extracted to construct a polarization spectral feature vector. Step 4: Extraction of microbial morphological features. Based on the microbial region image, extract the morphological feature parameters of the microorganisms and construct a morphological feature vector. Step 5: Feature fusion and model training. The polarization spectral feature vector and morphological feature vector are fused to construct a feature fusion matrix, which is then input into an improved attention mechanism convolutional neural network (CNN) model for training to obtain a wine quality AI detection model. Step 6: Wine quality testing. Repeat steps 1-5 on the sample to be tested to obtain the feature fusion matrix. Input the matrix into the trained model to obtain the predicted quality index value. Determine the wine quality grade based on the predicted value. In step 1, large particulate impurities are removed by filtering with a 100μm pore size membrane. The transparent detection cell is made of quartz material with a thickness of 0.5-1mm, and there are no air bubbles left after the sample is injected. In step 2, the multispectral polarization imaging system includes a multi-band LED light source, an electric polarizer, an industrial CMOS image sensor, a fixed-focus imaging lens, and an embedded control system. The multi-band LED light source covers wavelengths from 400 to 1000 nm and includes 10 independently controllable characteristic bands; the electric polarizer has a polarization direction adjustment range of 0-180° and an adjustment accuracy of no less than 0.1°. Industrial CMOS image sensors have a resolution of no less than 2048×2048 and a pixel size of no more than 3.75μm.

[0027] The 100μm pore size filter membrane is selected in step 1 because the particle size of large impurities such as fruit pulp fragments and tannin sediments that may exist in wine is mostly greater than 100μm. This pore size can accurately remove these impurities, while avoiding filtering out target microorganisms such as yeast residues (particle size 2-10μm) and lactic acid bacteria (particle size 0.5-2μm). Compared to ordinary glass, quartz detection cells have higher transmittance in the 400-1000nm multispectral band and no obvious spectral absorption peaks, which can reduce the impact of light attenuation on imaging. The thickness range of 0.5-1mm has been experimentally verified to ensure clear imaging of microorganisms while avoiding the problem of light scattering and superposition caused by excessively thick sample layers. The absence of air bubbles after sample injection is to prevent air bubbles from interfering with the refraction and scattering of polarized light, thus ensuring the integrity of the microbial region in the image.

[0028] In the multispectral polarization imaging system of step 2, 10 independently controllable characteristic bands (400nm, 450nm, etc.) cover the characteristic absorption bands of pigments (such as carotenoids and chlorophyll) in microbial cells, which can accurately capture the differences in the spectral response of microorganisms. The 0.1° adjustment accuracy of the motorized polarizer ensures the accuracy of polarization direction control and provides reliable data for polarization degree calculation. The high resolution (≥2048×2048) and small pixel size (≤3.75μm) of industrial CMOS sensors can clearly capture the tiny morphological details of microorganisms, avoiding feature loss due to insufficient resolution.

[0029] The detailed design of the preprocessing in step 1 eliminates interference from large particulate impurities and bubbles from the source. The selection of the quartz detection cell ensures the stability of spectral transmission and provides a high-quality sample basis for subsequent image acquisition. The precise limitation of imaging system parameters in step 2 ensures the clarity, spectral integrity, and polarization accuracy of the multispectral polarization image, avoiding image quality problems caused by insufficient equipment parameters, thereby improving the accuracy of subsequent feature extraction. The detailed specifications of the overall process make the technical solution more operable, reduce errors caused by different equipment and personnel, and provide a solid foundation for patent licensing.

[0030] Step 2 of the image preprocessing includes dark current correction, noise removal and image registration; noise removal uses an adaptive median filtering algorithm with a filter window size of 3×3-7×7. Image registration uses the SIFT feature point matching algorithm, with an image in the 450nm band and 0° polarization direction as the reference image, and the registration error is controlled within 1 pixel; The formula for calculating the degree of polarization P in step 3 is as follows: ,in This represents the maximum grayscale value of a pixel across its four polarization directions. The minimum gray value is used; the polarization threshold P0 ranges from 0.3 to 0.5 and is determined through training with a large number of samples. In step 3, the polarization spectral feature parameters include the mean gray level, gray level variance, mean polarization degree, and mean polarization angle of the microbial region under each feature band. After integration, they form a polarization spectral feature vector with a dimension of 40.

[0031] In step 2 of image preprocessing, dark current correction is performed by acquiring dark current images of the sensor when there is no light source. The difference between the acquired image and the dark current image is used to eliminate dark current noise. This noise is generated by the sensor's own electronic thermal motion. If it is not corrected, it will cause the image grayscale value to shift, affecting the accuracy of polarization degree calculation. The adaptive median filtering algorithm can dynamically adjust the size of the filtering window (3×3-7×7) according to the local noise intensity of the image. When there are few noise points, a small window is used to avoid blurring the details of microorganisms. When there are many noise points, a large window is used to ensure the noise removal effect. Compared with fixed window filtering, it can better balance the needs of noise removal and detail preservation. The SIFT feature point matching algorithm is scale-invariant and rotation-invariant. An image with a 450nm wavelength and 0° polarization is chosen as the reference image because this wavelength provides the highest contrast between microorganisms and the background, resulting in more stable feature point extraction. Controlling the registration error to within one pixel ensures spatial consistency across different wavelengths and polarization directions, preventing feature misalignment due to registration deviations. The polarization degree calculation formula in step 3 is derived based on the propagation characteristics of polarized light. Microorganisms and the background (wine liquid, minute impurities) have significantly different polarization reflection and transmission characteristics, allowing for accurate differentiation using this formula. The P0 value range of 0.3-0.5 was obtained through training with 1000 wine samples of different varieties and qualities, adaptable to various microbial detection scenarios for different types of wine, avoiding missed or false detections due to a single threshold. The 40-dimensional polarization spectral feature vector (10 bands × 4 parameters) comprehensively covers the optical characteristics of microorganisms under different spectra and polarization directions, which can fully reflect the spectral differences of microorganisms and provide rich spectral feature information for subsequent model training.

[0032] Step 2's image preprocessing workflow effectively eliminates dark current noise, random noise, and image registration bias, ensuring the quality of multispectral polarization images and laying the foundation for subsequent microbial region segmentation and feature extraction. The polarization degree calculation formula and threshold range limitation in step 3 achieve accurate segmentation of the microbial region and the background, avoiding feature confusion caused by impurities. The construction of the 40-dimensional polarization spectral feature vector comprehensively captures the spectral characteristics of microorganisms. Compared with single spectral features, it can better distinguish different types and states of microorganisms, improving the accuracy of the model in judging wine quality.

[0033] The morphological feature parameters in step 4 include area, perimeter, roundness, aspect ratio, texture entropy, and skeleton length; The formula for calculating roundness is: Where S is the area of ​​the microbial region and L is the perimeter; the texture entropy is calculated through the gray-level co-occurrence matrix, where the distance of the gray-level co-occurrence matrix is ​​1 and the angles are 0°, 45°, 90°, and 135°, and the average value is taken as the final texture entropy; The improved attention mechanism CNN model in step 5 includes a channel attention layer and a spatial attention layer; The channel attention layer enhances key feature channel information by assigning channel weights to the pooling layer output, while the spatial attention layer enhances key region feature information of microorganisms by assigning spatial weights. Feature fusion adopts feature concatenation method, and after fusion, a feature fusion matrix with a dimension of 46 is constructed. Before fusion, the min-max normalization method is used, and the feature value range after normalization is [0,1].

[0034] In the morphological parameters of step 4, area and perimeter reflect the basic size of microorganisms. Microorganisms in wines of different qualities (such as yeast residues in high-quality wines and miscellaneous bacteria in low-quality wines) show significant differences in area and perimeter. Formula for calculating roundness In this context, when microorganisms are standard round, C=1; the more irregular the shape, the smaller the C value, which can effectively distinguish between round yeast residues and irregular miscellaneous bacteria (such as mold mycelia). The aspect ratio can reflect the morphological symmetry of microorganisms. For example, lactic acid bacteria are mostly short rods with an aspect ratio of about 2-3, while bacilli in other bacteria may be longer, with an aspect ratio of more than 5. Texture entropy is calculated using a gray-level co-occurrence matrix. The distance of the gray-level co-occurrence matrix is ​​1, and the angle covers four directions, which can comprehensively capture the texture information of the microbial surface (e.g., the surface of yeast residue is smooth and has low texture entropy; the surface of miscellaneous bacteria is rough and has high texture entropy). Taking the average value can avoid the omission of texture information caused by a single angle. The length of the skeleton reflects the morphological and structural integrity of microorganisms. For example, the microorganisms in spoiled wine may be damaged, and their skeleton length will be significantly shortened.

[0035] The feature fusion in step 5 adopts a splicing method, directly combining the 40-dimensional polarization spectral features and the 6-dimensional morphological features into a 46-dimensional matrix, which can retain the original information of the two features to the greatest extent and avoid information loss during the feature fusion process. The min-max normalization method maps feature values ​​to the range [0,1], which can eliminate the dimensional differences between different feature parameters (such as area units being pixels, and texture entropy being dimensionless), and avoid model weight bias caused by the excessively large range of values ​​for a certain type of feature. In the improved attention mechanism CNN model, the channel attention layer adaptively calculates the weights of each feature channel, strengthens the channels that contribute significantly to quality judgment (such as channels reflecting the polarization characteristics of mixed bacteria and channels reflecting the irregularity of microbial morphology), and weakens the interference of irrelevant channels. The spatial attention layer calculates the weights of each pixel in the image, focuses on the core region of microorganisms (such as the cell body), ignores invalid information in blurred edge regions, and improves the model's ability to recognize key features.

[0036] The six morphological feature parameters in step 4 comprehensively capture the morphological differences of microorganisms from four dimensions: size, shape, texture, and structure. This can effectively distinguish different types of microorganisms and make up for the shortcomings of spectral features, which only reflect optical properties. The feature fusion method in step 5 preserves complete spectral and morphological information, the normalization process eliminates dimensional interference, and the improved attention mechanism strengthens key features through dual weight allocation, avoiding interference from irrelevant information. This significantly improves the model's feature recognition ability and prediction accuracy, making the model's judgment of wine quality more reliable and robust.

[0037] In step 5, the model training parameters are set as follows: initial learning rate of 0.001, which is reduced to 1 / 10 of the initial value in the later stage of training; batch size of 32; no more than 100 training epochs; and Adam optimizer. During training, dropout technology is used to prevent overfitting, with a dropout rate of 0.5. Training is stopped when the accuracy on the validation set no longer improves for 10 consecutive epochs. In step 2, when acquiring multispectral polarization images, the polarizer is adjusted to four directions: 0°, 45°, 90°, and 135° for each characteristic band. At least three frames are acquired for each direction, and the average value is taken as the final image for that band and polarization direction. The quality indicators in step 6 include sensory score, total bacterial count and volatile acid content. The total testing time for a single sample shall not exceed 5 minutes, and the testing process shall be non-destructive.

[0038] In the model training parameters of step 5, the initial learning rate of 0.001 has been experimentally verified to balance the convergence speed and training accuracy of the model. If the initial learning rate is too high, it will easily cause the model to oscillate and not converge, while if it is too low, the training efficiency will be low. In the later stages of training, the learning rate is reduced to 1 / 10 of the initial value. This can avoid parameter fluctuations caused by an excessively large learning rate in the later stages of training, and allow the model to converge stably to the optimal solution. A batch size of 32 is compatible with the memory capacity of most GPUs, which can ensure training efficiency while avoiding gradient estimation bias caused by excessively large batches. The training epochs are limited to no more than 100 because experiments have shown that the model converges within 100 epochs in most cases, and overfitting is likely to occur after more than 100 epochs. The Adam optimizer combines the advantages of momentum gradient descent and adaptive learning rate, which can adapt to the training needs of different feature dimensions and improve training efficiency. The dropout rate of 0.5 randomly discards 50% of the neurons in the fully connected layers to avoid the model from over-relying on a certain type of feature and effectively prevent overfitting. An early stopping strategy, where training is halted when the validation set accuracy no longer improves after 10 consecutive rounds, further avoids overfitting and saves training time. In step 2, acquiring at least 3 frames for each polarization direction and averaging them reduces the impact of random noise (such as ambient light fluctuations and sensor electronic noise) on the images, improving image stability and reliability. Acquiring data in four polarization directions can comprehensively capture the polarization characteristics of microorganisms, avoiding incomplete feature information caused by a single polarization direction.

[0039] In step 6, the quality indicators include sensory scores, which reflect the overall quality of the wine (color, aroma, and taste), total bacterial count, which reflects the degree of microbial contamination in the wine, and volatile acid content, which is the core indicator of wine spoilage (volatile acid content will increase significantly in spoiled wine). The combination of these three indicators can comprehensively evaluate the quality of the wine. The testing time for a single sample is no more than 5 minutes, which greatly improves the testing efficiency compared to traditional physicochemical analysis (≥24 hours). The non-destructive testing characteristics allow the tested samples to be used in production or sales, avoiding sample waste.

[0040] Step 5's precise parameter limiting and optimization strategies such as early stopping and dropout ensured the model's training effectiveness, avoiding overfitting and low training efficiency, and enabling the model to achieve an accuracy of 96.8% on the test set. Step 2's detailed image acquisition design improves the quality and stability of multispectral polarization images, providing reliable data for feature extraction; The comprehensiveness of the quality indicators in step 6 ensures the scientific nature of wine quality evaluation. The rapid and non-destructive testing characteristics meet the testing needs of multiple stages of wine production, storage, and sales, reducing testing costs and sample loss for enterprises, enhancing the practical value and market competitiveness of the technical solution, and also increasing the creativity and licensing potential of the patent.

[0041] In this embodiment, the present invention operates as follows: First, wine sample pretreatment was carried out. After selecting the wine sample to be tested, a filter membrane with a pore size of 100μm was used to filter out large particulate impurities with a particle size greater than 100μm to avoid these impurities interfering with subsequent microbial imaging. Then, the filtered pretreated sample was injected into a transparent quartz detection cell, and the thickness of the detection cell was controlled within the range of 0.5-1mm. During the injection process, it was ensured that no air bubbles remained in the sample to ensure that the sample layer thickness was uniform and to reduce the impact of differences in light propagation path on imaging quality.

[0042] Next, start the multi-spectral polarization imaging system for image acquisition. The system consists of a multi-band LED light source, an electric polarizer, an industrial CMOS image sensor, a fixed-focus imaging lens, and an embedded control system. The wavelength of the multi-band LED light source covers 400 - 1000 nm and includes 10 independently controllable characteristic bands. The adjustment range of the polarization direction of the electric polarizer is 0 - 180°, and the adjustment accuracy is not less than 0.1°. The resolution of the industrial CMOS image sensor is not less than 2048×2048, and the pixel size is not more than 3.75 μm. Through the embedded control system, the multi-band LED light source is controlled to be lit in sequence. When each characteristic band is lit, the electric polarizer is adjusted to four directions of 0°, 45°, 90°, and 135° respectively. For each direction, no less than 3 frames of images are collected and the average value is taken as the final image under this band and this polarization direction. Finally, 40 polarization spectral images can be obtained for each sample.

[0043] Preprocess the 40 collected polarization spectral images: First, collect the dark current image of the image sensor when there is no light source illumination, and subtract the dark current image from the collected polarization spectral image to complete the dark current correction and eliminate the dark current noise. Then, use the adaptive median filtering algorithm to remove Gaussian noise and salt-and-pepper noise in the image. The size of the filtering window is adaptively adjusted within the range of 3×3 - 7×7 according to the image noise intensity. Finally, use the SIFT feature point matching algorithm for image registration. Take the image of the 450 nm band and 0° polarization direction as the reference image, and register the images of other bands and other polarization directions to ensure that the registration error is controlled within 1 pixel, guaranteeing the spatial consistency of the images under different bands and different polarization directions.

[0044] After completing the image preprocessing, extract the microbial features: On the one hand, extract the polarization spectral features. Calculate the polarization degree P of each pixel point in 4 polarization directions. The calculation formula of the polarization degree P is (where is the maximum gray value of this pixel point in 4 polarization directions, is the minimum gray value). Set the polarization degree threshold P0 (the value range is 0.3 - 0.5) determined by training a large number of samples. Pixel points with polarization degree P≥P0 are determined as microbial regions, and pixel points with P<P0 are determined as background regions to achieve the segmentation of microbial regions and the background. Subsequently, extract the gray mean value, gray variance, polarization degree mean value, and polarization angle mean value of the microbial region under each characteristic band, and integrate them to form a microbial polarization spectral feature vector with a dimension of 40. On the other hand, extract the morphological features. Use binary processing to convert the microbial region image into a binary image, and extract 6 morphological feature parameters including area, perimeter, circularity, aspect ratio, texture entropy, and skeleton length. The calculation formula of circularity is (S is the area of ​​the microbial region, and L is the perimeter of the microbial region). The texture entropy is obtained by calculating the entropy value of the gray-level co-occurrence matrix (the distance of the gray-level co-occurrence matrix is ​​1, and the angle is 0°, 45°, 90°, and 135°. The average value is taken as the final texture entropy). After integration, a microbial morphological feature vector with a dimension of 6 is formed.

[0045] Next, feature fusion and model training were performed: the 40-dimensional polarization spectral feature vector and the 6-dimensional morphological feature vector were fused using feature concatenation to construct a 46-dimensional feature fusion matrix; the min-max normalization method was used to process the feature fusion matrix, and the normalization formula is as follows: (where x is an element in the feature fusion matrix,) The minimum value in the feature fusion matrix. (where is the maximum value in the feature fusion matrix), so that the normalized eigenvalue range is [0,1]; The normalized feature fusion matrix is ​​input into the improved attention mechanism CNN model, which includes a channel attention layer and a spatial attention layer (the channel attention layer strengthens key feature channel information by assigning channel weights to the pooling layer output, and the spatial attention layer strengthens key microbial region feature information by assigning spatial weights). The model training parameters are set as follows: initial learning rate of 0.001 (decaying to 1 / 10 of the initial value in the later stage of training), batch size of 32, no more than 100 training epochs, Adam optimizer is used, and dropout technology (dropout rate of 0.5) is used during training to prevent overfitting. Training is stopped when the accuracy of the validation set no longer improves for 10 consecutive epochs. The actual quality indicators of wine samples (determined by traditional sensory evaluation and physicochemical analysis methods) are used as labels. After training, the AI ​​detection model for wine quality is obtained.

[0046] Finally, the wine quality testing is carried out: the above steps of sample preprocessing, multispectral polarization image acquisition, image preprocessing, feature extraction, and feature fusion are repeated for the wine samples to be tested to obtain the feature fusion matrix of the sample to be tested; the feature fusion matrix is ​​input into the trained wine quality AI detection model, and the model outputs the sensory score, total bacterial count, volatile acid content, and other quality index prediction values ​​of the sample to be tested. The quality grade of the wine is determined based on the prediction values; the entire testing process is non-destructive, and the total time for testing a single sample does not exceed 5 minutes, enabling rapid on-site testing.

[0047] The following are several other specific embodiments of the application of this invention: Example 1 Sample preparation: 800 white wine samples from different origins and with different winemaking processes were selected, including 250 high-quality white wines, 350 qualified white wines, and 200 inferior white wines. Sample pretreatment employed a combination of centrifugation and filtration. First, the sample was centrifuged at 3000 rpm for 5 minutes to remove most of the suspended precipitate. Then, it was filtered through an 80 μm pore size membrane to further remove residual large particles. The pretreated sample was then injected into a 0.6 mm thick transparent sapphire detection cell. Sapphire is more wear-resistant than quartz and has better transmittance in the short-wavelength band. After injection, the sample was ultrasonically degassed for 1 minute to ensure that no air bubbles remained.

[0048] Multispectral polarization imaging system setup: The system includes a multi-band laser source, a manual high-precision polarizer, an industrial CCD image sensor, a zoom imaging lens, and a PLC control system; The multi-band laser source covers a wavelength range of 380-900nm, with eight independently controllable characteristic bands selected: 380nm, 450nm, 520nm, 580nm, 650nm, 720nm, 800nm, and 900nm. The laser source exhibits excellent monochromaticity, reducing spectral overlap interference. The manual high-precision polarizer allows for polarization direction adjustment from 0-180° with an adjustment accuracy of 0.05°, meeting the precise polarization signal acquisition requirements in low-pigment scenarios for white wine. The industrial CCD image sensor has a resolution of 4096×4096 and a pixel size of 2.5μm, which can capture finer microbial morphologies. The zoom imaging lens has a focal length adjustment range of 15-30mm and an aperture of F1.2, which can adapt to the imaging needs of different sample concentrations. The PLC control system is responsible for the coordinated control of light source illumination, polarizer adjustment, and image sensor operation.

[0049] System calibration and image acquisition: The system is calibrated using a high-reflectivity standard white plate and a polarization calibration plate. During the calibration process, grayscale accuracy calibration in the short-wave band (380nm) is added. Image acquisition parameters are set as follows: exposure time 8ms, gain 0.8, acquisition speed 15 frames / second; The PLC control system controls the sequential lighting of multi-band laser sources. When each band is lit, the polarizer is adjusted to four directions: 0°, 45°, 90°, and 135°. Five frames of images are acquired in each direction, and the average value is taken as the final image for that band and polarization direction. After each sample is acquired, 32 polarization spectral images are obtained.

[0050] Image preprocessing: Dark current correction adopts the method of "multiple acquisitions and averaging", acquiring 10 frames of dark current images without light source illumination, and taking the average value as the final dark current image to improve the correction accuracy. Noise removal employs an algorithm combining adaptive median filtering and Gaussian filtering. First, Gaussian filtering removes high-frequency noise, and then adaptive median filtering removes salt-and-pepper noise. The filtering window size ranges from 2×2 to 6×6. Image registration uses the SURF feature point matching algorithm, with an image at 450nm wavelength and 0° polarization as the reference image. The registration error is controlled within 0.5 pixels, which addresses the issue of indistinct feature points caused by the high light transmittance of white wine backgrounds.

[0051] Feature extraction: In the microbial polarization spectral feature extraction, the calculation formula for the degree of polarization P remains unchanged, and the polarization threshold P0 is set to 0.35. This threshold is determined through training with 500 white wine samples to adapt to the polarization difference between white wine microorganisms and the background. The mean gray level, gray level variance, mean polarization degree, mean polarization angle, and spectral peak position of the microbial region under each characteristic band are extracted and integrated to form a polarization spectral feature vector with a dimension of 40. In the extraction of microbial morphological features, a "convex hull area" feature parameter is added to the original 6 feature parameters. The ratio of the convex hull area to the actual area can more accurately reflect the morphological regularity of microorganisms in white wine. After integration, a morphological feature vector with a dimension of 7 is formed.

[0052] Feature fusion and model training: A feature fusion matrix is ​​constructed using a weighted feature fusion method, where the weight of polarization spectral features accounts for 0.6 and the weight of morphological features accounts for 0.4. The weights are determined by the analytic hierarchy process. The min-max normalization method is still used, and the normalized eigenvalues ​​range from [0,1].

[0053] The improved attention mechanism CNN model structure is adjusted as follows: input layer (input dimension 47×1), convolutional layer 1 (64 3×1 convolutional kernels, activation function ReLU), pooling layer 1 (2×1 max pooling), convolutional layer 2 (128 3×1 convolutional kernels, activation function ReLU), pooling layer 2 (2×1 max pooling), channel attention layer, spatial attention layer, fully connected layer 1 (256 neurons, activation function ReLU), fully connected layer 2 (128 neurons, activation function ReLU), and output layer (3 neurons, activation function Softmax).

[0054] Model training parameter settings: initial learning rate 0.0008, decayed to 1 / 8 of the initial value in the later stage of training, batch size 64, number of training epochs 80, and AdamW optimizer used; During training, dropout (dropout rate 0.4) and L2 regularization (regularization coefficient 0.001) are used to prevent overfitting. Training stops when the accuracy on the validation set no longer improves after 8 consecutive rounds.

[0055] Quality testing and verification: 150 white wine samples that were not used in model training were selected as verification samples. After processing according to the above steps, they were input into the trained model to obtain the quality grade prediction results; at the same time, the actual quality grade was determined using traditional methods.

[0056] The verification results show that the detection accuracy rate is 96.2%, with a high-quality white wine identification accuracy rate of 97.3%, a qualified white wine identification accuracy rate of 95.8%, and a low-quality white wine identification accuracy rate of 94.7%. The detection time for a single sample is 3.8 minutes, and the detection process is non-destructive, which is suitable for the rapid detection needs in the production and sales of white wine.

[0057] Example 2 Sample preparation: Select the wine sample to be tested (any variety), and use a disposable filter membrane with a pore size of 120μm for rapid filtration to remove obvious large particulate impurities and simplify the pretreatment process; The filtered sample is injected into a transparent detection cell made of ordinary glass with a thickness of 1 mm. During the injection process, the detection cell is tilted and the sample is injected slowly to reduce the generation of air bubbles, eliminating the need for additional degassing treatment.

[0058] Multispectral polarization imaging system construction: A miniaturized multispectral polarization imaging device is used. The system includes a small multi-band LED light source, a fixed polarization direction polarizer group, a low-resolution industrial CMOS image sensor, a fixed focal length imaging lens, and an embedded microcontroller. The small multi-band LED light source covers wavelengths from 450 to 850 nm, with five characteristic bands selected: 450 nm, 550 nm, 650 nm, 750 nm, and 850 nm. It is small in size and has low power consumption, making it suitable for portable applications. The fixed polarization direction polarizer group includes polarizers with three fixed polarization directions: 0°, 90°, and 135°, eliminating the need for manual or electric adjustment and improving acquisition speed; the low-resolution industrial CMOS image sensor has a resolution of 1920×1080 and a pixel size of 5μm, meeting the basic accuracy requirements for rapid on-site detection; the embedded microcontroller uses an STM32H7 series chip to handle system control and preliminary data processing.

[0059] Image acquisition and preprocessing: System calibration is simplified to grayscale calibration using a standard grayscale plate, eliminating the need for polarization accuracy calibration; Image acquisition parameters were set as follows: exposure time 15ms, gain 1.2, and acquisition speed 20 frames / second. A multi-band LED light source was sequentially illuminated by an embedded microcontroller. When each band was illuminated, images in three polarization directions were acquired by switching a fixed polarizer group. Two frames were acquired in each direction, and the average value was taken. After each sample was acquired, 15 polarization spectral images were obtained. Image preprocessing only retained dark current correction and simple noise removal. Dark current correction was performed by subtracting a preset dark current parameter, eliminating the need for on-site dark current image acquisition. Noise removal used a median filtering algorithm with a fixed 3×3 window to simplify the calculation process.

[0060] Feature Extraction and Model Training: In microbial polarization spectral feature extraction, only the polarization degree P of each pixel in the three polarization directions is calculated (the calculation formula is adjusted to...). ,in The maximum grayscale value. (Using the minimum grayscale value), a polarization threshold P0=0.45 was set to segment the microbial region; The mean gray level and mean polarization degree of the microbial region under each characteristic band are extracted and integrated to form a polarization spectral feature vector with a dimension of 10.

[0061] In microbial morphological feature extraction, only three core feature parameters—area, perimeter, and roundness—are retained and integrated to form a 3-dimensional morphological feature vector. Feature fusion employs feature concatenation to construct a 13-dimensional feature fusion matrix, which is then processed using z-score normalization. The improved attention mechanism CNN model is simplified to: input layer (13×1 input dimension), convolutional layer (32 3×1 convolutional kernels), pooling layer, channel attention layer, fully connected layer (64 neurons), and output layer (3 neurons). Model training parameters are set as follows: initial learning rate 0.002, batch size 64, training epochs 50, and SGD optimizer; dropout technology (dropout rate 0.6) is used during training to prevent overfitting.

[0062] Quality inspection and verification: After processing the samples according to the simplified steps described above, they are input into the trained model, and the model outputs the quality grade (excellent, qualified, poor). Verification results show that the detection accuracy rate is 92.3%, which meets the basic needs of rapid on-site sampling. The testing time for a single sample is only 2.5 minutes. The equipment is small in size and light in weight (≤2kg). It can be powered by batteries and is suitable for on-site scenarios without power. The testing process is non-destructive, and the tested samples can be sold or stored normally.

[0063] Example 3 This embodiment is designed to address the characteristics of sparkling wine, which contains a large amount of carbon dioxide bubbles and easily interferes with microbial imaging. The focus is on solving the problems of bubble blockage and scattering of polarization spectral signals. The specific working process is as follows: Sample preparation: 700 sparkling wine samples of different sweetness levels were selected, including 200 natural, 200 completely dry, 200 semi-dry, and 100 sweet samples, including 300 high-quality, 250 qualified, and 150 low-quality samples. Sample pretreatment adopted a combination of low-temperature standing and gradient filtration. First, the samples were placed in a low-temperature environment of 4℃ and left to stand for 30 minutes to allow most of the bubbles to rise and break. Then, they were filtered through two-stage filter membranes of 120μm and 100μm to remove large particulate impurities and unbroken residual bubbles to avoid bubbles blocking microorganisms during imaging. The processed samples were injected into a quartz detection cell with a thickness of 0.5mm at an injection speed controlled at 0.5ml / s to further reduce bubble generation.

[0064] Multispectral polarization imaging system setup: The system includes a multi-band pulsed LED light source, an electrically driven high-speed polarizer, a high-speed industrial CMOS image sensor, a macro imaging lens, and an embedded real-time control system. The multi-band pulsed LED light source covers wavelengths from 420-950nm, selecting nine characteristic bands: 420nm, 450nm, 500nm, 550nm, 600nm, 650nm, 750nm, 850nm, and 950nm. The pulse frequency is set to 50Hz to quickly capture microbial images from the gaps between bursting bubbles, avoiding dynamic interference from bubbles. The electrically driven high-speed polarizer has an adjustment response time of ≤1ms, a polarization direction adjustment range of 0-180°, and an adjustment accuracy of 0.1° to meet rapid imaging needs. The high-speed industrial CMOS image sensor has a resolution of 2048×2048 and a frame rate of ≥50 frames / second, capable of capturing instantaneous microbial morphology. The macro imaging lens has a magnification of 8× and an aperture of F1.2 to enhance the clarity of microbial imaging. The embedded real-time control system adopts an FPGA+ARM architecture to achieve parallel computing for image acquisition and preprocessing, improving processing speed.

[0065] System calibration and image acquisition: A standard whiteboard with polarization calibration function was used for system calibration. A bubble simulation calibration step was added. The polarization spectral characteristics of bubbles of different sizes were recorded for bubble identification and elimination during subsequent image preprocessing. Image acquisition parameters were set: exposure time 5ms, gain 0.9, acquisition speed 50 frames / second. The multi-band pulsed LED light source was controlled by the control system to light up the light source in sequence. When each band was lit, the motorized high-speed polarizer quickly switched to four directions: 0°, 45°, 90°, and 135°. Four frames were acquired in each direction. The two frames with the fewest bubbles were selected and the average value was taken as the final image in that polarization direction of that band. After each sample was acquired, 36 polarization spectral images were obtained.

[0066] Image preprocessing: Dark current correction uses preset correction parameters combined with real-time acquired dark current compensation values ​​to improve correction efficiency. Noise removal employs an algorithm combining adaptive median filtering and morphological filtering. First, morphological filtering is used to identify and mark bubble regions, and then adaptive median filtering is applied to non-bubble regions. The filtering window size is 2×2-5×5 to avoid misprocessing of bubble regions. Image registration uses the ORB feature point matching algorithm, with the image at 0° polarization direction in the 550nm band as the reference. The image registration error is controlled within 1 pixel. At the same time, bubble feature points identified during the registration process are removed to avoid bubbles affecting the registration accuracy.

[0067] Feature Extraction: In the microbial polarization spectral feature extraction, the calculation formula for the degree of polarization P remains unchanged. The polarization threshold P0 = 0.38 is set. This threshold is determined through training with 400 sparkling wine samples to adapt to the polarization difference between sparkling wine microorganisms and background bubbles. The mean gray value, gray value variance, mean polarization degree, and mean polarization angle of microorganisms in non-bubble areas under each feature band are extracted and integrated to form a polarization spectral feature vector with a dimension of 36. In the microbial morphological feature extraction, in addition to retaining the original 6 feature parameters, a "bubble interference coefficient" parameter is added to quantify the influence of bubbles around the microbial region. The bubble interference coefficient is calculated by the distance and overlap area between the microbial region and the bubble region and is integrated to form a morphological feature vector with a dimension of 7.

[0068] Feature fusion and model training: A feature fusion matrix with a dimension of 43 is constructed by fusing 36-dimensional polarization spectral feature vectors and 7-dimensional morphological feature vectors using feature concatenation. The min-max normalization method is used to process the normalized feature values, resulting in a range of [0,1]. An improved attention mechanism is implemented in the CNN model by adding a bubble interference exclusion layer. The bubble interference coefficient is first filtered to weaken the weights of features with large bubble interference. The model structure is adjusted to an input layer with an input dimension of 43×1. Convolutional layer 1: 48 3×1 convolutional kernels with ReLU activation function. Pooling layer 1: 2×1 max pooling. Convolutional layer 2: 96 3×1 convolutional kernels with ReLU activation function. Bubble interference exclusion layer: Channel attention layer, Spatial attention layer, Fully connected layer 1: 192 neurons with ReLU activation function. Fully connected layer 2: ... The model uses ReLU activation function for 96 neurons and Softmax activation function for 3 neurons in the output layer. Training parameters include an initial learning rate of 0.0012, which decays to 1 / 12 of the initial learning rate later in training; a batch size of 48; and 90 training epochs. The optimizer is Adam. Dropout is used during training with a dropout rate of 0.45 and an early stopping strategy. Training stops when the validation set accuracy no longer improves after 9 consecutive epochs.

[0069] Quality Inspection and Verification: 120 sparkling wine samples that were not used in model training were selected as verification samples. After processing according to the above steps, they were input into the trained model to obtain the predicted quality grade. At the same time, the actual quality grade was determined using traditional methods. The verification results showed that the detection accuracy rate was 95.1%, with a 96.3% accuracy rate for identifying high-quality sparkling wine, a 94.8% accuracy rate for identifying qualified sparkling wine, and a 93.9% accuracy rate for identifying inferior sparkling wine. The detection time for a single sample was 4.5 minutes. The detection process was non-destructive and could effectively meet the quality control requirements of the sparkling wine production and tasting process.

[0070] Example 4 This embodiment is designed to meet the online continuous testing needs of wine production lines, adapting to batch testing scenarios to achieve automatic sample collection, rapid testing, and real-time feedback. The specific working process is as follows: Sample preparation: The automatic continuous sampling is achieved by using the diversion sampling device of the wine production line. The sampling frequency is matched with the production line speed and set to collect one sample every 5 seconds. The single sampling volume is 5ml. After sampling, the sample is transported to the pretreatment unit through pipeline. The pretreatment unit adopts an automatic filtration device with a built-in disposable filter membrane with a pore size of 100μm to automatically filter out large particulate impurities. After filtration, the sample is automatically injected into a quartz detection cell with a thickness of 0.8mm by a peristaltic pump. The detection cell is equipped with an automatic cleaning function. Every 10 samples are tested are automatically cleaned with sterile water 3 times to avoid cross-contamination of samples.

[0071] Multispectral polarization imaging system setup: An online multispectral polarization imaging device is integrated into the production line. The system includes a multi-band continuous LED light source, an electric polarizer assembly, an industrial linear array CMOS image sensor, a fixed-focal-length imaging lens, and a PLC control system. The multi-band continuous LED light source covers wavelengths from 400-1000nm with 10 characteristic bands that can be independently controlled. Power stability ensures spectral consistency in continuous imaging. The electric polarizer assembly contains four polarizers with fixed polarization directions, which can be quickly switched via solenoid valves with a switching time of ≤2ms, adapting to the rapid inspection needs of production lines. The industrial linear array CMOS image sensor has a resolution of 4096×1 pixels, a size of 3.75μm, and a frame rate of ≥30 frames / second, enabling continuous image acquisition. The fixed-focal-length imaging lens has a focal length of 25mm and an aperture of F1.4 to ensure image clarity. The PLC control system is linked with the production line control system to achieve full automation of the sampling, preprocessing, imaging, and inspection process.

[0072] System calibration and image acquisition: An online automatic calibration mode is adopted. Before the production line starts every day, the system calibration is automatically completed using standard samples to ensure detection accuracy. The image acquisition parameters are set as follows: exposure time 10ms, gain 1.0, acquisition speed 30 frames / second. The PLC control system controls the multi-band continuous LED light source to light up in sequence. When each band is lit, the solenoid valve quickly switches the polarizer group to four directions: 0°, 45°, 90°, and 135°. Three frames of images are acquired in each direction and the average value is taken. After each sample is acquired, 40 polarization spectrum images are obtained. The images are transmitted to the back-end processing unit through optical fiber to avoid signal attenuation.

[0073] Image preprocessing: A parallel computing architecture is used to achieve synchronous preprocessing of multiple sample images. Dark current correction uses a preset dark current calibration curve to compensate for dark current noise in real time. Noise removal uses an adaptive median filtering algorithm with a fixed 3×3 window to simplify the calculation process and improve processing speed. Image registration uses a template matching algorithm with the image in the 0° polarization direction of the 450nm band as the reference template. The registration error is controlled within 1 pixel to ensure that the processing efficiency meets the pipeline requirements.

[0074] Feature Extraction and Model Training: Microbial polarization spectral feature extraction employs a simplified algorithm to calculate the polarization degree P of each pixel, then sets a fixed polarization degree threshold P0=0.4 to segment the microbial region. The mean grayscale and mean polarization degree of each feature band are extracted and integrated to form a 20-dimensional polarization spectral feature vector. This simplifies feature dimensions and improves processing speed. Microbial morphological feature extraction retains the three core parameters: area, perimeter, and circularity, which are then integrated to form a 3-dimensional morphological feature vector. Feature fusion uses a concatenation method to construct a 23-dimensional feature fusion matrix. Min-max normalization is used for processing. An improved attention mechanism is employed. The CNN model is lightweighted and optimized, reducing the number of neurons in convolutional and fully connected layers. The model structure is adjusted to an input layer with an input dimension of 23×1, a convolutional layer 1 with 32 3×1 convolutional kernels and ReLU activation function, a pooling layer 1 with 2×1 max pooling, a convolutional layer 2 with 64 3×1 convolutional kernels and ReLU activation function, a pooling layer 2 with 2×1 max pooling, a channel attention layer, and a fully connected layer 1. The model uses ReLU activation function for 64 neurons and Softmax activation function for 3 neurons in the output layer. Training parameters include an initial learning rate of 0.001, a batch size of 64, and 80 training epochs. The optimizer uses SGD to ensure fast model convergence.

[0075] Quality Inspection and Verification: Under normal production line conditions, 1000 online-collected samples were selected for inspection and verification. Simultaneously, 200 samples were tested using traditional laboratory methods to determine their quality grade as verification of the actual labels. The results showed that the model's detection accuracy was 94.2%, with a 95.6% accuracy rate for identifying premium wines, a 94.3% accuracy rate for identifying qualified wines, and a 92.8% accuracy rate for identifying inferior wines. The single-sample testing time was reduced to 2.8 minutes, enabling real-time continuous inspection of the production line. When an inferior sample is detected, the system automatically issues an alarm signal, and the production line automatically diverts the corresponding batch of samples to the re-inspection unit, effectively preventing unqualified products from entering subsequent stages.

[0076] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope disclosed in the present invention, and these should all be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A wine quality AI visual inspection method, characterized in that, Includes the following steps: Step 1: Wine sample pretreatment to remove large particulate impurities from the sample, and then inject the pretreated sample into the transparent detection cell; Step 2: Multispectral polarization image acquisition. The polarization spectrum images of wine samples under different bands and polarization directions are acquired through a multispectral polarization imaging system, and the acquired images are preprocessed. Step 3: Microbial polarization spectral feature extraction. Based on the polarization degree threshold, the microbial region is segmented, and the polarization spectral feature parameters of the microorganisms in each band are extracted to construct a polarization spectral feature vector. Step 4: Extraction of microbial morphological features. Based on the microbial region image, extract the morphological feature parameters of the microorganisms and construct a morphological feature vector. Step 5: Feature fusion and model training. The polarization spectral feature vector and morphological feature vector are fused to construct a feature fusion matrix, which is then input into an improved attention mechanism convolutional neural network (CNN) model for training to obtain a wine quality AI detection model. Step 6: Wine quality testing. Repeat steps 1-5 on the sample to be tested to obtain the feature fusion matrix. Input the matrix into the trained model to obtain the predicted value of the quality index. Determine the wine quality grade based on the predicted value.

2. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: In step 1, the removal of large particulate impurities is achieved by using a filter membrane with a pore size of 100 μm. The transparent detection cell is made of quartz material with a thickness of 0.5-1 mm, and there are no air bubbles remaining after the sample is injected.

3. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: The multispectral polarization imaging system described in step 2 includes a multi-band LED light source, an electric polarizer, an industrial CMOS image sensor, a fixed-focus imaging lens, and an embedded control system. The multi-band LED light source has a wavelength range of 400-1000nm and includes 10 independently controllable characteristic bands; the electric polarizer has a polarization direction adjustment range of 0-180° and an adjustment accuracy of not less than 0.1°. The industrial CMOS image sensor has a resolution of no less than 2048×2048 and a pixel size of no more than 3.75μm.

4. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: Step 2 of the image preprocessing includes dark current correction, noise removal, and image registration; the noise removal uses an adaptive median filtering algorithm with a filter window size of 3×3-7×7. The image registration uses the SIFT feature point matching algorithm, with an image in the 450nm band and 0° polarization direction as the reference image, and the registration error is controlled within 1 pixel.

5. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: The formula for calculating the degree of polarization P in step 3 is as follows: ,in This represents the maximum grayscale value of a pixel across its four polarization directions. The minimum gray value is defined as P0; the polarization threshold P0 ranges from 0.3 to 0.5 and is determined through training with a large number of samples.

6. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: The polarization spectral feature parameters mentioned in step 3 include the mean gray level, gray level variance, mean polarization degree, and mean polarization angle of the microbial region under each feature band. After integration, they form a polarization spectral feature vector with a dimension of 40.

7. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: The morphological feature parameters mentioned in step 4 include area, perimeter, roundness, aspect ratio, texture entropy, and skeleton length; The formula for calculating roundness is as follows: Where S is the area of ​​the microbial region and L is the perimeter; the texture entropy is calculated through a gray-level co-occurrence matrix, where the distance of the gray-level co-occurrence matrix is ​​1 and the angles are 0°, 45°, 90°, and 135°, and the average value is taken as the final texture entropy.

8. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: The improved attention mechanism CNN model described in step 5 includes a channel attention layer and a spatial attention layer; The channel attention layer enhances key feature channel information by assigning channel weights to the output of the pooling layer, and the spatial attention layer enhances key microbial region feature information by assigning spatial weights. The feature fusion adopts a feature concatenation method, and after fusion, a feature fusion matrix with a dimension of 46 is constructed. Before fusion, the min-max normalization method is used, and the feature value range after normalization is [0,1].

9. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: In step 5, the model training parameters are set as follows: the initial learning rate is 0.001, which is decayed to 1 / 10 of the initial value in the later stage of training; the batch size is 32; the number of training epochs does not exceed 100; and the Adam optimizer is used. During training, the dropout technique is used to prevent overfitting, with a dropout rate of 0.

5. Training is stopped when the accuracy on the validation set no longer improves for 10 consecutive epochs.

10. The AI ​​visual inspection method for wine quality according to claim 1, characterized in that: In step 2, when acquiring multispectral polarization images, the polarizer is adjusted to four directions: 0°, 45°, 90°, and 135° for each characteristic band. At least three frames are acquired for each direction, and the average value is taken as the final image for that band and polarization direction. The quality indicators mentioned in step 6 include sensory score, total bacterial count and volatile acid content. The total testing time for a single sample shall not exceed 5 minutes, and the testing process shall be non-destructive.