Traditional Chinese medicine decoction piece dispensing dosage AI dynamic optimization system
The AI-powered dynamic optimization system for dispensing Chinese herbal medicine slices solves the problem of difficulty in quantifying the differences in the state of the slices during dispensing. It enables dynamic correction and precise matching of weight calculation, improving medication safety and efficacy, and is suitable for large-scale and diversified dispensing scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies struggle to accurately quantify the differences in the state of Chinese herbal medicine slices during dispensing. The incompleteness of image recognition technology leads to low accuracy in dosage calculation, affecting medication safety and efficacy.
The system employs an AI-driven dynamic optimization system for dispensing traditional Chinese medicine (TCM) decoction pieces. It acquires historical and real-time image data through an AI recognition module, combines neural network prediction of dark features, constructs a correlation matrix between state features and weight features, dynamically corrects weight calculations, establishes a dedicated variety database, and supports the storage and retrieval of decoction pieces with multiple varieties and weight gradients.
It significantly reduces dosage errors caused by differences in state such as adhesion, breakage, and moisture, ensures accurate matching of effective weight with prescription requirements, improves dispensing efficiency, reduces reliance on the experience of professionals, and is suitable for large-scale and diversified dispensing scenarios of medicinal slices.
Smart Images

Figure CN121789889A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of AI dynamic optimization technology for dispensing dosage, and more specifically, to an AI dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces. Background Technology
[0002] Dispensing of Chinese herbal medicines is a crucial step in clinical treatment with traditional Chinese medicine. Its core purpose is to accurately adjust the dosage of herbs according to the prescription requirements to ensure medication safety and efficacy.
[0003] Existing technologies have significant shortcomings in practical applications. First, they are not adaptable enough to the differences in the state of medicinal slices. Traditional methods are unable to accurately quantify changes in the state of medicinal slices, such as adhesion, breakage, dampness, and mold. These state differences directly affect the bulk density and actual effective weight of the medicinal slices, causing the actual efficacy of the medicinal slices weighed according to the standard dosage to deviate from expectations. Second, the image recognition technology is not comprehensive enough. It can only extract features in the bright areas within the camera's shooting range, and does not effectively compensate for the lack of features in dark areas such as occluded areas and the back of the medicinal slices. This results in one-sided feature extraction, which in turn affects the accuracy of dosage calculation. To reduce this situation, an AI dynamic optimization system for the dosage of traditional Chinese medicine medicinal slices is proposed. Summary of the Invention
[0004] The purpose of this invention is to provide an AI-based dynamic optimization system for dispensing dosages of traditional Chinese medicine decoction pieces, in order to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, an AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces is provided, comprising a data acquisition unit, a feature extraction unit, an association evidence establishment unit, a weight feature correction unit, and a dispensing optimization unit. The data acquisition unit is used to establish an AI recognition module, collect historical image data of Chinese herbal medicine slices, establish a variety database based on the classification of Chinese herbal medicine slice varieties, and select standard image data for each Chinese herbal medicine slice in the variety database. The feature extraction unit is used to acquire real-time image data to be optimized. The AI recognition module extracts bright and dark features from the real-time image data. Based on the neural network, the dark features are predicted and supplemented according to the bright features, and the dark features are transformed into predicted bright features. The association evidence establishment unit is used to annotate the historical image data of the variety database with state features and weight features, perform image difference data analysis on standard image data and historical image data, and combine the obtained image difference data with the corresponding state features and weight features for association training, thereby constructing an association matrix of image difference data corresponding to weight features and state features. The weight feature correction unit is used to perform similarity matching between the light features and the predicted light features and the image data in the corresponding variety database, filter standard samples according to the matching results, summarize the weight features of the standard samples as the initial weight features, and then combine the initial weight with the correlation matrix to calculate the state correction amount to obtain the effective weight features. The dispensing optimization unit is used to obtain the dispensing dosage requirements, and then combine the effective weight characteristics with the dispensing dosage requirements to provide optimization reminders.
[0006] As a further improvement to this technical solution, an AI recognition module is established in the data acquisition unit, which completes the feature extraction unit, the associated evidence establishment unit, the weight feature correction unit, and the adjustment and optimization unit. By connecting to an industrial camera that controls the dosage of Chinese herbal medicine slices and is equipped with a multispectral module, images of the Chinese herbal medicine slices are acquired through the industrial camera, thereby obtaining historical image data and real-time image data to be optimized.
[0007] As a further improvement to this technical solution, the traditional Chinese medicine decoction pieces varieties are extracted from the historical image data to obtain the traditional Chinese medicine decoction pieces varieties corresponding to each historical image data. Then, a dedicated variety database is established for each traditional Chinese medicine decoction piece variety, and the historical image data of the same traditional Chinese medicine decoction piece variety is stored in the corresponding variety database. The variety database selects standard image data. By setting standard selection conditions, the database matches historical image data stored in the variety database with the standard selection conditions and selects historical image data that meets the standard conditions as standard image data. The standard selection conditions are that the state characteristics are no adhesion, no mold, and the integrity is higher than 98%, and the data is associated with the weight data recorded by the electronic scale.
[0008] As a further improvement to this technical solution, in the feature extraction unit, the Chinese herbal medicine slices are encoded in the real-time image data, and then image segmentation and extraction are performed according to each encoded Chinese herbal medicine slice to obtain the image data corresponding to each encoded Chinese herbal medicine slice. A model of Chinese herbal medicine is established based on the image data corresponding to each coded Chinese herbal medicine slice. Then, the bright features are extracted from the Chinese herbal medicine slice model. The structure of the Chinese herbal medicine slice model is corrected based on the bright features. The bright features are then removed from the structure-corrected Chinese herbal medicine slice model, and the remaining model area is used as the dark features. Among them, the visible features are the surface features of the Chinese herbal medicine slices that are captured and recorded by an industrial camera in the model of Chinese herbal medicine slices; Dark features refer to the surface features of Chinese herbal medicine slices that were not captured or recorded by industrial cameras in the model.
[0009] As a further improvement to this technical solution, the bright area features are combined with neural networks to predict and supplement the dark area features. Specifically, an improved CycleGAN model is used, with three ResNet residual blocks added to the generator, and PatchGAN is used as the discriminator. Paired samples of bright area features and complete features generated by randomly occluding the model region using standard image data are used. The model generator is trained based on the paired samples. After training, the dark area features and the traditional Chinese medicine film model are input into the model generator, and the model generator outputs the predicted bright area features corresponding to the dark area features.
[0010] As a further improvement to this technical solution, in the associated evidence establishment unit, the historical image data of the variety database is labeled with status features and weight features. Image data that cannot be labeled is deleted, and only historical image data with status features and weight features are retained. Among them, status features include morphological features, color features, and integrity features, and weight features include actual weight data. After labeling using the LabelStudio tool, both the state features and weight features are converted into 64-dimensional standardized feature vectors.
[0011] As a further improvement to this technical solution, in the associated evidence establishment unit, the standard image data and historical image data of the same variety database are grouped according to the weight characteristics. Within each group, the image difference data and feature vector difference between the standard image data and the historical image data are calculated. The image difference data and feature vector differences of all groups are summarized to establish an associated dataset. Image difference data is extracted from the associated dataset and combined with the corresponding state feature vector and weight feature vector to form basic training samples. Then, the basic training samples corresponding to the standard image data are combined with the basic training samples corresponding to the historical image data to form the initial training set data. The initial training dataset is then expanded and stratified by variety to form training set, validation set and test set. A three-layer fully connected neural network is used for training. The input layer is a 128-dimensional vector, the hidden layer contains ReLU activation function and dropout layer, and the output layer outputs a 64×64 correlation matrix. Among them, the 128-dimensional vector consists of a 64-dimensional state feature vector and a 64-dimensional Vic repetition feature vector; Training uses the Adam optimizer to configure training parameters and completes iterations through a cosine annealing learning rate decay strategy. Then, the MSE of the predicted weight feature and the actual weight feature is used as the loss function, and gradient clipping and early stopping strategies are used for optimization. Finally, L2 normalization and outlier processing are performed on the correlation matrix to complete the construction of the correlation matrix.
[0012] As a further improvement to this technical solution, in the weight feature correction unit, the predicted bright features and the bright features are vector-concatenated to form a 64-dimensional state feature vector, which is used as the feature vector of the real-time image data to be optimized. The state feature vector of the real-time image data to be optimized is matched with the state feature vector of the historical image data of the corresponding variety database to obtain the similarity between the real-time image data and the historical image data. Then, the top five historical image data with the highest similarity are selected as standard samples, and the average weight feature corresponding to the standard samples is summarized as the initial weight feature corresponding to the real-time image data. The initial weight feature is combined with the correlation matrix to calculate the state correction amount, and then the initial weight feature and the state correction amount are added together to obtain the effective weight feature.
[0013] As a further improvement to this technical solution, the dispensing optimization unit obtains the dispensing dosage requirement and compares the effective weight characteristic with the dispensing dosage requirement. When the effective weight characteristic is lower than the dispensing dosage requirement, it prompts the user to supplement the corresponding Chinese herbal medicine pieces to the dosage requirement value. If the effective weight characteristic is higher than the required dosage, it is recommended to reduce the corresponding Chinese herbal medicine pieces to the required dosage value.
[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. In this AI dynamic optimization system for dispensing traditional Chinese medicine decoction pieces, an improved CycleGAN model is used to predict and supplement features in the dark area, forming a complete feature representation by combining features in the light area. At the same time, a correlation matrix between state features and weight features is constructed based on a 3-layer fully connected neural network, quantifying the influence weight of different state indicators on weight. This makes weight calculation no longer dependent on a single standard value, but can be dynamically corrected according to the actual state of the decoction pieces. This significantly reduces dosage errors caused by state differences such as adhesion, breakage, and dampness, ensuring accurate matching between effective weight and prescription requirements, and providing core guarantees for medication safety and efficacy.
[0015] 2. This AI-powered dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces establishes a dedicated variety database, supporting the storage and retrieval of decoction pieces with multiple varieties and weight gradients. Through an incremental learning mechanism, it continuously incorporates data on decoction pieces with new varieties and new states, constantly optimizing model performance. At the same time, it integrates automated modules such as automatic encoding, image segmentation, and similarity matching. From feature extraction to dosage correction, no manual intervention is required throughout the entire process. Review reminders are only triggered in extreme abnormal scenarios, significantly reducing reliance on the experience of professional personnel and improving dispensing efficiency. It is especially suitable for large-scale and diversified decoction piece dispensing scenarios. Attached Figure Description
[0016] Figure 1This is a schematic diagram of the overall structure of the AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to the present invention. Detailed Implementation
[0017] 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.
[0018] Please see Figure 1 As shown, the purpose of this embodiment is to provide an AI dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces, including a data acquisition unit, a feature extraction unit, an association evidence establishment unit, a weight feature correction unit, and a dispensing optimization unit; The data acquisition unit is used to establish an AI recognition module, collect historical image data of Chinese herbal medicine slices, establish a variety database based on the classification of Chinese herbal medicine slice varieties, and select standard image data for each Chinese herbal medicine slice in the variety database. In the data acquisition unit, an AI recognition module is established, which completes the feature extraction unit, the associated evidence establishment unit, the weight feature correction unit, and the adjustment and optimization unit. It integrates core functions such as image preprocessing, feature extraction, neural network training, similarity matching, and weight calculation, serving as a unified technical support carrier for feature extraction unit, association evidence establishment unit, weight feature correction unit, and adjustment and optimization unit; By connecting to an industrial camera with a multispectral module (deploying the camera at the gripping station of the Chinese herbal medicine dispensing table) responsible for controlling the dosage of Chinese herbal medicine slices, images of Chinese herbal medicine slices are acquired through the industrial camera, thereby obtaining historical image data and real-time image data to be optimized.
[0019] The following steps are taken: Extract the varieties of Chinese medicinal herbs from historical image data to obtain the varieties corresponding to each historical image data. Then, establish a dedicated variety database for each variety of Chinese medicinal herbs, and store the historical image data of the same variety of Chinese medicinal herbs in the corresponding variety database. The pre-trained variety classification model (based on ResNet50 transfer learning) in the AI recognition module identifies the variety of Chinese medicinal herbs corresponding to each historical image, outputs the variety label and confidence score (confidence score ≥ 0.95 is considered valid recognition), and then creates an independent variety database for each identified Chinese medicinal herb. Using an index structure of variety ID-image ID-weight data-collection parameters, all historical image data and related information of the same variety are classified and stored in the corresponding database. The variety database selects standard image data. By setting standard selection conditions, the database matches historical image data stored in the variety database with the standard selection conditions and selects historical image data that meets the standard conditions as standard image data. The standard selection conditions include a baseline state with no adhesion, no mold, and an integrity of more than 98%, and are associated with weight data recorded by an electronic scale.
[0020] Based on the set standard selection criteria, historical image data in the database of each variety are matched one by one. The AI recognition module automatically detects the adhesion, mold traces, integrity and other status indicators of the sliced medicinal materials in the images, and selects images that meet all the conditions as standard image data. The number of standard images for each variety and each weight gradient is ≥50, forming a standard image subset.
[0021] The feature extraction unit is used to acquire real-time image data to be optimized. The AI recognition module extracts bright and dark features from the real-time image data. Based on the neural network, the dark features are predicted and supplemented according to the bright features, and the dark features are transformed into predicted bright features. In the feature extraction unit, Chinese herbal medicine slices are encoded in real-time image data, and then image segmentation and extraction are performed based on each encoded Chinese herbal medicine slice to obtain the image data corresponding to each encoded Chinese herbal medicine slice; A dual coding rule of region + time sequence is adopted. First, the location regions of all Chinese herbal medicine pieces in the real-time image are identified by the target detection algorithm. A unique region code is assigned to each region. Combined with the image acquisition timestamp, a time sequence code is generated. Finally, a unique code for each Chinese herbal medicine piece is formed to avoid confusion among multiple pieces. Based on the coordinates of the corresponding medicinal slice area, an image segmentation algorithm is used to accurately segment the independent medicinal slice image data corresponding to each code. After segmentation, the image is cropped at the edges to remove redundant background pixels and retain only the effective area of the medicinal slice, ensuring that subsequent feature extraction focuses on the target medicinal slice.
[0022] A model of Chinese herbal medicine is established based on the image data corresponding to each coded Chinese herbal medicine slice. Then, the bright features are extracted from the Chinese herbal medicine slice model. The structure of the Chinese herbal medicine slice model is corrected based on the bright features. The bright features are then removed from the structure-corrected Chinese herbal medicine slice model, and the remaining model area is used as the dark features. Among them, the visible features are the surface features of the Chinese herbal medicine slices that are captured and recorded by an industrial camera in the model of Chinese herbal medicine slices; The features in the dark area are the surface features of the Chinese herbal medicine slices that were not captured and recorded by the industrial camera in the model. The steps are as follows: The segmented single-piece image data is input into a point cloud reconstruction algorithm. Combined with the texture and color information of the multispectral image, a three-dimensional mesh model is generated. This model fully represents the spatial morphology, surface texture, and color distribution of the slices, providing a digital carrier for the separation of light and dark features. Then, the shooting angle and field of view of the industrial camera are determined through camera calibration parameters. Surface areas within the field of view that can be captured and recorded by the camera are selected in the three-dimensional mesh model, and features are extracted from these areas to obtain the light features. Based on the extracted light features, the ICP (Iterative Closest Point) algorithm is used to align the feature points of the model with those of the actual captured image, correcting the spatial pose and surface details of the model to ensure consistency between the model and the actual slices in terms of morphology and color, and reducing feature extraction errors. Then, in the structurally corrected 3D mesh model, the regions corresponding to the bright features are removed, and the remaining regions not covered by the camera's field of view are the dark feature regions. Bright area features are combined with neural networks to supplement dark area features for prediction. An improved CycleGAN model is used, with three ResNet residual blocks added to the generator. The discriminator uses PatchGAN. Paired samples of bright area features and complete features generated by randomly occluding model regions in standard image data are used. The model generator is trained based on these paired samples. After training, the dark area features and the traditional Chinese medicine film model are input into the model generator, which then outputs the predicted bright area features corresponding to the dark area features. The steps are as follows: The generator G adopts an encoder-decoder structure. The encoder contains 4 convolutional layers (3×3 kernels, stride 2), with 3 ResNet residual blocks inserted in the middle (each residual block contains 2 convolutional layers + batch normalization + ReLU activation). The decoder contains 4 transposed convolutional layers (3×3 kernels, stride 2), and the output is a predicted complete feature with the same dimension as the input feature. Discriminator D adopts the PatchGAN structure, which contains 4 convolutional layers (4×4 kernels, stride 2), and outputs an N×N matrix (N is the feature map size / 8). Each element corresponds to the truth score of a local region in the input feature map, which enhances the accuracy of local feature discrimination. The Adam optimizer was used with β1=0.5, β2=0.999, ε=1e-8, and an initial learning rate of 0.0002. A linear decay strategy was adopted, which reduced the learning rate to 10% of the initial value when the training reached 50% of the total number of iterations, and then maintained at this learning rate until the end of training. The batch size was set to 16, and the total number of iterations was 200 epochs. Dropout layers (dropout rate 0.3) were added to both the generator and discriminator to prevent overfitting. The model is jointly optimized using adversarial loss, cycle consistency loss, and perceptual loss. The parameters of the generator G and discriminator D are updated through backpropagation, as shown in the following formula:
[0023] in, To cover the area, The number of vertices of the irregular polygon. Let be the pixel coordinates of the i-th vertex. Let be the offset radius of the i-th vertex. Let be the rotation angle of the i-th vertex, and ⋃ be the set merging symbol, used to connect multiple vertices to form a complete irregular polygonal occlusion region;
[0024] in, To combat the loss value, For positive generator (visible features → complete features). For discriminator, For true and complete feature vectors, The probability distribution represents the true and complete features. This is the mathematical expectation (mean calculation) of the true complete feature distribution. The score given by the discriminator for the truthfulness of the true complete feature x, with a value range of (0,1). For the eigenvectors of the visible area, The probability distribution of features in bright areas. To give the mathematical expectation of the characteristic distribution of bright areas, The generator produces a predicted complete feature vector based on the visible feature z. The score given by the discriminator for the realism of the generated feature G(z) is as follows: the closer it is to 0, the higher the confidence level of the feature is as a false feature.
[0025] in, , For reverse generator, The pseudo-bright features (simulating bright features after occlusion) generated by the generator based on the real complete features x. For the reverse generator The mapped back restores the complete features. To restore the complete features and the true complete features, the L1 norm (sum of absolute errors) is calculated. The feature vector is the real visible feature vector. The reverse generator is based on real bright features. The generated pseudo-complete features For the generator The restored bright features are mapped back. To restore the L1 norm of the bright features and the true bright features;
[0026] in, The perceptual loss value is used to measure the similarity between generated features and real features in the high-level semantic space. To predict the high-level semantic features extracted from the complete features by the VGG16relu3_3 layer, These are high-level semantic features extracted from real and complete features through VGG16relu3_3 layers;
[0027] in, The total loss value for model training is the weighted sum of the three types of losses. To combat the losses, For cycle consistency loss, To perceive loss.
[0028] The association evidence establishment unit is used to annotate the state features and weight features of historical image data in the variety database, perform image difference data analysis on standard image data and historical image data, and combine the obtained image difference data with the corresponding state features and weight features for association training, thereby constructing an association matrix of image difference data corresponding to weight features and state features. In the associated evidence establishment unit, the historical image data of the variety database is labeled with status features and weight features (directly associated with the actual weight data recorded by the electronic scale during collection, and manually entered or automatically associated with the weight field in the database during labeling). Image data that cannot be labeled is deleted, and only historical image data with status features and weight features are retained. Among them, status features include morphological features, color features, and integrity features, and weight features include actual weight data. After labeling using the LabelStudio tool, both the state features and weight features are converted into 64-dimensional standardized feature vectors.
[0029] The 12 quantized state features are arranged in the order of morphological features (4 items) → color features (4 items) → completeness features (4 items). Each feature is mapped to a 5-6 dimensional sub-vector (through unique encoding or normalization processing), and then concatenated to form a 64-dimensional initial state feature vector. The actual weight data is used as the core value and expanded into a 64-dimensional initial weight feature vector through feature expansion (such as weight gradient encoding, weight-volume correlation coefficient and other auxiliary features).
[0030] In the associated evidence establishment unit, the standard image data and historical image data of the same variety database are grouped according to the weight characteristics. Within each group, the image difference data and feature vector difference between the standard image data and the historical data are calculated. The image difference data and feature vector differences of all groups are summarized to establish an associated dataset. Image difference data is extracted from the associated dataset and combined with the corresponding state feature vector and weight feature vector to form basic training samples. Then, the basic training samples corresponding to the standard image data are combined with the basic training samples corresponding to the historical image data to form the initial training set data. The initial training dataset is then expanded and stratified by variety to form training set, validation set and test set. A three-layer fully connected neural network is used for training. The input layer is a 128-dimensional vector, the hidden layer contains ReLU activation function and dropout layer, and the output layer outputs a 64×64 correlation matrix. The input layer receives a 128-dimensional vector, which is formed by concatenating a 64-dimensional state feature vector and a 64-dimensional repetitive feature vector in sequence. Hidden layer 1 has 256 neurons and ReLU activation function (to enhance non-linear fitting ability). A dropout layer is added (dropout rate 0.3 to prevent overfitting). Hidden layer 2, with 128 neurons, ReLU activation function, and dropout layer (dropout rate 0.2). The output layer outputs a 64×64 dimension correlation matrix. The rows of the matrix correspond to the dimension of the state feature vector, the columns correspond to the dimension of the weight feature vector, and the elements are the correlation weights between the two. Among them, the 128-dimensional vector consists of a 64-dimensional state feature vector and a 64-dimensional Vic repetition feature vector; Training employs the Adam optimizer to configure training parameters and iterates using a cosine annealing learning rate decay strategy. Then, using the mean squared error (MSE) of the predicted and actual weight features as the loss function, optimization is achieved through gradient clipping and early stopping strategies. Finally, L2 normalization and outlier handling are applied to the correlation matrix to complete its construction, as shown in the following formula:
[0031] in, This is the mean squared error loss value. This represents the number of samples in the training batch. Let be the predicted weight feature vector of the i-th sample. Let i be the feature vector of the actual weight of the i-th sample;
[0032] in, The learning rate for the current epoch. The initial learning rate is set to 0.001. This represents the current training iteration number. The maximum number of iterations is 300. The minimum learning rate is set to 1e-6. ; in, For gradient clipping, This is the gradient clipping threshold, with a value of 1.0. This is the gradient vector calculated during the backpropagation process of the network. Let g be the L2 norm of the gradient vector g; The weight feature correction unit is used to match the light features and predicted light features with the image data in the corresponding variety database. Based on the matching results, standard samples are selected, and the weight features of the standard samples are summarized as the initial weight features. Then, the initial weight is combined with the correlation matrix to calculate the state correction amount and obtain the effective weight features. In the weight feature correction unit, the predicted bright features are concatenated with the bright features to form a 64-dimensional state feature vector, which is used as the feature vector of the real-time image data to be optimized. Principal component analysis was used to control both the standardized predicted bright feature vector and the bright feature vector to 32 dimensions. The bright feature vector (32 dimensions) and the predicted bright feature vector (32 dimensions) were concatenated in the order of bright feature vector (32 dimensions) + predicted bright feature vector (32 dimensions) to form a 64-dimensional state feature vector, which serves as the core feature representation of the real-time image data to be optimized. The state feature vector of the real-time image data to be optimized is matched with the state feature vector of the historical image data of the corresponding variety database to obtain the similarity between the real-time image data and the historical image data. Then, the top five historical image data with the highest similarity are selected as standard samples, and the average weight feature corresponding to the standard samples is summarized as the initial weight feature corresponding to the real-time image data. The 64-dimensional state feature vectors of all fully labeled historical image data in the corresponding variety database are retrieved to construct a feature vector retrieval library for this variety. The cosine similarity algorithm is used to calculate the similarity between the 64-dimensional state feature vector of the real-time image to be optimized and the feature vector of each historical image in the retrieval library, quantifying the degree of feature matching. The images are sorted from high to low similarity, and the top five historical image data are selected as standard samples to ensure the representativeness of the samples (the top five samples can balance the random error of a single sample). Then, the core weight value (the actual weight recorded by the electronic scale) of the weight feature vector corresponding to the five standard samples is extracted, and their arithmetic mean is calculated as the initial weight feature of the real-time image data. The initial weight feature is combined with the correlation matrix to calculate the state correction value. Then, the initial weight feature and the state correction value are added together to obtain the effective weight feature. The steps are as follows: The difference between the 64-dimensional state feature vector of the real-time image to be optimized and the 64-dimensional state feature vector of the corresponding standard image is calculated to obtain the state difference vector. The state difference vector is then multiplied with the trained 64×64 correlation matrix to obtain the state correction value, which reflects the influence of the state difference between the real-time image and the standard image on the weight. Finally, the initial weight feature is added to the state correction value to obtain the final effective weight feature.
[0033] The dispensing optimization unit is used to obtain the dispensing dosage requirements, and then combines the effective weight characteristics with the dispensing dosage requirements to provide optimization reminders.
[0034] In the dispensing optimization unit, the dispensing dosage requirement is obtained, and the effective weight characteristic is compared with the dispensing dosage requirement. When the effective weight characteristic is lower than the dispensing dosage requirement, the corresponding Chinese herbal medicine pieces are prompted to be supplemented to the dosage requirement value of the dispensing dosage. If the effective weight characteristic is higher than the required dosage, it is recommended to reduce the corresponding Chinese herbal medicine pieces to the required dosage value.
[0035] 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 preferred examples and are not intended to limit 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 dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces using AI, characterized in that: It includes a data acquisition unit, a feature extraction unit, a correlation evidence establishment unit, a weight feature correction unit, and an adjustment and optimization unit; The data acquisition unit is used to establish an AI recognition module, collect historical image data of Chinese herbal medicine slices, establish a variety database based on the classification of Chinese herbal medicine slice varieties, and select standard image data for each Chinese herbal medicine slice in the variety database. The feature extraction unit is used to acquire real-time image data to be optimized. The AI recognition module extracts bright and dark features from the real-time image data. Based on the neural network, the dark features are predicted and supplemented according to the bright features, and the dark features are transformed into predicted bright features. The association evidence establishment unit is used to annotate the historical image data of the variety database with state features and weight features, perform image difference data analysis on standard image data and historical image data, and combine the obtained image difference data with the corresponding state features and weight features for association training, thereby constructing an association matrix of image difference data corresponding to weight features and state features. The weight feature correction unit is used to perform similarity matching between the light features and the predicted light features and the image data in the corresponding variety database, filter standard samples according to the matching results, summarize the weight features of the standard samples as the initial weight features, and then combine the initial weight with the correlation matrix to calculate the state correction amount to obtain the effective weight features. The dispensing optimization unit is used to obtain the dispensing dosage requirements, and then combine the effective weight characteristics with the dispensing dosage requirements to provide optimization reminders.
2. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 1, characterized in that: In the data acquisition unit, an AI recognition module is established, which completes the feature extraction unit, the associated evidence establishment unit, the weight feature correction unit, and the adjustment and optimization unit. By connecting to an industrial camera that controls the dosage of Chinese herbal medicine slices and is equipped with a multispectral module, images of the Chinese herbal medicine slices are acquired through the industrial camera, thereby obtaining historical image data and real-time image data to be optimized.
3. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 2, characterized in that: The historical image data is used to extract the varieties of Chinese medicinal herbs, and the varieties of Chinese medicinal herbs corresponding to each historical image data are obtained. Then, a dedicated variety database is established for each variety of Chinese medicinal herbs, and the historical image data of the same variety of Chinese medicinal herbs are stored in the corresponding variety database. The variety database selects standard image data. By setting standard selection conditions, the database matches historical image data stored in the variety database with the standard selection conditions and selects historical image data that meets the standard conditions as standard image data. The standard selection conditions are that the state characteristics are no adhesion, no mold, and the integrity is higher than 98%, and the data is associated with the weight data recorded by the electronic scale.
4. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 2, characterized in that: In the feature extraction unit, the Chinese herbal medicine slices are encoded in the real-time image data, and then image segmentation and extraction are performed based on each encoded Chinese herbal medicine slice to obtain the image data corresponding to each encoded Chinese herbal medicine slice. A model of Chinese herbal medicine is established based on the image data corresponding to each coded Chinese herbal medicine slice. Then, the bright features are extracted from the Chinese herbal medicine slice model. The structure of the Chinese herbal medicine slice model is corrected based on the bright features. The bright features are then removed from the structure-corrected Chinese herbal medicine slice model, and the remaining model area is used as the dark features. Among them, the visible features are the surface features of the Chinese herbal medicine slices that are captured and recorded by an industrial camera in the model of Chinese herbal medicine slices; Dark features refer to the surface features of Chinese herbal medicine slices that were not captured or recorded by industrial cameras in the model.
5. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 4, characterized in that: The bright area features are combined with neural networks to predict and supplement the dark area features. Specifically, an improved CycleGAN model is used, with three ResNet residual blocks added to the generator and PatchGAN used as the discriminator. Paired samples of bright area features and complete features generated by randomly occluding the model region using standard image data are used. The model generator is trained based on the paired samples. After training, the dark area features and the traditional Chinese medicine film model are input into the model generator, and the model generator outputs the predicted bright area features corresponding to the dark area features.
6. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 5, characterized in that: In the associated evidence establishment unit, the historical image data of the variety database is labeled with status features and weight features. Image data that cannot be labeled is deleted, and only historical image data with status features and weight features are retained. Among them, status features include morphological features, color features, and integrity features, and weight features include actual weight data. After labeling using the LabelStudio tool, both the state features and weight features are converted into 64-dimensional standardized feature vectors.
7. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 6, characterized in that: In the associated evidence establishment unit, the standard image data and historical image data of the same variety database are grouped according to the weight characteristics. Within each group, the image difference data and feature vector difference between the standard image data and the historical data are calculated. The image difference data and feature vector differences of all groups are summarized to establish an associated dataset. Image difference data is extracted from the associated dataset and combined with the corresponding state feature vector and weight feature vector to form basic training samples. Then, the basic training samples corresponding to the standard image data are combined with the basic training samples corresponding to the historical image data to form the initial training set data. The initial training dataset is then expanded and stratified by variety to form training set, validation set and test set. A three-layer fully connected neural network is used for training. The input layer is a 128-dimensional vector, the hidden layer contains ReLU activation function and dropout layer, and the output layer outputs a 64×64 correlation matrix. Among them, the 128-dimensional vector consists of a 64-dimensional state feature vector and a 64-dimensional Vic repetition feature vector; Training uses the Adam optimizer to configure training parameters and completes iterations through a cosine annealing learning rate decay strategy. Then, the MSE of the predicted weight feature and the actual weight feature is used as the loss function, and gradient clipping and early stopping strategies are used for optimization. Finally, L2 normalization and outlier processing are performed on the correlation matrix to complete the construction of the correlation matrix.
8. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 1, characterized in that: In the weight feature correction unit, the predicted bright features and the bright features are concatenated into a 64-dimensional state feature vector, which is used as the feature vector of the real-time image data to be optimized. The state feature vector of the real-time image data to be optimized is matched with the state feature vector of the historical image data of the corresponding variety database to obtain the similarity between the real-time image data and the historical image data. Then, the top five historical image data with the highest similarity are selected as standard samples, and the average weight feature corresponding to the standard samples is summarized as the initial weight feature corresponding to the real-time image data. The initial weight feature is combined with the correlation matrix to calculate the state correction amount, and then the initial weight feature and the state correction amount are added together to obtain the effective weight feature.
9. The AI-based dynamic optimization system for dispensing dosage of traditional Chinese medicine decoction pieces according to claim 8, characterized in that: In the dispensing optimization unit, the dispensing dosage requirement is obtained, and the effective weight characteristic is compared with the dispensing dosage requirement. When the effective weight characteristic is lower than the dispensing dosage requirement, the corresponding Chinese herbal medicine pieces are reminded to be supplemented to the dosage requirement value of the dispensing dosage. If the effective weight characteristic is higher than the required dosage, it is recommended to reduce the corresponding Chinese herbal medicine pieces to the required dosage value.