Transfusion medicine foreign matter and consistency detection method based on image recognition
By combining multispectral image acquisition with deep learning and machine learning, the problems of low efficiency in manual inspection and insufficient image recognition methods in infusion drug testing have been solved. This has enabled efficient and accurate foreign object detection and drug consistency verification, ensuring the quality and safety of infusion drugs.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-19
- Publication Date
- 2026-03-27
AI Technical Summary
Existing methods for detecting infusion drugs rely on manual visual inspection, which is inefficient, susceptible to human influence, and inaccurate. Image recognition methods have shortcomings in lighting conditions and image preprocessing, making it difficult to effectively detect foreign objects and ensure drug consistency.
Using a 20-megapixel industrial camera paired with a multispectral composite light source module, combined with deep learning target detection algorithms and machine learning feature matching models, foreign objects are identified and located through multispectral image acquisition, denoising, enhancement, and correction processing. The drug characteristic parameters are analyzed by comparing them with the expected formula, and the illumination conditions and denoising threshold are dynamically adjusted to optimize the detection model and improve accuracy.
It enables efficient and accurate detection of foreign objects in infusion drugs and consistency verification, improves detection efficiency and accuracy, reduces missed detections and false detections, and ensures the reliability and consistency of drug quality.
Smart Images

Figure CN121746338A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image recognition technology, specifically a method for detecting foreign bodies and consistency in infusion drugs based on image recognition. Background Technology
[0002] In the medical field, the quality of intravenous medications directly affects patient safety and treatment outcomes. However, during the production, transportation, and storage of intravenous medications, foreign substances such as impurities and microorganisms may be introduced for various reasons. These foreign substances not only affect the efficacy of the medication but may also cause serious health hazards to patients. At the same time, ensuring that the actual prepared medication matches the intended formula is crucial for guaranteeing the therapeutic effect and safety of the medication.
[0003] Currently, traditional methods for detecting foreign bodies in infusion drugs mainly rely on manual visual inspection, which has many limitations. Manual inspection is inefficient, cannot meet the needs of large-scale production, and is easily affected by factors such as personnel fatigue and experience, leading to inaccurate test results, with frequent missed and false detections. In addition, for the detection of drug consistency, traditional methods often require complex chemical analysis, which is cumbersome, time-consuming, and requires a high level of technical expertise from the testing personnel.
[0004] On the other hand, with the continuous development of image recognition technology, image recognition-based detection methods are gradually being applied to various fields. However, although the existing image recognition-based infusion drug detection methods have high detection efficiency, they are not reasonable in terms of lighting conditions and are difficult to highlight the feature differences of different substances in the image. The image preprocessing algorithm is not perfect and cannot effectively remove noise, enhance features and correct image deformation.
[0005] Therefore, the present invention provides a method for detecting foreign objects and consistency in infusion drugs based on image recognition. Summary of the Invention
[0006] In order to overcome the shortcomings of the prior art, at least one technical problem raised in the background art is solved.
[0007] The technical solution adopted by this invention to solve its technical problem is: a method for detecting foreign bodies and consistency of infusion drugs based on image recognition, comprising the following steps:
[0008] S1. Acquiring images of infusion drugs: Using a 20-megapixel industrial camera, paired with a multispectral composite light source module, images of infusion drugs are acquired from multiple lighting conditions and different shooting angles to obtain a raw image dataset containing the overall and local details of the drugs.
[0009] S2. Image preprocessing: Denoising, enhancement, and correction are performed on the acquired raw image dataset to remove noise interference in the images, enhance drug feature information, and correct image distortion caused by shooting angle and lens distortion.
[0010] S3. Foreign Object Detection: Using target detection algorithms in deep learning, a detection model for foreign objects in infusion drugs is constructed. The pre-processed image is input into the model, and the model automatically identifies and locates the foreign objects in the image, while outputting the location, size and shape information of the foreign objects.
[0011] S4. Consistency Verification: Extract key feature parameters of the drug in the image, such as color, turbidity, texture, shape, particle size distribution, and transparency, and compare them with the standard feature parameters of the drug corresponding to the pre-stored expected formula.
[0012] By establishing a feature matching model based on machine learning, the similarity between the actual drug feature parameters and the standard feature parameters is calculated, and the consistency between the actual drug and the expected formula is determined based on the preset similarity threshold.
[0013] A further improvement of the present invention is that, in step S1, the spectral composite light source module includes a visible light LED lamp group of 450-650nm, a near-infrared LED lamp group of 850-1050nm, and an ultraviolet LED lamp group of 365-405nm; the light source controller supports 0-1000mA current adjustment, with a light intensity control accuracy of ±2%; six shooting positions are set around the infusion drug container, namely: 0° front view, ±30° side view, ±60° oblique view, and 90° top view; the illumination conditions are dynamically adjusted according to the type of drug solution, and the adjustment principle is:
[0014] Transparent electrolyte infusion type, visible light content 42%-48%, near-infrared light content 37%-43%, ultraviolet light content 12%-15%, exposure time 10-30ms, gain 3-6dB;
[0015] For dark-colored traditional Chinese medicine injections, the visible light content is 62%-68%, the near-infrared light content is 22%-28%, the ultraviolet light content is 12%-15%, the exposure time is 15-35ms, and the gain is 4-7dB.
[0016] For suspension infusions, the proportion of visible light is 52%-58%, the proportion of near-infrared light is 32%-38%, the proportion of ultraviolet light is 6%-9%, the exposure time is in the range of 12-32ms, and the gain is 3.5-6.5dB.
[0017] For antibiotic infusions, the proportion of visible light is 57%-63%, the proportion of near-infrared light is 27%-33%, the proportion of ultraviolet light is 13%-18%, the exposure time is 13-33ms, and the gain is 3.8-6.8dB.
[0018] A further improvement of the present invention is that, in step S2, the denoising process employs a multi-scale denoising algorithm based on wavelet transform, selecting the db4 wavelet basis function, decomposing into 3 layers, and using the Birgé-Massart strategy for threshold calculation, as detailed below:
[0019] For low-frequency components of the image: preserve the overall characteristics of the liquid medicine, and set the threshold to 0.02-0.05 times the maximum gray value of the image;
[0020] For high-frequency components of the image: distinguish noise from foreign object edges, and dynamically adjust the threshold according to the number of decomposition layers; specifically: 0.08-0.12 for the first layer, 0.05-0.08 for the second layer, and 0.03-0.05 for the third layer, to ensure that Gaussian noise is removed while retaining the edge features of foreign objects with a diameter ≥10μm;
[0021] After denoising, the image is enhanced according to the following rules:
[0022] For transparent liquid medicine: Histogram equalization with 256 gray levels is used to enhance the gray level difference between foreign objects and liquid medicine, improving contrast by 20%-30%;
[0023] For dark-colored liquid medicine: Homomorphic filtering is used, with the Gaussian filter radius controlled at 5-15px and the cutoff frequency at 0.1-0.3, to suppress the interference of liquid medicine color and enhance the reflection characteristics of foreign objects.
[0024] After enhancement processing, the image is corrected, and a distortion model library for different types of infusion container lenses is established. Different distortion parameters are obtained using a 12×12 grid calibration plate with a grid spacing of 5mm, as detailed below:
[0025] Glass bottle: A polynomial distortion model is adopted, with radial distortion coefficients k1=-0.015~-0.005, k2=0.002~0.008; tangential distortion coefficients p1=-0.001~0.001, p2=-0.001~0.001;
[0026] PVC soft bags: Perspective projection correction is used to eliminate geometric deformation caused by container wrinkles. The pixel deviation of the corrected image is ≤2px.
[0027] Non-PVC soft bags: Combining region growth algorithms, the liquid area and the edge of the bag are segmented to avoid the impact of uneven light transmission on the detection.
[0028] A further improvement of the present invention is that, in step S3, the YOLOv7 model for detecting foreign bodies in infusion drugs is improved and reconstructed, specifically as follows:
[0029] Backbone network optimization: A CBAM attention mechanism is inserted after the ELAN module of YOLOv7, with channel attention weights ranging from 0.1 to 0.9 and spatial attention convolution kernels of 3×3, enhancing the model's ability to extract features from foreign object regions and increasing the recognition weight of small targets smaller than 30px by 20%.
[0030] Anchor frame optimization: Based on the K-means clustering algorithm with 9 clusters, the foreign body annotation boxes of more than 100,000 sample images were clustered to obtain the anchor frame sizes suitable for infusion foreign bodies, which are: 12×12, 20×20, 32×32, 48×48, 64×64, 80×80, 96×96, 128×128, and 160×160, respectively, and the average IOU was improved to 0.85;
[0031] Improved loss function: The Complete-IoU loss function is adopted, combined with focusing parameters α=0.25 and γ=2.0, to solve the problem of imbalance of foreign object samples, control the proportion of foreign object region to <0.1%, and improve the convergence speed of the model by 30%.
[0032] The YOLOv7 model was trained and optimized, specifically as follows:
[0033] In a training environment with an NVIDIA A100 GPU, PyTorch 1.12 framework, batch size=16, and initial learning rate of 0.01, cosine annealing learning rate scheduling is used.
[0034] The model was trained under random conditions of random rotation from -15° to 15°, horizontal flip with a probability of 0.5, scaling from 0.8 to 1.2 times, Gaussian blur with a kernel size of 3×3 at a probability of 0.2, and brightness adjustment from -20% to 20% to enhance its generalization ability.
[0035] The training objectives were as follows: the model achieved an accuracy of over 98.2%, a recall of 92.5%, an F1 score of 95.3%, and a detection rate of 88.7% for foreign objects with a diameter of 20-25 μm on a test set with a sample size of 20,000.
[0036] Based on the mature training model above, foreign object identification is performed on the preprocessed image in step S2. The identification rules are as follows:
[0037] Canny edge detection with a threshold of 100-200 is used to extract the edge of the foreign object and calculate its curvature. If the object is identified as a foreign object, it is determined to be a foreign object if any of the following conditions are met: mean curvature > 0.8, mean curvature < 0.3, or fiber length > 200 μm.
[0038] Furthermore, based on the lens distortion model library of different types of infusion containers established in S2, the similarity between foreign objects and drug components is calculated using the Euclidean distance formula. The calculation formula is as follows:
[0039]
[0040] Where x_i is the characteristic value of the foreign object in the i-th spectral band, i=1 is visible light, i=2 is near-infrared, and i=3 is ultraviolet, and y_i is the standard value of the drug component in the corresponding spectral band. Different judgment thresholds are set for different types of infusion drugs: for transparent electrolyte infusions, when D>0.25, it is judged as a foreign object; for dark-colored traditional Chinese medicine injections, when D>0.28, it is judged as a foreign object; for suspension infusions, when D>0.22, it is judged as a foreign object; and for antibiotic infusions, when D>0.26, it is judged as a foreign object. By setting more precise judgment thresholds according to different types of drugs, the accuracy and reliability of foreign object detection are improved.
[0041] A further improvement of the present invention is that, in step S4, the HSI color space model is used to extract the color hue of the original image processed in S2, wherein H: 0-360°, saturation S: 0-1, brightness I: 0-1, and accuracy ±1%; the standard values of the standard saline model are set as: H=180°±5°, S=0.05±0.01, I=0.9±0.02 as the standard reference values of the HSI model;
[0042] Calculate the entropy value of the gray-scale histogram of the drug solution area. The entropy value ranges from 0 to 8. An entropy value > 2.0 is judged as turbidity and its turbidity characteristics are extracted.
[0043] Texture features in image samples are acquired using a gray-level co-occurrence matrix. Parameters are set as follows: distance 1, angles 0°, 45°, 90°, and 135°. The contrast, correlation, and entropy values of each angle are calculated to extract texture features.
[0044] For suspension infusion, a particle counting algorithm based on fractal theory is used to extract the equivalent diameter and uniformity of particles, and Fourier transform is used to remove bubble interference and extract particle size distribution characteristics.
[0045] The light intensity attenuation rate of the liquid area is measured. If the attenuation rate is less than 85%, it is considered to have abnormal transparency. Its transparency characteristics are then extracted.
[0046] A further improvement of the present invention is that step S4 further includes using the extracted color hue, turbidity features, texture features, particle size distribution features, and transparency features to perform consistency detection on the identified drug components; specifically:
[0047] According to the parameter types in step S4, collect various standard drug parameters to establish a standard parameter library, and record the parameter ranges of hue, turbidity characteristics, texture characteristics, particle size distribution characteristics, and transparency characteristics.
[0048] The parameters of hue, turbidity, texture, particle size distribution, and transparency features extracted from the processed drug image in S2 are compared with the feature values of each drug component in the database. The similarity is calculated using the Euclidean distance formula, which is: ,in The image of the drug being tested is in the first... Characteristic values of each spectral band For a certain drug component in the database, in the first... Characteristic values of each spectral band This represents the number of spectral bands.
[0049] A further improvement of the present invention is that the feature matching model based on machine learning is constructed using the support vector machine algorithm:
[0050] When training the feature matching model, a large number of actual feature parameters and corresponding standard feature parameters of different types of infusion drugs are collected as training samples to train and optimize the model, so that the model can accurately judge the similarity between the actual drug feature parameters and the standard feature parameters.
[0051] During training, an ensemble learning strategy is adopted to combine multiple support vector machine models and determine the final similarity judgment result through voting or weighted averaging.
[0052] A further improvement of the present invention is that, when training the feature matching model constructed by the support vector machine algorithm, a kernel function selection strategy is adopted to automatically select a suitable kernel function based on the distribution characteristics of the training samples. The kernel function types include linear kernel functions, polynomial kernel functions, and radial basis kernel functions, so as to improve the generalization ability and matching accuracy of the model.
[0053] An adaptive parameter adjustment mechanism is introduced to dynamically adjust the model parameters based on error feedback during training, thereby accelerating the model's convergence speed and improving training efficiency.
[0054] A further improvement of this invention is that the preset similarity threshold is dynamically set according to the characteristics and quality requirements of different types of infusion drugs:
[0055] For infusion drugs with high quality requirements, the similarity threshold is set at ≥95%;
[0056] For infusion drugs with general quality requirements, the similarity threshold is set to ≥90%.
[0057] A further improvement of the present invention is that the method also includes result feedback and recording, feeding back the foreign object detection results and consistency verification results to the operator in real time, and storing the detection data and results in the database for subsequent query and traceability. At the same time, a detailed detection report is generated based on the detection results, which includes foreign object information, consistency judgment results, and related images and data charts.
[0058] The beneficial effects of this invention are as follows:
[0059] This invention employs a multispectral composite light source, cleverly combining visible, near-infrared, and ultraviolet light. Based on the principle that different substances exhibit unique characteristics in each spectral band—for example, some foreign objects show significant reflectivity under near-infrared light, while others exhibit prominent transmittance under ultraviolet light—this invention dynamically adjusts the light intensity ratio to maximize the highlighting of these differences, making the foreign object clearly visible in the image as if under a spotlight. This clear image provides a high-quality foundation for subsequent foreign object detection, greatly improving the accuracy and reliability of the detection. Secondly, it utilizes a multi-scale denoising algorithm based on wavelet transform. This algorithm adaptively selects the denoising threshold according to local image features. Taking an image containing small drug particles as an example, this algorithm can remove noise caused by factors such as the shooting environment while ensuring the edges and shapes of the drug particles are intact. Key features such as image state are not compromised. An enhancement processing method combining histogram equalization and homomorphic filtering is employed. Histogram equalization adjusts the pixel distribution of the image, brightening previously dark areas, while homomorphic filtering further optimizes image contrast. For example, when processing images of infusion drugs with light colors and low contrast, this combination effectively improves image contrast and clarity, making details in the image more distinct. Geometric correction is performed by establishing a lens distortion model. Lens distortion causes the shape and position of objects in an image to become distorted, much like the view seen in a funhouse mirror. Establishing a lens distortion model allows for accurate calculation and correction of the degree of distortion, eliminating the impact of lens distortion on image quality. This provides a solid guarantee for the accurate operation of the foreign object detection model, ensuring that the detection results are not interfered with by image distortion. Attached Figure Description
[0060] The invention will now be further described with reference to the accompanying drawings.
[0061] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0062] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0063] Example 1
[0064] Please see Figure 1 This embodiment provides: a method for detecting foreign bodies and consistency in infusion drugs based on image recognition, including the following steps:
[0065] S1. Acquiring images of infusion drugs: Using a 20-megapixel industrial camera, paired with a multispectral composite light source module, images of infusion drugs are acquired from multiple lighting conditions and different shooting angles to obtain a raw image dataset containing the overall and local details of the drugs.
[0066] S2. Image preprocessing: Denoising, enhancement, and correction are performed on the acquired raw image dataset to remove noise interference in the images, enhance drug feature information, and correct image distortion caused by shooting angle and lens distortion.
[0067] S3. Foreign Object Detection: Using target detection algorithms in deep learning, a detection model for foreign objects in infusion drugs is constructed. The pre-processed image is input into the model, and the model automatically identifies and locates the foreign objects in the image, while outputting the location, size and shape information of the foreign objects.
[0068] S4. Consistency Verification: Extract key feature parameters of the drug in the image, such as color, turbidity, texture, shape, particle size distribution, and transparency, and compare them with the standard feature parameters of the drug corresponding to the pre-stored expected formula.
[0069] By establishing a feature matching model based on machine learning, the similarity between the actual drug feature parameters and the standard feature parameters is calculated, and the consistency between the actual drug and the expected formula is determined based on the preset similarity threshold.
[0070] A further improvement of the present invention is that, in step S1, the spectral composite light source module includes a visible light LED lamp group of 450-650nm, a near-infrared LED lamp group of 850-1050nm, and an ultraviolet LED lamp group of 365-405nm; the light source controller supports 0-1000mA current adjustment, with a light intensity control accuracy of ±2%; six shooting positions are set around the infusion drug container, namely: 0° front view, ±30° side view, ±60° oblique view, and 90° top view; the illumination conditions are dynamically adjusted according to the type of drug solution, and the adjustment principle is:
[0071] Transparent electrolyte infusion type, visible light content 42%-48%, near-infrared light content 37%-43%, ultraviolet light content 12%-15%, exposure time 10-30ms, gain 3-6dB;
[0072] For dark-colored traditional Chinese medicine injections, the visible light content is 62%-68%, the near-infrared light content is 22%-28%, the ultraviolet light content is 12%-15%, the exposure time is 15-35ms, and the gain is 4-7dB.
[0073] For suspension infusions, the proportion of visible light is 52%-58%, the proportion of near-infrared light is 32%-38%, the proportion of ultraviolet light is 6%-9%, the exposure time is in the range of 12-32ms, and the gain is 3.5-6.5dB.
[0074] For antibiotic infusions, the exposure time is 57%-63% visible light, 27%-33% near-infrared light, and 13%-18% ultraviolet light. The exposure time is 13-33ms, and the gain is 3.8-6.8dB. By adjusting the exposure time and gain parameters, it is possible to avoid drug reflection and motion blur while ensuring that the image has a sufficient signal-to-noise ratio, thus enabling the detection of foreign objects with a diameter of 10μm or larger.
[0075] It should be noted that after completing step S1, which involves acquiring images of infusion drugs across multiple spectral bands including visible light, near-infrared, and ultraviolet, multispectral image registration and fusion processing is performed. A feature-point-based registration method is employed. First, the SIFT algorithm is used to extract feature points from each spectral image. These feature points are invariant to image rotation, scaling, and illumination changes. Then, feature point matching is performed by calculating the similarity between feature points to obtain the correspondence between the spectral images. Next, based on the matched feature points, the transformation matrix between the images is calculated, and an affine transformation model is used to spatially transform each spectral image to align them in spatial position. Finally, a weighted average fusion algorithm is used to fuse the registered multispectral images. Different weights are assigned to each spectral image based on the importance of different spectral bands for foreign object detection and consistency verification. For example, the weight of the visible light image is set to 0.4, the near-infrared image to 0.35, and the ultraviolet image to 0.25. The weighted sum of the spectral images yields the fused multispectral image, which integrates information from each spectral band and can more comprehensively and accurately reflect the characteristics of the infusion drug.
[0076] A further improvement of the present invention is that, in step S2, the denoising process employs a multi-scale denoising algorithm based on wavelet transform, selecting the db4 wavelet basis function, decomposing into 3 layers, and using the Birgé-Massart strategy for threshold calculation, as detailed below:
[0077] For low-frequency components of the image: preserve the overall characteristics of the liquid medicine, and set the threshold to 0.02-0.05 times the maximum gray value of the image;
[0078] For high-frequency components of the image: distinguish noise from foreign object edges, and dynamically adjust the threshold according to the number of decomposition layers; specifically: 0.08-0.12 for the first layer, 0.05-0.08 for the second layer, and 0.03-0.05 for the third layer, to ensure that Gaussian noise is removed while retaining the edge features of foreign objects with a diameter ≥10μm;
[0079] After denoising, the image is enhanced according to the following rules:
[0080] For transparent liquid medicine: Histogram equalization with 256 gray levels is used to enhance the gray level difference between foreign objects and liquid medicine, improving contrast by 20%-30%;
[0081] For dark-colored liquid medicine: Homomorphic filtering is used, with the Gaussian filter radius controlled at 5-15px and the cutoff frequency at 0.1-0.3, to suppress the interference of liquid medicine color and enhance the reflection characteristics of foreign objects.
[0082] After enhancement processing, the image is corrected, and a distortion model library for different types of infusion container lenses is established. Different distortion parameters are obtained using a 12×12 grid calibration plate with a grid spacing of 5mm, as detailed below:
[0083] Glass bottle: A polynomial distortion model is adopted, with radial distortion coefficients k1=-0.015~-0.005, k2=0.002~0.008; tangential distortion coefficients p1=-0.001~0.001, p2=-0.001~0.001;
[0084] PVC soft bags: Perspective projection correction is used to eliminate geometric deformation caused by container wrinkles. The pixel deviation of the corrected image is ≤2px.
[0085] Non-PVC soft bags: Combining region growth algorithms, the liquid area and the edge of the bag are segmented to avoid the impact of uneven light transmission on the detection.
[0086] A further improvement of the present invention is that, in step S3, the YOLOv7 model for detecting foreign bodies in infusion drugs is improved and reconstructed, specifically as follows:
[0087] Backbone network optimization: A CBAM attention mechanism is inserted after the ELAN module of YOLOv7, with channel attention weights ranging from 0.1 to 0.9 and spatial attention convolution kernels of 3×3, enhancing the model's ability to extract features from foreign object regions and increasing the recognition weight of small targets smaller than 30px by 20%.
[0088] Anchor frame optimization: Based on the K-means clustering algorithm with 9 clusters, the foreign body annotation boxes of more than 100,000 sample images were clustered to obtain the anchor frame sizes suitable for infusion foreign bodies, which are: 12×12, 20×20, 32×32, 48×48, 64×64, 80×80, 96×96, 128×128, and 160×160, respectively, and the average IOU was improved to 0.85;
[0089] Improved loss function: The Complete-IoU loss function is adopted, combined with focusing parameters α=0.25 and γ=2.0, to solve the problem of imbalance of foreign object samples, control the proportion of foreign object region to <0.1%, and improve the convergence speed of the model by 30%.
[0090] The YOLOv7 model was trained and optimized, specifically as follows:
[0091] In a training environment with an NVIDIA A100 GPU, PyTorch 1.12 framework, batch size=16, and initial learning rate of 0.01, cosine annealing learning rate scheduling is used.
[0092] The model was trained under random conditions of random rotation from -15° to 15°, horizontal flip with a probability of 0.5, scaling from 0.8 to 1.2 times, Gaussian blur with a kernel size of 3×3 at a probability of 0.2, and brightness adjustment from -20% to 20% to enhance its generalization ability.
[0093] The training objectives were as follows: the model achieved an accuracy of over 98.2%, a recall of 92.5%, an F1 score of 95.3%, and a detection rate of 88.7% for foreign objects with a diameter of 20-25 μm on a test set with a sample size of 20,000.
[0094] Based on the mature training model above, foreign object identification is performed on the preprocessed image in step S2. The identification rules are as follows:
[0095] Canny edge detection with a threshold of 100-200 is used to extract the edge of the foreign object and calculate its curvature. If the object is identified as a foreign object, it is determined to be a foreign object if any of the following conditions are met: mean curvature > 0.8, mean curvature < 0.3, or fiber length > 200 μm.
[0096] Furthermore, based on the lens distortion model library of different types of infusion containers established in S2, the similarity between foreign objects and drug components is calculated using the Euclidean distance formula. The calculation formula is as follows:
[0097]
[0098] Where x_i is the characteristic value of the foreign substance in the i-th spectral band, i=1 is visible light, i=2 is near infrared, i=3 is ultraviolet, and y_i is the standard value of the drug component in the corresponding spectral band.
[0099] Furthermore, different judgment thresholds are set for different types of infusion drugs: for transparent electrolyte infusions, a value of D > 0.25 is considered a foreign body; for dark-colored traditional Chinese medicine injections, a value of D > 0.28 is considered a foreign body; for suspension infusions, a value of D > 0.22 is considered a foreign body; and for antibiotic infusions, a value of D > 0.26 is considered a foreign body. By setting more precise judgment thresholds according to different types of drugs, the accuracy and reliability of foreign body detection are improved.
[0100] It should be noted that, in the foreign object identification process in step S3, the following mechanism is used to distinguish between foreign objects and air bubbles:
[0101] First, based on multispectral image information, the reflectance characteristics of objects in different spectral bands are analyzed. Bubbles have relatively uniform reflectance characteristics in different spectral bands, and their shapes are usually quite regular, mostly round or elliptical, with relatively smooth edges. However, foreign objects often have significant differences in reflectance characteristics in different spectral bands. For example, metallic foreign objects may have high reflectance in the near-infrared spectral band, while fibrous foreign objects may have unique absorption and reflection characteristics in the visible light spectral band. At the same time, the shapes of foreign objects are usually irregular, and the edges may be serrated or burr-like.
[0102] Secondly, the texture features of the image are used for differentiation. The texture inside a bubble is relatively uniform and has no obvious texture structure, while foreign objects may have complex texture structures, such as the texture direction of fibers or the surface texture of particles. By comprehensively analyzing the reflectance characteristics, shape features, and texture features of the object in different spectral bands, a pre-trained classification model, such as a deep learning-based convolutional neural network model, is used to classify and judge the object. When the object meets the feature description of a bubble, it is judged as a bubble; otherwise, it is judged as a foreign object, thereby improving the accuracy of foreign object detection and avoiding misjudging bubbles as foreign objects.
[0103] A further improvement of the present invention is that, in step S4, the HSI color space model is used to extract the color hue of the original image processed in S2, wherein H: 0-360°, saturation S: 0-1, brightness I: 0-1, and accuracy ±1%; the standard values of the standard saline model are set as: H=180°±5°, S=0.05±0.01, I=0.9±0.02 as the standard reference values of the HSI model;
[0104] Calculate the entropy value of the gray-scale histogram of the drug solution area. The entropy value ranges from 0 to 8. An entropy value > 2.0 is judged as turbidity and its turbidity characteristics are extracted.
[0105] Texture features in image samples are acquired using a gray-level co-occurrence matrix. Parameters are set as follows: distance 1, angles 0°, 45°, 90°, and 135°. The contrast, correlation, and entropy values of each angle are calculated to extract texture features.
[0106] For suspension infusion, a particle counting algorithm based on fractal theory is used to extract the equivalent diameter and uniformity of particles, and Fourier transform is used to remove bubble interference and extract particle size distribution characteristics.
[0107] The light intensity attenuation rate of the liquid area is measured. If the attenuation rate is less than 85%, it is considered to have abnormal transparency. Its transparency characteristics are then extracted.
[0108] It should be noted that in step S4, after extracting key feature parameters such as color, turbidity, texture, shape, particle size distribution, and transparency of the drug in the image, weighted integration of different spectral features is performed. For color features, weights are assigned to the color features of the visible light, near-infrared, and ultraviolet spectral bands according to the contribution of different spectral bands to color representation. For example, the weight of the visible light color feature is set to 0.6, the weight of the near-infrared color feature is set to 0.2, and the weight of the ultraviolet color feature is set to 0.2. The weighted sum of the color features of each spectral band is then used to obtain the comprehensive color feature parameters. For turbidity features, considering... The perceptual differences in turbidity across different spectral bands are used to assign weights to the turbidity features of each spectral band. For example, the weight of visible light turbidity features is set to 0.5, near-infrared turbidity features to 0.3, and ultraviolet turbidity features to 0.2. These weighted integrations yield a comprehensive turbidity feature parameter. Similarly, for texture features, shape features, particle size distribution features, and transparency features, reasonable weights are assigned based on the degree of influence of each spectral band on the corresponding features, and these are then weighted integrations to ultimately obtain a feature parameter set that comprehensively reflects the characteristics of the infusion drug. This set is then used for comparative analysis with the standard feature parameters of the drug corresponding to the pre-stored expected formulation.
[0109] The machine learning-based feature matching model is constructed using the support vector machine algorithm.
[0110] When training the feature matching model, a large number of actual feature parameters and corresponding standard feature parameters of different types of infusion drugs are collected as training samples to train and optimize the model, so that the model can accurately judge the similarity between the actual drug feature parameters and the standard feature parameters.
[0111] During training, an ensemble learning strategy is adopted to combine multiple support vector machine models and determine the final similarity judgment result through voting or weighted averaging.
[0112] When training the feature matching model constructed by the support vector machine algorithm, a kernel function selection strategy is adopted to automatically select a suitable kernel function based on the distribution characteristics of the training samples. The kernel function types include linear kernel function, polynomial kernel function and radial basis kernel function, in order to improve the generalization ability and matching accuracy of the model.
[0113] An adaptive parameter adjustment mechanism is introduced to dynamically adjust the model parameters based on error feedback during training, thereby accelerating the model's convergence speed and improving training efficiency.
[0114] The preset similarity threshold is dynamically set according to the characteristics and quality requirements of different types of infusion drugs:
[0115] For infusion drugs with high quality requirements, the similarity threshold is set at ≥95%;
[0116] For infusion drugs with general quality requirements, the similarity threshold is set to ≥90%.
[0117] For example, when extracting color feature parameters of drugs in an image, the HSI color space model is used to extract the hue, saturation, and brightness components of the drug as color features. For a certain infusion drug, the actual extracted hue is 30°, saturation is 0.6, and brightness is 0.8, which is compared with pre-stored standard feature parameters such as hue 32°, saturation 0.65, and brightness 0.85. When extracting turbidity feature parameters, turbidity is characterized by calculating the entropy value of the gray-level histogram of the drug region in the image. The actual entropy value is 3.5, and the standard entropy value is 3.2. All extracted feature parameters are input into a feature matching model constructed using a support vector machine algorithm, and the similarity between the actual drug feature parameters and the standard feature parameters is calculated to be 92%. For this infusion drug with general quality requirements, the preset similarity threshold is ≥90%, therefore it is determined that the actual prepared drug is consistent with the expected formula.
[0118] Furthermore, the preprocessed image in S2 provides accurate image data for the consistency verification in S4. Consistency verification requires extracting key feature parameters of the drug in the image, such as color, turbidity, and texture features. The preprocessed image has higher quality and more obvious features, which is conducive to the accurate extraction of these feature parameters. At the same time, the accurate extraction and analysis of feature parameters in S4 also requires image quality, which S2 preprocessing meets. In addition, S2 preprocessing improves the accuracy of feature parameter extraction in S4. For example, when using the HSI color space model to extract drug color feature parameters, the color information of the preprocessed image is more accurate, and the hue, saturation, and brightness components can be extracted more precisely. When extracting turbidity feature parameters, preprocessing removes noise interference, making the gray-level histogram of the drug area in the image more accurate, and the calculated entropy value can more realistically reflect the turbidity. When extracting texture features, the texture of the preprocessed image is clearer, and the parameters such as contrast, correlation, and entropy calculated using the gray-level co-occurrence matrix are more accurate and can better reflect the texture features of the drug. These accurate feature parameters provide a reliable basis for subsequent comparison analysis with standard feature parameters and consistency judgment.
[0119] S3 (foreign matter detection) and S4 (consistency verification) are both crucial steps in assessing the quality of infusion drugs. They complement each other. Foreign matter detection focuses on the presence and characteristics of foreign objects in the drug, while consistency verification focuses on whether the actual drug matches the expected formulation in key characteristic parameters. Performing these two steps simultaneously allows for a more comprehensive assessment of drug quality. In practice, if S3 detects foreign objects, the batch of drugs may have issues regardless of the S4 consistency verification result, requiring further processing. Conversely, if S4 determines that the actual drug does not match the expected formulation, it may indicate an anomaly in the drug, requiring a comprehensive analysis based on the S3 foreign matter detection results. For example, if no foreign object is detected in a certain infusion drug in S3, but the S4 consistency verification reveals a significant difference in the drug's color characteristic parameters from the standard, further investigation can be conducted to determine if the inconsistency is due to drug component deterioration or other non-foreign matter factors, thus ensuring more comprehensive drug quality assurance.
[0120] S5. Result Feedback and Recording: The system provides real-time feedback on foreign object detection results and consistency verification results to the operator, and stores the detection data and results in the database for subsequent querying and traceability. It also generates a detailed detection report based on the results, including foreign object information, consistency judgment results, and relevant images and data charts. When the system alarms and detects a foreign object or inconsistency, the following processing procedure is initiated: First, the system automatically marks the suspected foreign object location or inconsistency characteristics and provides real-time feedback to the operator. After receiving the alarm information, the operator performs a manual review. This review involves viewing the detailed detection report generated by the system, which includes foreign object information such as foreign object type, location, size, shape, consistency judgment results, and relevant images and data charts such as screenshots of the foreign object's location and feature parameter comparison charts. The operator then uses their experience and professional knowledge to determine whether it is a genuine foreign object or if an inconsistency does exist.
[0121] If, upon manual verification, a genuine foreign object is confirmed or inconsistencies are found, in the case of a foreign object, if the object is large and easily removed, the system will automatically control the removal device to remove the infusion medication containing the foreign object from the testing line; if the object is small or not easily removed automatically, the operator will manually stop the production of that batch of medication and conduct an investigation. In cases where consistency verification fails, the operator will investigate whether the problem is due to drug composition issues, production process issues, or other factors, and take corresponding improvement measures, such as adjusting the formula or optimizing the production process.
[0122] Furthermore, S1-S4 complete a series of quality inspection tasks, such as image acquisition, preprocessing, foreign object detection, and consistency verification of infusion drugs. S5 then provides feedback, records, and generates reports on these inspection results. The feedback from S5 allows operators to understand the drug quality status in a timely manner and take corresponding measures. The recording function provides data support for subsequent queries and traceability. The report generation provides detailed evidence for drug quality control. The inspection results of S1-S4 form the basis for S5's feedback, recording, and report generation.
[0123] Simultaneously, through the collaboration of S1-S4 and S5, a complete drug quality testing process is realized. For example, after S1-S4 completes the testing, S5 provides real-time feedback to the operators on foreign object detection results, such as the type and location of foreign objects found, and consistency verification results, such as whether the actual drug matches the expected formula. Based on the feedback results, the operators can promptly stop the production of the problematic batch of drugs or take other handling measures. At the same time, S5 stores the test data and results in the database, facilitating subsequent inquiries about the production status and test results of that batch of drugs. The detailed test report generated based on the test results includes foreign object information, consistency judgment results, and related images and data charts, providing a comprehensive basis for drug quality assessment, problem investigation, and production process improvement, thereby improving the efficiency and accuracy of drug quality control.
[0124] Example 2:
[0125] Foreign body detection in transparent electrolyte infusion (physiological saline) was performed using the method described in Example 1.
[0126] S1 acquisition parameters: industrial camera with resolution of 5472×3648, exposure time of 10ms, gain of 1dB; multispectral light intensity ratio: visible light 45%, near-infrared 40%, ultraviolet 15%; simultaneous acquisition from 6 shooting stations.
[0127] S2 preprocessing: wavelet transform denoising (db4 basis function, 3-level decomposition, low-frequency threshold 0.03, high-frequency threshold 0.1), histogram equalization enhancement, glass bottle distortion correction (radial distortion coefficient k1=-0.01, k2=0.005; tangential distortion coefficient p1=0, p2=0).
[0128] S3 Foreign Object Detection: Improved YOLOv7 model (CBAM attention mechanism, anchor frames 12×12, 20×20, 32×32), detected a 15μm diameter metal particle (location: bottom of container (x=2000px, y=3000px), edge curvature 0.9, movement speed 0.8px / frame, spectral similarity D=0.5>0.3, judged as a foreign object);
[0129] S4 Consistency Verification: Extract color features (H=182°, S=0.04, I=0.89), turbidity entropy value 1.2, transparency 95%, and calculate similarity using SVM model (linear kernel) 96.5% ≥ 90%, thus determining consistency;
[0130] Results feedback: The display shows "Metal particles detected, consistency qualified", triggering an audible and visual alarm, storing data in the database, and generating a test report.
[0131] Example 3
[0132] The consistency verification of dark-colored traditional Chinese medicine injection (Danshen injection) was carried out using the scheme in Example 1.
[0133] S1 acquisition parameters: exposure time set to 15ms, gain 2dB; multispectral light intensity ratio: visible light 65%, near-infrared 25%, ultraviolet 10%;
[0134] S2 preprocessing: wavelet transform denoising (low frequency threshold 0.04, high frequency threshold 0.08), homomorphic filtering enhancement (Gaussian radius 10px, cutoff frequency 0.2), non-PVC soft bag perspective correction;
[0135] S3 Foreign Object Detection: No foreign object detected (model output confidence level < 0.5);
[0136] S4 consistency verification: Extract color features (H=350°, S=0.6, I=0.4), texture contrast 35, correlation 0.9, SVM model (radial basis kernel) calculated similarity 88% < 90%, judged as inconsistent (possibly due to drug concentration deviation);
[0137] Results feedback: The display shows "No foreign matter detected, consistency unqualified", triggering an alarm. It is recommended to re-formulate, and the data is stored and a report is generated.
[0138] In summary, Examples 2 and 3, through verification operations on standard drug components, demonstrate that the patented solution, by combining multispectral dynamic adaptation with an improved YOLOv7 model, achieves the detection of minute foreign objects at the 10μm level, a 400% improvement over existing technologies (detection limit 50μm); multi-dimensional feature consistency verification reduces the false judgment rate to 1.4%, which is superior to traditional single-feature methods (10%); it also covers multiple types of drug solutions, including transparent, dark, and suspension solutions, and is compatible with containers such as glass bottles, PVC bags, and non-PVC bags, overcoming the limitation of existing technologies that "one light source / algorithm adapts to a single drug solution".
[0139] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed. The scope of protection of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for detecting foreign bodies and consistency in infusion drugs based on image recognition, characterized in that, Includes the following steps: S1. Acquiring images of infusion drugs: Using a 20-megapixel industrial camera, paired with a multispectral composite light source module, images of infusion drugs are acquired from multiple lighting conditions and different shooting angles to obtain a raw image dataset containing the overall and local details of the drugs. S2. Image preprocessing: Denoising, enhancement, and correction are performed on the acquired raw image dataset to remove noise interference in the images, enhance drug feature information, and correct image distortion caused by shooting angle and lens distortion. S3. Foreign Object Detection: Using target detection algorithms in deep learning, a detection model for foreign objects in infusion drugs is constructed. The pre-processed image is input into the model, and the model automatically identifies and locates the foreign objects in the image, while outputting the location, size and shape information of the foreign objects. S4. Consistency Verification: Extract key feature parameters of the drug in the image, such as color, turbidity, texture, shape, particle size distribution, and transparency, and compare them with the standard feature parameters of the drug corresponding to the pre-stored expected formula. By establishing a feature matching model based on machine learning, the similarity between the actual drug feature parameters and the standard feature parameters is calculated, and the consistency between the actual drug and the expected formula is determined based on the preset similarity threshold.
2. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: In step S1, the spectral composite light source module includes a visible light LED group (450-650nm), a near-infrared LED group (850-1050nm), and an ultraviolet LED group (365-405nm); the light source controller supports 0-1000mA current adjustment with a light intensity control accuracy of ±2%; six shooting positions are set around the infusion drug container: 0° front view, ±30° side view, ±60° oblique view, and 90° top view; the illumination conditions are dynamically adjusted according to the type of drug solution, and the adjustment principle is as follows: Transparent electrolyte infusion type, visible light content 42%-48%, near-infrared light content 37%-43%, ultraviolet light content 12%-15%, exposure time 10-30ms, gain 3-6dB; For dark-colored traditional Chinese medicine injections, the visible light content is 62%-68%, the near-infrared light content is 22%-28%, the ultraviolet light content is 12%-15%, the exposure time is 15-35ms, and the gain is 4-7dB. For suspension infusions, the proportion of visible light is 52%-58%, the proportion of near-infrared light is 32%-38%, the proportion of ultraviolet light is 6%-9%, the exposure time is in the range of 12-32ms, and the gain is 3.5-6.5dB. For antibiotic infusions, the proportion of visible light is 57%-63%, near-infrared light is 27%-33%, ultraviolet light is 13%-18%, the exposure time is 13-33ms, and the gain is 3.8-6.8dB.
3. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: In step S2, the denoising process employs a multi-scale denoising algorithm based on wavelet transform, selecting the db4 wavelet basis function, decomposing into 3 layers, and using the Birgé-Massart strategy for threshold calculation, as detailed below: For low-frequency components of the image: preserve the overall characteristics of the liquid medicine, and set the threshold to 0.02-0.05 times the maximum gray value of the image; For high-frequency components of the image: distinguish noise from foreign object edges, and dynamically adjust the threshold according to the number of decomposition layers; specifically: 0.08-0.12 for the first layer, 0.05-0.08 for the second layer, and 0.03-0.05 for the third layer, to ensure that Gaussian noise is removed while retaining the edge features of foreign objects with a diameter ≥10μm; After denoising, the image is enhanced according to the following rules: For transparent liquid medicine: Histogram equalization with 256 gray levels is used to enhance the gray level difference between foreign objects and liquid medicine, improving contrast by 20%-30%; For dark-colored liquid medicine: Homomorphic filtering is used, with the Gaussian filter radius controlled at 5-15px and the cutoff frequency at 0.1-0.3, to suppress the color interference of the liquid medicine and enhance the reflection characteristics of foreign objects. After enhancement processing, the image was corrected, and a distortion model library for different types of infusion container lenses was established. Different distortion parameters were obtained using a 12×12 grid calibration plate with a grid spacing of 5mm, as detailed below: Glass bottle: A polynomial distortion model is adopted, with radial distortion coefficients k1=-0.015~-0.005, k2=0.002~0.008; tangential distortion coefficients p1=-0.001~0.001, p2=-0.001~0.001; PVC soft bags: Perspective projection correction is used to eliminate geometric deformation caused by container wrinkles. The pixel deviation of the corrected image is ≤2px. Non-PVC soft bags: Combining region growth algorithms, the liquid area and the edge of the bag are segmented to avoid the impact of uneven light transmission on the detection.
4. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: In step S3, the YOLOv7 model is improved and reconstructed for the detection of foreign bodies in infusion drugs, specifically as follows: Backbone network optimization: A CBAM attention mechanism is inserted after the ELAN module of YOLOv7, with channel attention weights ranging from 0.1 to 0.9 and spatial attention convolution kernels of 3×3, enhancing the model's ability to extract features from foreign object regions and increasing the recognition weight of small targets smaller than 30px by 20%. Anchor frame optimization: Based on the K-means clustering algorithm with 9 clusters, the foreign body annotation boxes of more than 100,000 sample images were clustered to obtain the anchor frame sizes suitable for infusion foreign bodies, which are: 12×12, 20×20, 32×32, 48×48, 64×64, 80×80, 96×96, 128×128, and 160×160, respectively, and the average IOU was improved to 0.85; Improved loss function: The Complete-IoU loss function is adopted, combined with focusing parameters α=0.25 and γ=2.0, to solve the problem of imbalance of foreign object samples, control the proportion of foreign object region to <0.1%, and improve the convergence speed of the model by 30%. The YOLOv7 model was trained and optimized, specifically as follows: In a training environment with an NVIDIA A100 GPU, PyTorch 1.12 framework, batch size=16, and initial learning rate of 0.01, cosine annealing learning rate scheduling is used. The model was trained under random conditions of random rotation from -15° to 15°, horizontal flip with a probability of 0.5, scaling from 0.8 to 1.2 times, Gaussian blur with a kernel size of 3×3 at a probability of 0.2, and brightness adjustment from -20% to 20% to enhance its generalization ability. The training objectives were as follows: the model achieved an accuracy of over 98.2%, a recall of 92.5%, an F1 score of 95.3%, and a detection rate of 88.7% for foreign objects with a diameter of 20-25 μm on a test set with a sample size of 20,000. Based on the mature training model above, foreign object identification is performed on the preprocessed image in step S2. The identification rules are as follows: Canny edge detection with a threshold of 100-200 is used to extract the edge of the foreign object and calculate its curvature. If the object is identified as a foreign object, it is determined to be a foreign object if any of the following conditions are met: mean curvature > 0.8, mean curvature < 0.3, or fiber length > 200 μm. Furthermore, based on the lens distortion model library of different types of infusion containers established in S2, the similarity between foreign objects and drug components is calculated using the Euclidean distance formula. The calculation formula is as follows: Where x_i is the characteristic value of the foreign substance in the i-th spectral band, i=1 is visible light, i=2 is near-infrared, i=3 is ultraviolet, and y_i is the standard value of the drug component in the corresponding spectral band.
5. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: In step S4, the HSI color space model is used to extract the color hue of the original image processed in S2, where H: 0-360°, saturation S: 0-1, brightness I: 0-1, and accuracy ±1%; the standard values of the standard saline model are set as: H=180°±5°, S=0.05±0.01, I=0.9±0.02 as the standard reference values of the HSI model. Calculate the entropy value of the gray-scale histogram of the drug solution area. The entropy value ranges from 0 to 8. An entropy value > 2.0 is judged as turbidity and its turbidity characteristics are extracted. Texture features in image samples are acquired using a gray-level co-occurrence matrix. Parameters are set as follows: distance 1, angles 0°, 45°, 90°, and 135°. The contrast, correlation, and entropy values of each angle are calculated to extract texture features. For suspension infusion, a particle counting algorithm based on fractal theory is used to extract the equivalent diameter and uniformity of particles, and Fourier transform is used to remove bubble interference and extract particle size distribution characteristics. The light intensity attenuation rate of the liquid area is measured. If the attenuation rate is less than 85%, it is considered to have abnormal transparency. Its transparency characteristics are then extracted.
6. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: Step S4 further includes using the extracted color hue, turbidity features, texture features, particle size distribution features, and transparency features to perform consistency detection on the identified drug components; specifically: According to the parameter types in step S4, collect various standard drug parameters to establish a standard parameter library, and record the parameter ranges of hue, turbidity characteristics, texture characteristics, particle size distribution characteristics, and transparency characteristics. The parameters of hue, turbidity, texture, particle size distribution, and transparency features extracted from the processed drug image in S2 are compared with the feature values of each drug component in the database. The similarity is calculated using the Euclidean distance formula, which is: ,in The image of the drug being tested is in the first... Characteristic values of each spectral band For a certain drug component in the database, in the first... Characteristic values of each spectral band The number of spectral bands, when the calculated similarity... If the value is less than a preset threshold, the foreign object is determined to be different from the drug component.
7. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: The machine learning-based feature matching model is constructed using the support vector machine algorithm. When training the feature matching model, a large number of actual feature parameters and corresponding standard feature parameters of different types of infusion drugs are collected as training samples to train and optimize the model, so that the model can accurately judge the similarity between the actual drug feature parameters and the standard feature parameters. During training, an ensemble learning strategy is adopted to combine multiple support vector machine models and determine the final similarity judgment result through voting or weighted averaging.
8. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: When training the feature matching model constructed by the support vector machine algorithm, a kernel function selection strategy is adopted to automatically select a suitable kernel function based on the distribution characteristics of the training samples. The kernel function types include linear kernel function, polynomial kernel function and radial basis kernel function, in order to improve the generalization ability and matching accuracy of the model. An adaptive parameter adjustment mechanism is introduced to dynamically adjust the model parameters based on error feedback during training, thereby accelerating the model's convergence speed and improving training efficiency.
9. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: The preset similarity threshold is dynamically set according to the characteristics and quality requirements of different types of infusion drugs: For infusion drugs with high quality requirements, the similarity threshold is set at ≥95%; For infusion drugs with general quality requirements, the similarity threshold is set to ≥90%.
10. The method for detecting foreign bodies and consistency of infusion drugs based on image recognition according to claim 1, characterized in that: It also includes result feedback and recording, which provides real-time feedback of foreign object detection results and consistency verification results to operators, and stores the detection data and results in the database for subsequent query and traceability. At the same time, it generates a detailed detection report based on the detection results, which includes foreign object information, consistency judgment results, and related images and data charts.