Micro-needle blemish detection model construction method and system
Patent Information
- Application Number
- CN202611468354.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-21
- Publication Date
- 2026-10-27
AI Technical Summary
此类方案在处理数据时,往往将实体轮廓的形变、光学折射斑块及背景纹理视为彼此融合的整体参量,依赖对全局像素强度的直接拟合,缺乏针对光照不均与复杂背景噪声的自适应抑制机制
本发明根据原始图像矩阵的局部对比度矩阵,并结合双曲正切函数与局部对比度矩阵平方项构建增强逻辑,生成增强图像矩阵;随后,通过双分支卷积网络分别提取断裂边缘场景特征与光学纹理场景特征,生成对应的边缘特征矩阵与纹理特征矩阵,并计算两者的空间重叠度及距离分布相似性以获得解耦损失值。本发明克服了传统单一全局特征提取易受透明材质高反光与不规则折射干扰的技术瓶颈,成功剥离了背景杂光对微针实体几何突变轮廓的掩盖效应,提升了模型在复杂光学扰动环境下捕获微小瑕疵的精度与抗干扰能力;
Smart Images

Figure CN122989733A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of microneedle patch defect detection technology, specifically to a method and system for constructing a microneedle patch defect detection model. Background Technology
[0002] With the rapid development of medical aesthetics technology, microneedle patches, as a novel and highly efficient minimally invasive drug delivery carrier, are rapidly expanding their application scenarios in transdermal delivery. The micron-scale needle array on the surface of microneedle patches can painlessly penetrate the stratum corneum, and their manufacturing quality directly affects drug release efficiency. Accurate detection of defects during the microneedle patch manufacturing process is a physical prerequisite for ensuring product compliance before shipment. However, the microneedle patch matrix often has transparent or semi-transparent properties, and its structure is tiny and densely packed. In conventional industrial visual inspection environments, this complex physical structure easily induces irregular refraction and high-intensity reflection of light, resulting in highly concealed micro-defect features that can be confused with normal textures, greatly hindering the accurate extraction of subsequent visual features.
[0003] Existing visual inspection methods for micro-pin sticker defects typically deploy high-definition cameras and fixed light sources during the quality inspection stage, assessing the forming status by acquiring single-dimensional images of the micro-pin sticker surface. These methods largely rely on directly feeding the acquired raw images into conventional deep learning networks to extract global visual features and convert them into defect category values. In terms of detection logic, existing technologies generally employ single-branch fixed models trained on general samples, triggering defect rejection by determining whether the extracted pixel features exceed boundaries. When processing data, such schemes often treat the deformation of the entity contour, optical refraction patches, and background texture as a holistic parameter that is integrated with each other, relying on direct fitting of global pixel intensity and lacking adaptive suppression mechanisms for uneven illumination and complex background noise.
[0004] In real-world high-throughput manufacturing environments, there is a complex interference relationship between the actual fracture edges of microneedle defects and the optical texture formed by background stray light, leading to severe feature homogenization. However, existing models generally lack effective means to utilize local contrast extrema and lack dedicated mechanisms to deeply decouple geometrical abrupt changes from optical texture features. This makes it difficult for the network to isolate the masking effect of transparent background materials on the actual needle fracture edges, easily resulting in mutual interference in feature extraction. Furthermore, conventional loss functions tend to exhibit gradient homogenization when dealing with weak features coupled from multiple sources, failing to force the network to independently extract orthogonal dimension scene features, easily causing missed detection of tiny broken needles, making it difficult to accurately define the spatial localization boundary of defects under complex optical perturbations.
[0005] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0006] The purpose of this invention is to provide a method and system for constructing a microneedle patch defect detection model to solve the problems mentioned in the background art.
[0007] To achieve the above objectives, the present invention provides the following technical solution: A method for constructing a defect detection model for microneedle patches, comprising the following steps: Step 1: Obtain the original image matrix of the micro-needle patch and the real defect label matrix with the coordinates and categories of the defect area. Extract the local contrast matrix of the original image matrix. Construct enhancement logic based on the hyperbolic tangent function and the square term of the local contrast matrix. Perform highlight suppression and solid contour enhancement on the original image matrix to generate the enhanced image matrix. Step 2: Construct a dual-branch convolutional network. Input the enhanced image matrix into the dual-branch convolutional network and control the dual-branch convolutional network to extract the fracture edge scene features indicating entity defects in the enhanced image matrix to generate an edge feature matrix. Control the dual-branch convolutional network to extract the optical texture scene features indicating background interference to generate a texture feature matrix. Step 3: Calculate the spatial overlap and distance distribution similarity between the edge feature matrix and the texture feature matrix, and obtain the spatial mean to generate the decoupling loss value. During model training, the decoupling loss value is used to force the scene object features extracted by the dual-branch convolutional network to be independent of each other. Step 4: Cross-fuse the edge feature matrix and the texture feature matrix. Using the edge feature matrix as the amplitude basis, convert the texture feature matrix into a phase bias for cross-modulation calculation, and output a defect fusion feature matrix with the same spatial dimension as the real defect label matrix. Step 5: Calculate the pixel-wise error matrix between the defect fusion feature matrix and the real defect label matrix to obtain the classification loss. After obtaining the spatial mean, add the classification loss and decoupling loss values according to the preset weight to calculate the total loss value. Backpropagation completes the construction of the defect detection model. Input the micro-needle patch image to be tested into the defect detection model and output the manufacturing defect category and spatial positioning boundary results.
[0008] Furthermore, the specific steps for obtaining the original image matrix, the true defect label matrix, and extracting the local contrast matrix are as follows: The initial image of the micro-needle patch is subjected to grayscale conversion and interval normalization to generate an original image matrix with values ranging from 0 to 1. Extract the bounding box coordinates and defect categories of the manually labeled micro-needle patch data, and perform pixel-level mask mapping in the feature space with the same spatial dimension as the original image matrix to generate a real defect label matrix. Set a local sliding window of a preset size and traverse the original image matrix. Calculate the absolute difference between each pixel and the mean value of its neighboring pixels within the corresponding local sliding window to construct a local contrast matrix.
[0009] Furthermore, the specific steps for generating the enhanced image matrix are as follows: Obtain the square value of each pixel in the original image matrix to construct the first square matrix, obtain the square value of each pixel in the local contrast matrix to construct the second square matrix, calculate the square root of the sum of the first square matrix, the second square matrix and the preset anti-boundary minimum constant, divide the first square matrix by the square root element by element, and calculate the amplitude projection matrix. The local contrast matrix is summed element-wise with the preset anti-boundary minimum constant, and the original image matrix is divided element-wise by the summation result to obtain the local brightness quotient matrix. Each element in the local brightness quotient matrix is used as the input parameter of the hyperbolic tangent function for nonlinear mapping to calculate the nonlinear suppression matrix. The enhanced image matrix is generated by performing element-wise multiplication of the amplitude projection matrix and the nonlinear suppression matrix.
[0010] Furthermore, the dual-branch convolutional network includes a first branch network and a second branch network configured in parallel; The specific steps for generating the edge feature matrix are as follows: In the first branch network, the first convolution kernel weight matrix and the first bias term vector are configured. The enhanced image matrix and the first convolution kernel weight matrix are subjected to spatial sliding window convolution operation and the first bias term vector is superimposed to obtain the first intermediate response matrix. The first intermediate response matrix is mapped using a nonlinear activation function to truncate negative response noise, extract the fracture edge scene features that characterize high-frequency geometric changes, and generate the edge feature matrix. The specific steps for generating the texture feature matrix are as follows: In the second branch network, a second convolution kernel weight matrix and a second bias term vector, independent of the first branch network, are configured. The enhanced image matrix and the second convolution kernel weight matrix are subjected to spatial sliding window convolution operation and the second bias term vector is superimposed to obtain the second intermediate response matrix. The second intermediate response matrix is mapped using a nonlinear activation function to extract optical texture scene features that characterize light refraction and background light spots, and generate a texture feature matrix.
[0011] Furthermore, the specific steps for generating the decoupling loss value are as follows: The edge feature matrix and texture feature matrix are multiplied element-wise and their absolute values are extracted to obtain the coupling absolute value matrix. The coupling absolute value matrix is summed element-wise with the numerical value to obtain the overlap variable matrix. The natural logarithm is extracted from each element in the overlap variable matrix to calculate the spatial overlap matrix that represents the local coupling strength of the features. Obtain the absolute value matrix of the edge feature matrix and the absolute value matrix of the texture feature matrix respectively, calculate the element-wise difference between the edge feature matrix and the texture feature matrix and extract the absolute value to obtain the feature difference matrix; The absolute value matrix of the edge feature matrix, the absolute value matrix of the texture feature matrix, and the preset anti-boundary minimum constant are added element by element to obtain the feature normalization denominator matrix. The feature difference matrix is divided element by element by the feature normalization denominator matrix to obtain the quotient matrix. The opposite number of each element in the quotient matrix is extracted to construct the opposite number matrix. The opposite number matrix is used as the input parameter of the natural exponential function for mapping, and the distance distribution similarity matrix representing the approximation of the feature numerical distribution is calculated. The spatial overlap matrix and the distance distribution similarity matrix are multiplied element-wise to generate an intermediate penalty matrix. The arithmetic mean of all elements in the intermediate penalty matrix is calculated along the spatial dimension to perform feature dimensionality reduction and generate a decoupling loss value.
[0012] Furthermore, the specific steps for outputting the defect fusion feature matrix are as follows: Calculate the element-wise squares of the edge feature matrix and the texture feature matrix respectively to obtain the edge feature square matrix and the texture feature square matrix; The edge feature square matrix, texture feature square matrix, and preset anti-boundary minimum constant are added element-wise and their square roots are extracted to obtain the basis denominator matrix. The edge feature square matrix and the basis denominator matrix are then divided element-wise to calculate the amplitude basis. Extract the absolute value of the texture feature matrix to obtain the absolute value texture matrix. Summate the absolute value texture matrix with the numerical value one element by element to obtain the bias denominator matrix. Divide the edge feature matrix with the bias denominator matrix element by element to obtain the bias quotient matrix. Each element in the bias quotient matrix is used as the input parameter of the sine function for nonlinear mapping to calculate the phase bias. The amplitude basis and the phase bias are then multiplied element by element to complete the cross-modulation calculation and generate the defect fusion feature matrix.
[0013] Furthermore, the specific steps for calculating the total loss value are as follows: Calculate the element-wise difference between the defect fusion feature matrix and the real defect label matrix to obtain the pixel-wise error matrix, and obtain the square value of each element in the pixel-wise error matrix to construct the error square matrix. Each element in the pixel-wise error matrix is used as the input parameter of the hyperbolic cosine function for nonlinear mapping to obtain the cosine penalty matrix. The error square matrix and the cosine penalty matrix are then multiplied element-wise to generate the spatial classification loss matrix. The arithmetic mean of all elements in the spatial classification loss matrix is calculated along the spatial dimension to reduce dimensionality, and the scalar classification loss is obtained. The square of the decoupling loss value is calculated to obtain the decoupling squared term. The decoupling squared term is multiplied by the preset weight to obtain the weighted decoupling penalty value. The classification loss is arithmetically added to the weighted decoupling penalty value to calculate the total loss value.
[0014] Furthermore, backpropagation completes the defect detection model construction, and the specific steps include: Obtain the first convolutional kernel weight matrix and the first bias term vector of the first branch network in the dual-branch convolutional network, and the second convolutional kernel weight matrix and the second bias term vector of the second branch network, as the model parameters to be updated; Based on the chain rule, the partial derivatives of the total loss value with respect to the parameters of each model to be updated are calculated to obtain the parameter gradient matrix with the same dimension as the parameters of each model to be updated. Introducing a preset learning rate hyperparameter, and combining it with the parameter gradient matrix, the adaptive gradient descent optimization algorithm is used to iteratively update the parameters of the model to be updated. The enhanced image matrix is used as the input parameter for model training, the real defect label matrix is used as the supervision label for model training, and the corresponding generated defect fusion feature matrix is used as the output parameter for the forward prediction of the network. The forward feature extraction calculation and backward iterative update steps are repeated. When the total loss value decreases and converges to the preset threshold range, or when the number of iterations reaches the preset maximum iteration period, the update stops and the current first convolution kernel weight matrix, first bias term vector, second convolution kernel weight matrix, and second bias term vector are saved as the fixed network parameters of the dual-branch convolutional network, thus completing the construction of the defect detection model.
[0015] The present invention also provides a microneedle patch defect detection model construction system, which is used to implement the above-mentioned microneedle patch defect detection model construction method, including: The contrast enhancement module is used to obtain the original image matrix of the micro-needle patch and the real defect label matrix with the coordinates and categories of the defect area. It extracts the local contrast matrix of the original image matrix, constructs the enhancement logic based on the hyperbolic tangent function and the square term of the local contrast matrix, and performs highlight suppression and solid contour enhancement on the original image matrix to generate the enhanced image matrix. The dual-branch extraction module is used to construct a dual-branch convolutional network. The enhanced image matrix is input into the dual-branch convolutional network, and the dual-branch convolutional network is controlled to extract the fracture edge scene features indicating entity defects in the enhanced image matrix to generate an edge feature matrix. The dual-branch convolutional network is also controlled to extract the optical texture scene features indicating background interference to generate a texture feature matrix. The decoupling loss module is used to calculate the spatial overlap and distance distribution similarity between the edge feature matrix and the texture feature matrix, and to calculate the spatial mean to generate the decoupling loss value. During model training, the decoupling loss value is used to force the scene object features extracted by the dual-branch convolutional network to be independent of each other. The cross-modulation module is used to cross-fuse the edge feature matrix and the texture feature matrix. Using the edge feature matrix as the amplitude basis, the texture feature matrix is converted into a phase bias for cross-modulation calculation, and the output is a defect fusion feature matrix with the same spatial dimension as the real defect label matrix. The model building module is used to calculate the pixel-wise error matrix between the defect fusion feature matrix and the real defect label matrix to obtain the classification loss. After obtaining the spatial mean, the classification loss and decoupling loss values are superimposed according to the preset weight to calculate the total loss value. Backpropagation completes the construction of the defect detection model. The micro-needle patch image to be tested is input into the defect detection model, and the manufacturing defect category and spatial positioning boundary results are output.
[0016] Compared with the prior art, the beneficial effects of the present invention are: This invention constructs an enhancement logic based on the local contrast matrix of the original image matrix, combined with the hyperbolic tangent function and the squared terms of the local contrast matrix, to generate an enhanced image matrix. Subsequently, a dual-branch convolutional network is used to extract the features of the fractured edge scene and the optical texture scene, respectively, generating corresponding edge feature matrices and texture feature matrices. The spatial overlap and distance distribution similarity of the two are calculated to obtain the decoupling loss value. This invention overcomes the technical bottleneck of traditional single global feature extraction, which is easily affected by the high reflectivity and irregular refraction of transparent materials. It successfully removes the masking effect of background stray light on the geometric abrupt contours of microneedle entities, improving the model's accuracy and anti-interference ability in capturing minute defects under complex optical perturbation environments. This invention also performs cross-modulation operations on the edge feature matrix and the texture feature matrix, using the edge feature matrix as the amplitude basis to convert the texture feature matrix into a phase bias, outputting a defect fusion feature matrix. This calculation process achieves structured modulation and fusion of multi-dimensional orthogonal features in space, abandoning mechanical feature channel splicing and solving the problem that extremely weak defects in transparent materials can easily cause gradient homogenization and feature backlash. Finally, the classification loss and decoupling loss values are superimposed with preset weights to calculate the total loss value and then backpropagated, which can effectively constrain the network to adaptively focus on the real defect area and avoid unnecessary false alarms of background texture. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the overall method flow of the present invention; Figure 2 A diagram showing the mapping relationship between bi-branch orthogonal feature decoupling and spatial classification loss; Figure 3 This is a schematic diagram of the overall system structure of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to specific embodiments.
[0019] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0020] Example: Please see Figures 1-2 The present invention provides a technical solution: A method for constructing a defect detection model for microneedle patches, comprising the following steps: Step 1: Obtain the original image matrix of the micro-needle patch and the real defect label matrix with the coordinates and categories of the defect area. Extract the local contrast matrix of the original image matrix. Construct enhancement logic based on the hyperbolic tangent function and the square term of the local contrast matrix. Perform highlight suppression and solid contour enhancement on the original image matrix to generate the enhanced image matrix.
[0021] In real-world high-throughput industrial imaging environments, the matrix materials of microneedle patches generally exhibit highly transparent or semi-transparent optical properties. When light passes through a dense array, it is prone to irregular refraction and reflection, causing the visual features of real, minute imperfections to be masked by large areas of background highlights.
[0022] To separate the true geometric boundaries from complex physical astigmatism, this embodiment performs grayscale and interval normalization processing on the acquired initial image of the micropatch, generating an original image matrix with values ranging from 0 to 1. The complex refraction within the micropatch often manifests as a chromaticity shift in the color channel without substantial physical meaning. Grayscale processing directly removes redundant color dimensions, allowing data computation to focus purely on the light intensity distribution influenced by the physical contours. Further interval normalization compresses the absolute pixel values to a dimensionless range of 0 to 1, eliminating global brightness fluctuations caused by different batch lighting conditions or ambient light attenuation.
[0023] The coordinates of the bounding boxes and the defect categories in the manually labeled data of micropatch are extracted. Pixel-level masking is then performed in a feature space with the same dimensionality as the original image matrix to generate a true defect label matrix. Manual annotations typically exist as isolated geometric bounding box vectors. This embodiment transforms discrete coordinate vectors into continuous two-dimensional spatial matrices by performing masking in a blank feature space of the same dimension. This operation spatially visualizes the physical location and distribution of defects, establishing an absolute supervision standard for subsequent forward feature alignment and backward gradient optimization of the model.
[0024] A local sliding window of a preset size is set and the original image matrix is traversed. The absolute difference between each pixel and the mean value of its neighboring pixels within the corresponding local sliding window is calculated to construct a local contrast matrix. Faced with tiny and densely packed needles, a global threshold can easily cause weak local breakage edges to be swallowed by background halos. In this embodiment, the pixel width corresponding to the physical diameter of the bottom of a single microneedle calibrated by an industrial camera is obtained. This pixel width is divided by a preset receptive field scaling factor, and after rounding to the nearest integer, the side length dimension of the local sliding window is calibrated to 5×5 pixels. This size precisely covers the deformation range of a single microneedle, actively filtering out low-frequency, gradual illumination changes caused by transparent materials, and stripping away and amplifying high-frequency physical structural distortions caused by broken needles, microbubbles, etc.
[0025] Based on this, enhancement logic is executed by combining the original image matrix and the local contrast matrix to remove optical artifacts caused by transparent materials. A first square matrix is constructed by obtaining the squared value of each pixel in the original image matrix, and a second square matrix is constructed by obtaining the squared value of each pixel in the local contrast matrix. The square root of the element-wise sum of the first square matrix, the second square matrix, and a preset minimum constant for preventing boundary crossing is calculated. The first square matrix is then divided element-wise by this square root to obtain the amplitude projection matrix. This embodiment, based on the extreme values of floating-point operations at the processing device's underlying level and the dark current noise variance of an industrial camera in a completely dark environment, sets the preset minimum constant for preventing boundary crossing to... By establishing an inherent noise floor threshold for the imaging hardware, the risk of computational singularity collapse caused by pure black background areas is avoided. In the calculation, the first square matrix amplifies the absolute numerical difference between highly reflective pixels, while the second square matrix enhances edge distortion. The square root denominator of both matrices constructs an adaptive scaling operator. When local physical contrast is severe, this adaptive scaling operator automatically reduces the projection amplitude to prevent high-frequency noise divergence; when local areas are smooth, it maintains the original brightness, thus achieving initial separation between structural features and background reflections.
[0026] The local contrast matrix is summed element-wise with a preset minimum constant to prevent exceeding limits. The original image matrix is then divided element-wise by the summation result to obtain a local brightness quotient matrix. Each element of this matrix is used as input parameters for the hyperbolic tangent function for nonlinear mapping, resulting in a nonlinear suppression matrix. The hyperbolic tangent function possesses unique extreme value saturation compression characteristics. When a local region is a smooth, unstructured, intense highlight, the local geometric abrupt change approaches the minimum constant infinitely, causing a sharp increase in the local brightness quotient, which the hyperbolic tangent function forces to compress to the saturation asymptote. Conversely, for real fracture contours with significant physical geometric changes, the quotient decreases and falls into the linear amplification region of the function. The local contrast matrix acts as a reverse damper here, ensuring that regions with weaker geometric abrupt changes experience stronger suppression and compression.
[0027] Finally, the amplitude projection matrix and the nonlinear suppression matrix are multiplied element-wise to generate the enhanced image matrix. This cross-product utilizes the nonlinear suppression matrix to perform spatial mask modulation on the amplitude projection matrix, further suppressing the false large-area refractive highlights caused by the transparent material and highlighting the true physical boundaries of the microneedle geometry. The formula used is: In the formula, To enhance the feature values of corresponding pixels in the image matrix, These are the values of each pixel in the original image matrix. These are the values for each pixel in the local contrast matrix. This is a preset minimum constant to prevent boundary overflow.
[0028] In this system, the feature values of corresponding pixels in the enhanced image matrix are used to quantify the salience of the physical boundary of the microneedle; a larger value indicates the presence of geometric defects such as broken needles or bubbles, while a smaller value indicates a smooth, transparent substrate or background light spots. The original image matrix values positively drive the amplitude of the basic features, while the local contrast matrix values serve as independent variables reflecting the intensity of local geometric deformation abrupt changes. When local abrupt changes are weak, the quotient of the two increases, and the hyperbolic tangent function's extreme value saturation strongly suppresses smooth highlights; when there are local abrupt changes, the quotient decreases and falls into the linear amplification region to highlight the contour. The square root operator in the denominator adaptively balances the dynamic range, and the minimum constant prevents out-of-bounds errors, eliminates computational singularities, and filters out optical noise, transforming discrete light intensity into a physical boundary index resistant to refraction interference.
[0029] Step 2: Construct a dual-branch convolutional network. Input the enhanced image matrix into the dual-branch convolutional network, control the dual-branch convolutional network to extract the fracture edge scene features indicating entity defects in the enhanced image matrix to generate an edge feature matrix, and control the dual-branch convolutional network to extract the optical texture scene features indicating background interference to generate a texture feature matrix.
[0030] In complex spatial distributions, the physical fracture contours caused by physical defects and the optical refraction textures induced by the transparent matrix itself still exist within the same data dimension. If a single network channel is used to extract features, it is easy for high-frequency geometric deformations and low-frequency optical interferences to be homogenized and fitted, resulting in feature confusion. Based on this physical layering logic, this embodiment configures a first convolutional kernel weight matrix and a first bias term vector in the first branch network. The enhanced image matrix and the first convolutional kernel weight matrix are subjected to spatial sliding window convolution operation, and the first bias term vector is superimposed to obtain the first intermediate response matrix. In the actual optical performance of micro-needle patches, physical defects such as broken needles, defects, or micro-bubbles are often accompanied by drastic spatial gray-level jumps. The essence of spatial sliding window convolution operation is to use the convolutional kernel as a directional filter to scan and capture such drastic physical boundary changes across the entire image. The first intermediate response matrix reflects the spatial matching degree between the local pixel arrangement of the input image and the preset physical fracture pattern. The closer the local gray-level jump pattern in the enhanced image matrix matches the arrangement pattern of the first convolutional kernel weight matrix, the more positively linearly amplified the response value of the dot product accumulation output.
[0031] A nonlinear activation function is used to map the first intermediate response matrix, truncating negative response noise and extracting features representing high-frequency geometric abrupt changes in the fracture edge scene to generate an edge feature matrix. In the convolutional response of edge detection, negative features typically correspond to a smooth background transition or ineffective optical dark current noise, which are opposite to the target defect. This embodiment uses a linear rectified function as the nonlinear activation function, whose logic ensures that any negative input less than zero is absolutely zero-correlated with the final output, i.e., it is completely truncated and forced to zero; only positive high-frequency geometric abrupt change signals are retained. This operation clears redundant computational values and establishes a geometric benchmark for identifying true defects.
[0032] In the second branch network, a second convolutional kernel weight matrix and a second bias term vector, independent of the first branch network, are configured. The enhanced image matrix and the second convolutional kernel weight matrix are then subjected to a spatial sliding window convolution operation, and the second bias term vector is superimposed to obtain a second intermediate response matrix. A nonlinear activation function is then used to map the second intermediate response matrix, extracting optical texture scene features representing light refraction and background light spots, generating a texture feature matrix. Under illumination, the transparent matrix of the micro-needle patch produces a large area of low-frequency halo and irregular refractive light spots. The generated texture feature matrix essentially constructs an accurate background noise template, further preventing non-destructive optical spots from being misjudged as physical broken needles.
[0033] To ensure the dual-branch network can accurately target and capture the aforementioned physical features, this embodiment extracts the physical fracture surface of a real single broken microneedle under an industrial microscope, measures the average pixel width occupied in the image and takes an odd number, and calibrates the receptive field size of the first convolutional kernel weight matrix to 3×3 pixels; it also calculates the average diffusion radius of the high-refraction patches formed by the transparent matrix and takes an odd number, calibrating the receptive field size of the second convolutional kernel weight matrix to 7×7 pixels. The first branch uses a small-sized convolutional kernel to finely capture the weak needle tip fracture edge and prevent small features from being over-smoothed; the second branch uses a large-sized convolutional kernel to overcome local abrupt changes and perceive the diffusion texture of the background light spots holistically.
[0034] Step 3: Calculate the spatial overlap and distance distribution similarity between the edge feature matrix and the texture feature matrix, and obtain the spatial mean to generate the decoupling loss value. During model training, the decoupling loss value is used to force the scene object features extracted by the dual-branch convolutional network to be independent of each other.
[0035] In a dual-branch network structure, the high-intensity optical refraction spots generated by microneedles attached to a transparent matrix often spatially cover a large area of the actual broken needle geometric defects. Deep convolutional layers in their naturally optimized state are prone to falling into gradient homogenization traps, causing both branches to simultaneously tend to fit the most significant specular features, resulting in feature collapse and confusion. To address this, this embodiment constructs decoupled computational logic during the model training phase. By quantifying the overlap and similarity between the two branches, a decoupled loss value is generated. During backpropagation, a penalty gradient is applied, forcing the first branch to exclusively extract pure fracture geometric features, while the second branch exclusively extracts optical texture features, ensuring that the extracted scene object features are independent of each other.
[0036] At the level of evaluating feature space co-occurrence, the edge feature matrix and texture feature matrix are multiplied element-wise and their absolute values are extracted to obtain the coupling absolute value matrix. The coupling absolute value matrix is then summed element-wise with the numerical value to obtain the overlap variable matrix. The natural logarithm is extracted from each element in the overlap variable matrix to calculate the spatial overlap matrix that represents the local coupling strength of the features.
[0037] The spatial overlap matrix reflects the feature activation superposition state of the two branches at the same pixel coordinates. The element-wise absolute product of the edge feature matrix and the texture feature matrix constitutes a nonlinear intersection probe operator. Since the two types of physical features should be spatially mutually exclusive, the product result increases dramatically when both produce strong responses at the same coordinate. The addition operation ensures that the true value of the logarithm calculation is always positive, while the natural logarithm operator, with its mathematical property of gradually slowing down the growth rate on the positive half-axis, applies smooth compression to extreme co-activated pixels. The value of the spatial overlap matrix is positively nonlinearly correlated with the product of the response amplitudes of the two branch feature matrices; that is, the stronger the co-occurrence feature, the larger the spatial overlap penalty value.
[0038] To assess the convergence of feature numerical evolution, the absolute value matrices of the edge feature matrix and the texture feature matrix are obtained separately. The element-wise differences between the edge and texture feature matrices are calculated, and their absolute values are extracted to obtain the feature difference matrix. The absolute value matrices of the edge and texture feature matrices are then added element-wise to a preset minimum constant to obtain a feature normalization denominator matrix. The feature difference matrix is then divided element-wise by the feature normalization denominator matrix to obtain the quotient matrix. The negatives of each element in the quotient matrix are extracted to construct an negative number matrix, which is then used as the input parameter of the natural exponential function for mapping, resulting in a distance distribution similarity matrix that characterizes the degree of approximation of feature numerical distributions. This distance distribution similarity matrix reflects the convergence level of the absolute numerical amplitudes of the two-branch features. Using the sum of the absolute values of the two features as the denominator, the absolute difference is normalized by division, eliminating scale interference caused by the absolute magnitude of the features. The natural exponential function, in conjunction with the inverse matrix, reverses the mapping polarity: when the feature values of the two branches are highly similar (the absolute difference is extremely small, and the quotient approaches 0), the inverse approaches 0, and the output of the natural exponential function approaches the maximum value of 1, thereby imposing a strong homogenization rejection penalty.
[0039] Finally, the spatial overlap matrix and the distance distribution similarity matrix are multiplied element-wise to generate an intermediate penalty matrix. The arithmetic mean of all elements in the intermediate penalty matrix is calculated along the spatial dimension to perform feature dimensionality reduction and generate the decoupling loss value. The formula used is: In the formula, This is the decoupling loss value. These are the feature values of the corresponding pixels in the edge feature matrix. These are the feature values of the corresponding pixels in the texture feature matrix. To pre-determine the minimum constant to prevent out-of-bounds access, This is an operation to calculate the arithmetic mean of all elements along a spatial dimension.
[0040] The decoupling loss value characterizes the degree of spatial and numerical entanglement in the network feature extraction. A larger decoupling loss value indicates that the optical refraction and solid fracture of the transparent matrix are homogenized and fitted, while a smaller value indicates that they have been separated into independent orthogonal physical representations. The numerical values of edge features and texture features respectively map the intensity of local geometric mutations and optical interference. The absolute product of the two positively drives the overlap penalty; the stronger the co-occurrence activation at the same coordinates, the more the penalty increases smoothly with the logarithm. The absolute difference between the two negatively constrains the similarity matrix; the more similar the magnitudes, the closer the exponential function output approaches its maximum value to apply repulsion. This formula cuts off the physical masking of the broken needle outline by background stray light, eliminates division-zero singularities with a minimal constant, and achieves independent decoupling of heterogeneous physical features.
[0041] Step 4: Cross-fuse the edge feature matrix and the texture feature matrix. Using the edge feature matrix as the amplitude basis, convert the texture feature matrix into a phase bias for cross-modulation calculation, and output a defect fusion feature matrix with the same spatial dimension as the real defect label matrix.
[0042] In the actual physical detection environment of microneedle patches, the authenticity determination of tiny broken needles cannot be completely separated from their optical background. If conventional feature channel splicing or algebraic linear addition is used for fusion, the strong light spot features that have been separated are easily overwhelmed by the weak broken needle features at the output end. Based on this physical interference logic, this embodiment calculates the element-wise squares of the edge feature matrix and the texture feature matrix respectively to obtain the edge feature square matrix and the texture feature square matrix; the edge feature square matrix, the texture feature square matrix and the preset anti-cross-boundary minimum constant are added element-wise and the square root is extracted to obtain the basis denominator matrix; the edge feature square matrix and the basis denominator matrix are divided element-wise to calculate the amplitude basis. Among them, the squaring operation unifies the gradient response in a single direction into a positive physical energy scale. The basis denominator matrix essentially calculates the sum of the global composite perturbation energy in the local space. Dividing the edge energy (edge feature square matrix) by the global total energy aims to calculate the absolute energy distribution ratio occupied by the broken feature in the local optical environment. This amplitude base establishes the basic weights of the fusion output: when the texture background energy is extremely high in a local area, the denominator increases dramatically, automatically reducing the output amplitude of edge features, thus achieving adaptive energy suppression in areas with strong light spot interference.
[0043] The absolute value of the texture feature matrix is extracted to obtain the absolute value texture matrix. The absolute value texture matrix is then summed element-wise with the numerical value to obtain the bias denominator matrix. The edge feature matrix is then divided element-wise with the bias denominator matrix to obtain the bias quotient matrix. Each element of the bias quotient matrix is used as input parameters for a sine function for nonlinear mapping to calculate the phase bias. Adding one to the absolute value texture matrix as the denominator ensures that when the background texture light spots are extremely strong, the denominator increases sharply, and the bias quotient is strongly compressed; if the background is clean, the denominator approaches one, and the edge features are fully transmitted. Furthermore, utilizing the quasi-linearity of the sine operator near the origin and its bounded saturation at extrema, infinitely divergent optical interference is mapped to the bounded trigonometric function domain, transforming the background interference into a smoothly fluctuating phase angle offset, preventing numerical overflow caused by extremely strong local stray light.
[0044] Finally, the amplitude basis and phase bias are multiplied element-wise to complete the cross-modulation calculation and generate the defect fusion feature matrix. The formula used is: In the formula, These are the feature values of the corresponding pixels in the defect fusion feature matrix. These are the feature values of the corresponding pixels in the edge feature matrix. To pre-determine the minimum constant to prevent out-of-bounds access, This represents the feature value of the corresponding pixel in the texture feature matrix.
[0045] In this matrix, the feature values of corresponding pixels in the defect fusion feature matrix represent the absolute intensity of the physical defects of the microneedles after modulation; a larger value indicates the presence of a real physical fracture that penetrates stray light, while a smaller value indicates a transparent substrate or pure optical artifact. Edge and texture feature values map the energy of local geometric abrupt changes and the intensity of environmental optical interference, respectively. Edge features positively drive substrate energy and phase angle shift; a larger value results in a sharper contour. The absolute value of texture features, as a double denominator, constructs natural optical damping, which in turn constrains the fusion result; stronger refraction leads to more severe suppression. This formula transforms optical interference into nonlinear damping for cross-modulation, avoiding feature submersion caused by linear superposition, stripping away the background stray light masking effect, and realistically restoring the morphology of the tiny broken needles.
[0046] Step 5: Calculate the pixel-wise error matrix between the defect fusion feature matrix and the real defect label matrix to obtain the classification loss. After obtaining the spatial mean, add the classification loss and decoupling loss values according to the preset weight to calculate the total loss value. Backpropagation completes the construction of the defect detection model. Input the micro-needle patch image to be tested into the defect detection model and output the manufacturing defect category and spatial positioning boundary results.
[0047] The defect fusion feature matrix, as the output of the network's forward propagation, is essentially an unverified open-loop feature map. To ensure that this mathematical spatial distribution accurately matches the actual physical defect boundaries of the microneedle patch, a defined supervisory label needs to be introduced as an absolute benchmark for error measurement. The classification loss is used to quantify the absolute deviation between the predicted results and the manually labeled data in physical space; while the total loss value is constructed to deeply couple the core task of enhancing defect recognition accuracy with the orthogonal constraint task of maintaining mutually exclusive and independent bi-branch features into a globally unique mathematical penalty scale. Finally, backpropagation is performed based on this total loss value, transforming the abstract spatial prediction error into gradient update momentum to guide parameter iteration, forcing the convolutional kernel weights of each branch to adaptively converge to the optimal feature extraction space.
[0048] The element-wise difference between the defect fusion feature matrix and the true defect label matrix is calculated to obtain the pixel-wise error matrix. The squared value of each element in the pixel-wise error matrix is then obtained to construct the error squared matrix. The pixel-wise error matrix intuitively reflects the spatial deviation between the network's predicted location and the actual microneedle breakage location. The squaring operation aims to eliminate the directional cancellation of positive and negative errors, uniformly mapping all prediction deviations as positive energy loss. Each element in the pixel-wise error matrix is used as the input parameter of a hyperbolic cosine function for nonlinear mapping to calculate the cosine penalty matrix. The error squared matrix and the cosine penalty matrix are then multiplied element-wise to generate the spatial classification loss matrix. The arithmetic mean of all elements in the spatial classification loss matrix is calculated along the spatial dimension for dimensionality reduction, resulting in the scalar classification loss. The square of the decoupling loss value is then calculated to obtain the decoupling squared term. The decoupling squared term is multiplied by a preset weight to obtain the weighted decoupling penalty value. The classification loss and the weighted decoupling penalty value are then arithmetically added to obtain the total loss value. Given the significant difference in initial gradient magnitudes between the primary task of defect localization and the auxiliary constraint of feature decoupling during backpropagation, directly weighting them equally could easily lead to interference with the parameter update direction of the primary task by the constraint terms. Therefore, during the model warm-up training phase, the absolute values of the initial in-batch classification loss and decoupling loss are extracted, their ratio is calculated, and multiplied by a down-adjustment decay coefficient based on the primary task priority principle, setting this preset weight to 0.2. This further ensures that a suitable orthogonal repulsive force is applied to the network without weakening the dominant role of microneedle classification and detection. The specific formula for calculating the total loss value is as follows: In the formula, This is the total loss value. This is an operation to calculate the arithmetic mean of all elements along a spatial dimension. This represents the predicted value of the corresponding pixel in the defect fusion feature matrix. This represents the absolute supervision value of the corresponding pixel in the actual defect label matrix. To preset weights, This represents the decoupling loss value.
[0049] The total loss value represents the combined severity of the deviation between the predicted output and the actual physical defects. A larger value indicates serious missed detections, false positives, and feature confusion, while a smaller value indicates that the model has accurately captured the microneedle breakage pattern. The spatial absolute deviation between the predicted value and the label positively drives the classification loss. The hyperbolic cosine function, combined with squaring, applies only gentle constraints to minor edge blurring, while imposing exponentially increasing penalties for malicious deviations such as missed needle breakages or false spot detections, forcing computing power to focus on high-difficulty defects. The decoupled loss square term is independently accessed as an orthogonal constraint, utilizing its zero-to-zero smoothing characteristic to avoid optimization oscillations. This formula effectively balances the defect detection rate and feature purity, ensuring that the calculated mathematical deviation can be effectively transformed into an effective gradient for correcting the underlying weights.
[0050] After obtaining the total loss value, the specific steps for backpropagation to complete the defect detection model construction are as follows: Obtain the first convolutional kernel weight matrix and first bias term vector of the first branch network in the dual-branch convolutional network, and the second convolutional kernel weight matrix and second bias term vector of the second branch network, as the model parameters to be updated. Based on the chain rule, calculate the partial derivative of the total loss value with respect to each model parameter to be updated, and obtain the parameter gradient matrix with the same dimension as each model parameter to be updated; this gradient matrix indicates the optimal parameter adjustment direction to reduce prediction error.
[0051] Subsequently, a preset learning rate hyperparameter is introduced, and combined with the parameter gradient matrix, the adaptive gradient descent optimization algorithm is used to perform reverse iterative updates on the parameters of the model to be updated. To enable the calculation of independent adaptive update step sizes for each model parameter based on the first and second momentum of the gradient, this embodiment uses the Adam (Adaptive Moment Estimator) optimizer to perform reverse iterative updates on the parameters of the model to be updated. This mechanism effectively avoids update stagnation or divergence caused by a single learning rate when dealing with sparsely distributed real defect gradients in microneedle images, further improving the network's optimization efficiency under complex lighting and shadow perturbations. Since the learning rate determines the single-step update span of the model parameters under gradient guidance, an excessively large span can easily cause the parameters to oscillate violently near the optimal solution, while an excessively small span can easily cause the network to get trapped in local minima. This embodiment extracts the underlying calibration baseline value of the adaptive gradient descent optimizer in the deep learning framework and constructs a cosine annealing decay strategy based on the total iteration period to dynamically adjust the initial value, setting the learning rate hyperparameter to... This ensures that the model can smoothly avoid local error traps and stably converge to the optimal parameter space with the minimum global error when faced with complex background light spot interference from micropatch.
[0052] The enhanced image matrix is used as the input parameter for model training, the real defect label matrix is used as the supervision label for model training, and the corresponding generated defect fusion feature matrix is used as the output parameter for the network's forward prediction. The forward feature extraction calculation and backward iterative update steps are repeatedly executed. When the total loss value decreases and converges to a preset threshold range, or when the number of iterations reaches a preset maximum iteration cycle, the update stops and the current first convolutional kernel weight matrix, first bias term vector, second convolutional kernel weight matrix, and second bias term vector are saved as the fixed network parameters of the dual-branch convolutional network, completing the defect detection model construction. However, if the neural network iterates without restriction, it is prone to forcibly memorizing specific background stray noise points in the training set images instead of the actual physical fracture patterns, leading to severe overfitting. Therefore, this embodiment calculates the upper limit of iteration based on the total size of the micro-needle patch training sample dataset and the memory throughput of the computing hardware, and calibrates the lower limit of error convergence using an early stopping tolerance mechanism in engineering practice. The maximum iteration cycle is set to 250 times, and the threshold range is set to a value where the absolute fluctuation of the total loss value within 10 consecutive validation cycles is less than... This effectively ensures the model's true generalization detection capability when faced with unknown micropatch images.
[0053] Finally, the image of the industrial micro-needle patch to be tested is input into the cured defect detection model for forward reasoning, and the manufacturing defect category and spatial positioning boundary results are output, thereby achieving accurate physical positioning and rejection of unqualified micro-needle patch products.
[0054] Table 1 is an example table of the comprehensive data of the full-link physical feature response and spatial classification penalty evolution of the micro-needle patch image under 25 discrete pixel sample points.
[0055] Table 1: Comprehensive Data Table of Multidimensional Feature Response and Spatial Classification Loss of Microneedle Patches Table 1 shows the performance of this method in decoupling and correcting features of real defects under complex optical backgrounds. For pixel samples 1 and 2, although their original image matrix values are greater than 0.75, the texture feature matrix values decoupled by the network are both higher than 0.82 due to the weak local geometric deformation. Under the cross-modulation operation, the defect fusion feature matrix values of these two points are forcibly suppressed to below 0.003, effectively eliminating the artifact interference caused by strong refractive spots. In contrast, the local contrast matrix values of pixel samples 3 and 9 suddenly increase to above 0.7, driving the edge feature matrix value to exceed 0.8, explicitly characterizing the actual fracture of the needle. Under the adjustment of the sinusoidal damping term, the defect fusion feature matrix values of these two points are stably output to above 0.5, realizing the smooth activation of defect features. In addition, for the extreme missed detection case of sample 7 (the defect fusion feature matrix value abnormally drops to 0.0135), the hyperbolic cosine operator nonlinearly amplifies its spatial absolute deviation, causing the spatial classification loss matrix value to surge to 1.4862, triggering the heavy penalty mechanism of network parameters. The table demonstrates that this method can accurately filter out optical artifacts and apply an exponential gradient drive to the underreporting bias, thus solving the technical problem of traditional networks easily confusing light spots with real defects.
[0056] Please see Figure 3 The present invention also provides a microneedle patch defect detection model construction system, which is used to implement the above-mentioned microneedle patch defect detection model construction method, including: The contrast enhancement module is used to obtain the original image matrix of the micro-needle patch and the real defect label matrix with the coordinates and categories of the defect area. It extracts the local contrast matrix of the original image matrix, constructs the enhancement logic based on the hyperbolic tangent function and the square term of the local contrast matrix, and performs highlight suppression and solid contour enhancement on the original image matrix to generate the enhanced image matrix. The dual-branch extraction module is used to construct a dual-branch convolutional network. The enhanced image matrix is input into the dual-branch convolutional network, and the dual-branch convolutional network is controlled to extract the fracture edge scene features indicating entity defects in the enhanced image matrix to generate an edge feature matrix. The dual-branch convolutional network is also controlled to extract the optical texture scene features indicating background interference to generate a texture feature matrix. The decoupling loss module is used to calculate the spatial overlap and distance distribution similarity between the edge feature matrix and the texture feature matrix, and to calculate the spatial mean to generate the decoupling loss value. During model training, the decoupling loss value is used to force the scene object features extracted by the dual-branch convolutional network to be independent of each other. The cross-modulation module is used to cross-fuse the edge feature matrix and the texture feature matrix. Using the edge feature matrix as the amplitude basis, the texture feature matrix is converted into a phase bias for cross-modulation calculation, and the output is a defect fusion feature matrix with the same spatial dimension as the real defect label matrix. The model building module is used to calculate the pixel-wise error matrix between the defect fusion feature matrix and the real defect label matrix to obtain the classification loss. After obtaining the spatial mean, the classification loss and decoupling loss values are superimposed according to the preset weight to calculate the total loss value. Backpropagation completes the construction of the defect detection model. The micro-needle patch image to be tested is input into the defect detection model, and the manufacturing defect category and spatial positioning boundary results are output.
[0057] The above formulas are all dimensionless calculations. The formulas are derived from software simulations using a large amount of collected data, and are the closest to the real situation. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.
[0058] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented in software, the above embodiments can be implemented, in whole or in part, as a computer program product. Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution.
[0059] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0060] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A method for constructing a defect detection model for microneedle patches, characterized in that, The specific steps include: Obtain the original image matrix of the micro-needle patch and the real defect label matrix with the coordinates and categories of the defect area. Extract the local contrast matrix of the original image matrix. Construct enhancement logic based on the hyperbolic tangent function and the square term of the local contrast matrix. Perform highlight suppression and solid contour enhancement on the original image matrix to generate the enhanced image matrix. A dual-branch convolutional network is constructed. The enhanced image matrix is input into the dual-branch convolutional network. The dual-branch convolutional network is controlled to extract the fracture edge scene features indicating entity defects in the enhanced image matrix to generate an edge feature matrix. The dual-branch convolutional network is also controlled to extract the optical texture scene features indicating background interference to generate a texture feature matrix. Calculate the spatial overlap and distance distribution similarity between the edge feature matrix and the texture feature matrix, and obtain the spatial mean to generate the decoupling loss value. During model training, the decoupling loss value is used to force the scene object features extracted by the dual-branch convolutional network to be independent of each other. The edge feature matrix and texture feature matrix are cross-fused. The edge feature matrix is used as the amplitude basis, and the texture feature matrix is converted into a phase bias for cross-modulation calculation. The output is a defect fusion feature matrix with the same spatial dimension as the real defect label matrix. The pixel-wise error matrix between the defect fusion feature matrix and the real defect label matrix is calculated to obtain the classification loss. After obtaining the spatial mean, the classification loss and decoupling loss values are superimposed according to the preset weight to calculate the total loss value. Backpropagation completes the construction of the defect detection model. The micro-needle patch image to be tested is input into the defect detection model, and the manufacturing defect category and spatial positioning boundary results are output.
2. The method for constructing a microneedle patch defect detection model according to claim 1, characterized in that: The specific steps for obtaining the original image matrix, the true defect label matrix, and extracting the local contrast matrix are as follows: The initial image of the micro-needle patch is subjected to grayscale conversion and interval normalization to generate an original image matrix with values ranging from 0 to 1. Extract the bounding box coordinates and defect categories of the manually labeled micro-needle patch data, and perform pixel-level mask mapping in the feature space with the same spatial dimension as the original image matrix to generate a real defect label matrix. Set a local sliding window of a preset size and traverse the original image matrix. Calculate the absolute difference between each pixel and the mean value of its neighboring pixels within the corresponding local sliding window to construct a local contrast matrix.
3. The method for constructing a microneedle patch defect detection model according to claim 2, characterized in that: The specific steps for generating the enhanced image matrix are as follows: Obtain the square value of each pixel in the original image matrix to construct the first square matrix, obtain the square value of each pixel in the local contrast matrix to construct the second square matrix, calculate the square root of the sum of the first square matrix, the second square matrix and the preset anti-boundary minimum constant, divide the first square matrix by the square root element by element, and calculate the amplitude projection matrix. The local contrast matrix is summed element-wise with the preset anti-boundary minimum constant, and the original image matrix is divided element-wise by the summation result to obtain the local brightness quotient matrix. Each element in the local brightness quotient matrix is used as the input parameter of the hyperbolic tangent function for nonlinear mapping to calculate the nonlinear suppression matrix. The enhanced image matrix is generated by performing element-wise multiplication of the amplitude projection matrix and the nonlinear suppression matrix.
4. The method for constructing a microneedle patch defect detection model according to claim 1, characterized in that: A two-branch convolutional network consists of a first branch network and a second branch network configured in parallel. The specific steps for generating the edge feature matrix are as follows: In the first branch network, the first convolution kernel weight matrix and the first bias term vector are configured. The enhanced image matrix and the first convolution kernel weight matrix are subjected to spatial sliding window convolution operation and the first bias term vector is superimposed to obtain the first intermediate response matrix. The first intermediate response matrix is mapped using a nonlinear activation function to truncate negative response noise, extract the fracture edge scene features that characterize high-frequency geometric changes, and generate the edge feature matrix. The specific steps for generating the texture feature matrix are as follows: In the second branch network, a second convolution kernel weight matrix and a second bias term vector, independent of the first branch network, are configured. The enhanced image matrix and the second convolution kernel weight matrix are subjected to spatial sliding window convolution operation and the second bias term vector is superimposed to obtain the second intermediate response matrix. The second intermediate response matrix is mapped using a nonlinear activation function to extract optical texture scene features that characterize light refraction and background light spots, and generate a texture feature matrix.
5. The method for constructing a microneedle patch defect detection model according to claim 1, characterized in that: The specific steps for generating the decoupling loss value are as follows: The edge feature matrix and texture feature matrix are multiplied element-wise and their absolute values are extracted to obtain the coupling absolute value matrix. The coupling absolute value matrix is summed element-wise with the numerical value to obtain the overlap variable matrix. The natural logarithm is extracted from each element in the overlap variable matrix to calculate the spatial overlap matrix that represents the local coupling strength of the features. Obtain the absolute value matrix of the edge feature matrix and the absolute value matrix of the texture feature matrix respectively, calculate the element-wise difference between the edge feature matrix and the texture feature matrix and extract the absolute value to obtain the feature difference matrix; The absolute value matrix of the edge feature matrix, the absolute value matrix of the texture feature matrix, and the preset anti-boundary minimum constant are added element by element to obtain the feature normalization denominator matrix. The feature difference matrix is divided element by element by the feature normalization denominator matrix to obtain the quotient matrix. The opposite number of each element in the quotient matrix is extracted to construct the opposite number matrix. The opposite number matrix is used as the input parameter of the natural exponential function for mapping, and the distance distribution similarity matrix representing the approximation of the feature numerical distribution is calculated. The spatial overlap matrix and the distance distribution similarity matrix are multiplied element-wise to generate an intermediate penalty matrix. The arithmetic mean of all elements in the intermediate penalty matrix is calculated along the spatial dimension to perform feature dimensionality reduction and generate a decoupling loss value.
6. The method for constructing a microneedle patch defect detection model according to claim 1, characterized in that: The specific steps for outputting the defect fusion feature matrix are as follows: Calculate the element-wise squares of the edge feature matrix and the texture feature matrix respectively to obtain the edge feature square matrix and the texture feature square matrix; The edge feature square matrix, texture feature square matrix, and preset anti-boundary minimum constant are added element-wise and their square roots are extracted to obtain the basis denominator matrix. The edge feature square matrix and the basis denominator matrix are then divided element-wise to calculate the amplitude basis. Extract the absolute value of the texture feature matrix to obtain the absolute value texture matrix. Summate the absolute value texture matrix with the numerical value one element by element to obtain the bias denominator matrix. Divide the edge feature matrix with the bias denominator matrix element by element to obtain the bias quotient matrix. Each element in the bias quotient matrix is used as the input parameter of the sine function for nonlinear mapping to calculate the phase bias. The amplitude basis and the phase bias are then multiplied element by element to complete the cross-modulation calculation and generate the defect fusion feature matrix.
7. The method for constructing a microneedle patch defect detection model according to claim 4, characterized in that: The specific steps for calculating the total loss value are as follows: Calculate the element-wise difference between the defect fusion feature matrix and the real defect label matrix to obtain the pixel-wise error matrix, and obtain the square value of each element in the pixel-wise error matrix to construct the error square matrix. Each element in the pixel-wise error matrix is used as the input parameter of the hyperbolic cosine function for nonlinear mapping to obtain the cosine penalty matrix. The error square matrix and the cosine penalty matrix are then multiplied element-wise to generate the spatial classification loss matrix. The arithmetic mean of all elements in the spatial classification loss matrix is calculated along the spatial dimension to reduce dimensionality, and the scalar classification loss is obtained. The square of the decoupling loss value is calculated to obtain the decoupling squared term. The decoupling squared term is multiplied by the preset weight to obtain the weighted decoupling penalty value. The classification loss is arithmetically added to the weighted decoupling penalty value to calculate the total loss value.
8. The method for constructing a microneedle patch defect detection model according to claim 7, characterized in that: Backpropagation completes the construction of the defect detection model. The specific steps include: Obtain the first convolutional kernel weight matrix and the first bias term vector of the first branch network in the dual-branch convolutional network, and the second convolutional kernel weight matrix and the second bias term vector of the second branch network, as the model parameters to be updated; Based on the chain rule, the partial derivatives of the total loss value with respect to the parameters of each model to be updated are calculated to obtain the parameter gradient matrix with the same dimension as the parameters of each model to be updated. Introducing a preset learning rate hyperparameter, and combining it with the parameter gradient matrix, the adaptive gradient descent optimization algorithm is used to iteratively update the parameters of the model to be updated. The enhanced image matrix is used as the input parameter for model training, the real defect label matrix is used as the supervision label for model training, and the corresponding generated defect fusion feature matrix is used as the output parameter for the forward prediction of the network. The forward feature extraction calculation and backward iterative update steps are repeated. When the total loss value decreases and converges to the preset threshold range, or when the number of iterations reaches the preset maximum iteration period, the update stops and the current first convolution kernel weight matrix, first bias term vector, second convolution kernel weight matrix, and second bias term vector are saved as the fixed network parameters of the dual-branch convolutional network, thus completing the construction of the defect detection model.
9. A microneedle patch defect detection model construction system, characterized in that: The microneedle patch defect detection model construction system is used to implement the microneedle patch defect detection model construction method according to any one of claims 1-8, including: The contrast enhancement module is used to obtain the original image matrix of the micro-needle patch and the real defect label matrix with the coordinates and categories of the defect area. It extracts the local contrast matrix of the original image matrix, constructs the enhancement logic based on the hyperbolic tangent function and the square term of the local contrast matrix, and performs highlight suppression and solid contour enhancement on the original image matrix to generate the enhanced image matrix. The dual-branch extraction module is used to construct a dual-branch convolutional network. The enhanced image matrix is input into the dual-branch convolutional network, and the dual-branch convolutional network is controlled to extract the fracture edge scene features indicating entity defects in the enhanced image matrix to generate an edge feature matrix. The dual-branch convolutional network is also controlled to extract the optical texture scene features indicating background interference to generate a texture feature matrix. The decoupling loss module is used to calculate the spatial overlap and distance distribution similarity between the edge feature matrix and the texture feature matrix, and to calculate the spatial mean to generate the decoupling loss value. During model training, the decoupling loss value is used to force the scene object features extracted by the dual-branch convolutional network to be independent of each other. The cross-modulation module is used to cross-fuse the edge feature matrix and the texture feature matrix. Using the edge feature matrix as the amplitude basis, the texture feature matrix is converted into a phase bias for cross-modulation calculation, and the output is a defect fusion feature matrix with the same spatial dimension as the real defect label matrix. The model building module is used to calculate the pixel-wise error matrix between the defect fusion feature matrix and the real defect label matrix to obtain the classification loss. After obtaining the spatial mean, the classification loss and decoupling loss values are superimposed according to the preset weight to calculate the total loss value. Backpropagation completes the construction of the defect detection model. The micro-needle patch image to be tested is input into the defect detection model, and the manufacturing defect category and spatial positioning boundary results are output.
