Urine test classification model training method and system and readable storage medium
By acquiring and iterating the training of urine test sample data on the mobile terminal, the applicability of urine test methods under hardware updates and environmental changes is solved, and higher detection accuracy and consistency are achieved.
Patent Information
- Application Number
- CN202410042722.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-11
- Publication Date
- 2025-07-11
AI Technical Summary
Due to hardware updates and environmental changes in existing urine detection methods on mobile terminals, fixed-trained machine learning algorithms are difficult to apply, and the accuracy and consistency are insufficient.
By obtaining the sample set in the experimental environment, training the initial classification model, combining user operations and real environment data for iterative training, a final urine test classification model is formed, improving the applicability and accuracy of the model.
It improves the accuracy and consistency of the urine detection classification model, approaching or even exceeding the detection accuracy of traditional urine detection hardware devices.
Smart Images

Figure CN120298739A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and particularly to a method, system and readable storage medium for training a urine test classification model. Background Art
[0002] In recent years, with the improvement of the informatization level, especially the wide application of mobile terminal devices, in the field of in vitro diagnostic urine testing, more and more methods of interpreting urine test strips by combining a mobile phone camera through software methods have emerged. By obtaining the color of the test strip through various methods and obtaining semi-quantitative test results at different levels by judging the color threshold, this simple color comparison method is often inaccurate, greatly affected by the environment, and prone to jumping levels. Gradually, many manufacturers have introduced methods of artificial intelligence, machine learning and neural networks. By collecting experimental data or historical data and training algorithm models, the efficiency and accuracy are further improved. However, just doing this is not enough. New mobile terminals are constantly emerging on the market, and the hardware is constantly updated. There are always new changes in the camera imaging algorithms and color conversion algorithms optimized by different manufacturers, and the operating light environments and operating habits of different users are also different. Therefore, an existing set of fixed training machine learning algorithms for urine tests is difficult to have wide applicability. Summary of the Invention
[0003] To solve the above technical problems, this application provides a method, system and readable storage medium for training a urine test classification model.
[0004] In a first aspect, this application provides a method for training a urine test classification model, the method including:
[0005] Obtain a first sample set in an experimental environment, the first sample set including test strip types, color feature vector arrays, and labels set by users;
[0006] Extract the first sample set into a model trainer, train to obtain an initial classification model, and send the initial classification model to a server, and the server runs the initial classification model online;
[0007] Obtain initial urine test data in an actual environment, the initial urine test data including real urine test strip images, color feature vector arrays, and labels identified by the initial classification model;
[0008] Receive user selection operations and / or user annotation operations through a client, and classify the initial urine test data based on the user selection operations and / or the user annotation operations to obtain a second sample set;
[0009] The model trainer extracts the first sample set and the second sample set, trains them into a phased classification model, and uploads the phased classification model to the server; the server runs the phased classification model online;
[0010] Iteratively train the phased classification model based on historical urine test strip data to obtain a final urine test classification model.
[0011] In a second aspect, the present application provides a training system for a urine test classification model. The training system for the urine test classification model includes:
[0012] A first collection terminal for obtaining a first sample set in an experimental environment. The first sample set includes test strip types, color feature vector arrays, and labels set by users;
[0013] A model trainer for extracting the first sample set into the model trainer, training an initial classification model, sending the initial classification model to the server, and the server running the initial classification model online;
[0014] The server for running the initial classification model online;
[0015] A second collection terminal for obtaining initial urine test data in an actual environment. The initial urine test data includes real urine test strip images, color feature vector arrays, and labels identified by the initial classification model;
[0016] A client for receiving user selection operations and / or user annotation operations, and classifying the initial urine test data based on the user selection operations and / or the user annotation operations to obtain a second sample set;
[0017] The model trainer for extracting the first sample set and the second sample set and training to obtain a phased classification model, and uploading the phased classification model to the server;
[0018] The server is further used for running the phased classification model online;
[0019] The model trainer is further used for training the phased classification model multiple times based on historical urine test strip data to obtain a final urine test classification model.
[0020] In a third aspect, the present application provides a computer-readable storage medium storing a computer program, and when the computer program runs on a processor, it executes the training method for the urine test classification model provided in the first aspect.
[0021] The training method, system and readable storage medium of the urine test classification model provided by the present application effectively solve the weaknesses of insufficient samples in the experimental environment and insufficient representativeness of sample data. By continuously iteratively selecting real user urine test data and continuously training a new model online iteratively, the accuracy, accuracy and consistency of the classification model are effectively improved. The accuracy of the test results based on the urine test method of the acquisition terminal is improved to the same level or even higher than that of traditional urine test hardware devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] To more clearly illustrate the technical solutions of the present application, the accompanying drawings required for the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the protection scope of the present application. In each drawing, similar components are numbered similarly.
[0023] Figure 1 Fig. shows a schematic structural diagram of a training system of a urine test classification model provided by the present application;
[0024] Figure 2 Fig. shows a schematic flowchart of a training method of a urine test classification model provided by the present application;
[0025] Figure 3 Fig. shows another schematic flowchart of a training method of a urine test classification model provided by the present application;
[0026] Figure 4 Fig. shows a schematic diagram of a urine test strip image provided by the present application;
[0027] Figure 5 Fig. shows a schematic diagram of items of a urine test strip to be collected provided by the present application;
[0028] Figure 6 Fig. shows a schematic structural diagram of a first acquisition terminal provided by the present application;
[0029] Figure 7 Another schematic flowchart of a training method of a urine test classification model provided by the present application;
[0030] Figure 8 Another schematic flowchart of a training method of a urine test classification model provided by the present application;
[0031] Figure 9 Fig. shows a schematic structural diagram of a second acquisition terminal provided by the present application;
[0032] Figure 10 Fig. shows another schematic flowchart of a training method of a urine test classification model provided by the present application;
[0033] Figure 11A schematic structural diagram of the client provided by this application;
[0034] Figure 12 A schematic structural diagram of the server provided by this application;
[0035] Figure 13 Another schematic flow diagram of the training method of the urine test classification model provided by this application;
[0036] Figure 14 A schematic structural diagram of the model trainer provided by this application. Detailed implementation manners
[0037] Next, the technical solutions in this application will be clearly and completely described in conjunction with the accompanying drawings in this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments.
[0038] Generally, the components of this application described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of this application that is required to be protected, but only represents the selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative efforts belong to the scope of protection of this application.
[0039] In the following text, the terms "include", "have" and their cognates that can be used in various embodiments of this application are only intended to represent specific features, numbers, steps, operations, elements, components or combinations of the foregoing items, and should not be construed as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or combinations of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or combinations of the foregoing items.
[0040] In addition, the terms "first", "second", "third", etc. are only used for differentiating descriptions and cannot be understood as indicating or implying relative importance.
[0041] Unless otherwise limited, all terms (including technical terms and scientific terms) used here have the same meaning as those generally understood by those of ordinary skill in the art to which various embodiments of this application belong. The terms (such as those defined in a generally used dictionary) will be interpreted as having the same meaning as the contextual meaning in the relevant technical field and will not be interpreted as having an idealized meaning or being overly formal, unless clearly defined in various embodiments of this application.
[0042] Embodiment 1
[0043] The present application provides a training method for a urine test classification model. This method is applied to a training system for a urine test classification model. Refer to Figure 1 the training system for the urine test classification model shown in
[0044] Refer to Figure 2 . The training method for the urine test classification model includes steps S101 - S106. Each step will be described below with reference to the accompanying drawings.
[0045] Step S101: Obtain a first sample set in an experimental environment.
[0046] In this embodiment, the first sample set includes the test strip type, the color feature vector array, and the label set by the user.
[0047] It should be supplemented that for urine test strips of different specifications, whether they are dry chemical test strips or colloidal gold test strips, chemical reactions are continuously occurring after being immersed in urine, and the color is constantly changing; test strips with insufficient chemical reactions or overly long reaction times have color differences and cannot be used as sample data for the first collection terminal 100 and the second collection terminals 200.
[0048] Refer to Figure 3 . Step S101 includes:
[0049] Step S1011: Place the urine test strips to be collected with sufficient reactions one by one under the fixed bracket of the first collection terminal. Select the test strip type and items of each urine test strip to be collected through the first collection terminal, and set the corresponding label; obtain the initial urine test strip image captured by the camera through the first collection terminal. The initial urine test strip image includes a positioning block, a white balance color block, and a chemical reaction color block.
[0050] In this embodiment, the test strip types of each urine test strip to be collected include types such as dry chemical test strips and colloidal gold test strips, and the items of each urine test strip to be collected include bilirubin, ketone body, etc.
[0051] Refer to Figure 4 . The urine test strip image includes a white balance color block, a chemical reaction color block, a large - end positioning block P1, and a small - end positioning block P2. The image of other types of test strips may also have other distribution methods, which are not limited here.
[0052] Please refer to Figure 5 . The items of each urine test strip to be collected include bilirubin, ketone body, bilirubin, urobilinogen, glucose, white blood cells, nitrite, micro - albumin, protein, occult blood, creatinine, etc.
[0053] Step S1012: According to the type of test strip, determine the positions of the chemical reaction color blocks and the white balance color blocks through the positioning blocks of the initial urine test strip image.
[0054] In this embodiment, the types of test strips include dry chemical test strips, colloidal gold test strips and other types.
[0055] Step S1013: Perform white balance processing on the initial urine test strip image through the white balance color block to complete color correction and obtain the white balance processed test strip image.
[0056] Step S1014: Extract color features from the white balance processed urine test strip image according to the positions of the chemical reaction color blocks to form a color feature vector.
[0057] Step S1015: Combine the test strip type, color feature vector and label corresponding to each urine test strip to form the first sample set.
[0058] In this embodiment, the first acquisition terminal includes a marking module, a first positioning module, a first acquisition module and a first determination module.
[0059] The selection of the test strip type and item of each urine test strip to be collected and the setting of the corresponding label by the first acquisition terminal include:
[0060] Select the test strip type of the urine test strip to be collected through the marking module, and set the item, gear and label of the reaction color block of the urine test strip to be collected.
[0061] In this embodiment, when collecting dry chemical test strips, it supports collecting data of multiple items at the same time, such as collecting creatinine and urinary calcium at the same time; when collecting colloidal gold test strips, only the gear label needs to be set.
[0062] See Figure 6, the first acquisition terminal 100 includes a labeling module 110, a first positioning module 120, a first acquisition module 130, and a first determination module 140. The first positioning module 110 captures an image of the urine test strip to be detected with a complete reaction from the camera video stream as the initial urine test strip image. The first positioning module 120 converts the initial urine test strip image into the Mat format, and takes the scanning frame of the first acquisition terminal 100 as the region of interest. The initial urine test strip image is cropped through the region of interest to obtain a cropped urine test strip image. The cropped urine test strip image is converted from the RGB format to the first target image in the HSV format, and the first target image is subjected to channel segmentation to extract the S-channel Mat matrix of the first target image. The Otsu threshold method is used to perform binary processing on the S-channel Mat matrix to obtain a binary image. The morphological operation function is used to process the binary image to remove the noise points of the binary image and obtain a denoised image. All the contours of the denoised image are obtained by finding the boundary function. It is judged whether the number of the contour arrays is greater than or equal to the preset number of contours. If the number of the contour groups is less than the preset number of contours, it is determined that there is no valid test strip in the first target image region. If the number of the contour groups is greater than or equal to the preset number of contours, the interference contours are excluded according to the contour area threshold, whether the contour is a rectangle, the contour area ratio, the color of the contour center point, and the distance between the contours, and finally the two positioning blocks and their position information of the initial urine test strip image are found. According to the two positioning blocks, the position information, and the S-channel Mat matrix, the chemical reaction color block information is obtained.
[0063] Exemplarily, the first positioning module 120 captures an image of the test strip with a complete reaction to be detected from the camera video stream, converts the test strip image into the Mat format of Opencv, takes the scanning frame on the scanning interface of the first acquisition terminal 100 as the region of interest (ROI), and crops the test strip image through the ROI. The positioning process is performed based on the cropped image. The urine test strip image to be detected is converted from the RGB format to the first target image in the HSV format, and the first target image is subjected to channel segmentation. The S-channel Mat matrix of the first target image is extracted, and the Otsu threshold method (OSTU) is used to perform binary processing on the S-channel Mat matrix to obtain a binary image. Further, the morphological operation functions erosion (erode) and dilation in Opencv are used for processing to remove the noise points and obtain a denoised image.
[0064] Further, all contours are obtained through the boundary-finding function (findContours function) of Opencv. It is judged that the number of the contour arrays is greater than or equal to 2 (for example, the preset number of contours is 2, and it can also be other values). If it is less than 2, there is no valid test strip in the first target image area. According to several factors such as the contour area threshold, whether the contour is a rectangle, the contour area ratio, the color of the contour center point, and the distance between contours, the interference contours are excluded, and finally two positioning blocks and the position information are found.
[0065] In this embodiment, the first acquisition module 130 calculates the center point position of each reaction color block according to the two positioning blocks and their position information; color feature vectors are extracted at the center point positions of each reaction color block corresponding to the test strip image after white balance processing; the first determination module 140 determines the validity of the color feature vectors acquired each time, and combines the valid color features into the color feature vector array.
[0066] Exemplarily, the first acquisition module 130 acquires chemical reaction color block information according to the positioning block information and the Mat of the test strip image within the ROI. The center point position of each reaction color block is calculated through the positions of the two positioning blocks; for the dry chemical test strip, RGB, HSV, and LAB color space data are taken; for the colloidal gold test strip, in addition to taking RGB / HSV / LAB color data, color feature data such as mean and variance are also taken. The first determination module 140 determines the validity of the color feature vector data acquired each time, for example, the color value cannot be pure white or pure black, etc., and the valid color feature vectors are added to the color feature vector array.
[0067] When enough color feature vector data is collected (such as 20 valid data), the first determination module 140 sends the color feature vector data to the server 400 through the HTTP interface. Information such as the current successful collection of the preset number of data, the network abnormal / normal state, and the failure of image positioning will be displayed on the interface of the first collection terminal 100. The user clicks the "Stop" button to stop the collection process.
[0068] Exemplarily, the urine test strips with sufficient reaction are placed one by one under the fixed bracket of the first collection terminal 100. The first collection terminal 100 selects the test strip type and items (such as bilirubin, ketone body, etc.), sets the corresponding labels, and clicks the start button to start the collection process. The first collection terminal 100 captures the camera image; two test strip positioning blocks on the image are found (see Figure 4The big-end positioning block P1 and the small-end positioning block P2) in it are used to find the complete test strip image; the clarity of the test strip image is judged through an image algorithm; according to the type of test strip, the positions of each chemical reaction color block and the white balance color block are analyzed and calculated through the positioning block; the test strip image is subjected to white balance processing through the white balance color block to complete color correction. On the image after white balance processing, color features are extracted according to the color block coordinates to form a color feature vector; the collected test strip type, color feature vector, and label information are uploaded to the server 400 through the HTTP interface. The server 400 stores the first sample set collected by the first collection terminal 100 in the database.
[0069] In step S102, the first sample set is extracted to a model trainer, and an initial classification model is trained and sent to the server, and the server runs the initial classification model online.
[0070] In this embodiment, the first sample set obtained by the model trainer 500 includes a number of data, which is downloaded from the database of the server 400 and converted into a text format initial sample set. The initial sample set is input into machine learning model software, such as a random forest classification algorithm or a support vector machine classification algorithm, to obtain an initial classification model. After the accuracy verification of the initial classification model algorithm reaches the standard, it is uploaded to the server 400.
[0071] See Figure 7 , step S102 includes steps S1021 - S1023.
[0072] In step S1021, the model trainer converts the first sample set into a text format initial sample set;
[0073] In step S1022, the initial sample set is input into the model trainer to obtain the initial classification model;
[0074] In step S1023, when the initial classification model meets the accuracy verification standard, the initial classification model is uploaded to the server.
[0075] In this way, preliminary model training can be carried out to obtain an initial classification model, which can be used for the recognition and classification of urine test strip images.
[0076] In step S103, initial urine test data in the actual environment is obtained.
[0077] In one embodiment, the initial urine test data includes a real urine test strip image, an array of color feature vectors, and a label identified by the initial classification model.
[0078] See Figure 8, step S103 includes steps S1031 - S1034.
[0079] In step S1031, place the actual urine test strip under the bracket of the second acquisition terminal, obtain the actual test strip image to be detected captured by the camera through the second acquisition terminal, locate the complete urine test strip image through the positioning block of the actual test strip image to be detected, and determine the test strip type of the actual test strip image to be detected based on the color, area, and distance information of the positioning block.
[0080] In this embodiment, the second acquisition terminal 200 supports the software and hardware systems of different manufacturers of iPhone and Android systems. Different software and hardware imaging algorithms will cause certain differences in the output images. The light environment, operating habits of the user operating the second acquisition terminal 200, and the reaction time of the test strip will all cause differences in the quality and color of the urine test strip image. Widely adopting a variety of urine test strip images collected by the second acquisition terminal 200 with different software and hardware systems in these specific environments can cover a variety of image features and can train a more applicable classification model. Place the fully reacted urine test strip under the camera of the second acquisition terminal 200 and click the start button to start the detection and acquisition process.
[0081] In step S1032, determine the clarity of the actual test strip image to be detected through an image analysis algorithm; determine the positions of the chemical reaction color blocks and the white balance color block of the actual test strip image to be detected through the positioning block of the actual test strip image to be detected, and perform white balance processing on the actual test strip image to be detected through the white balance color block of the actual test strip image to complete color correction and obtain the corrected actual test strip image.
[0082] In this embodiment, the second acquisition terminal 200 captures a camera image; find the complete test strip by searching for two test strip positioning blocks on the image (see Figure 3 , the large - end positioning block P1 and the small - end positioning block P2); calculate the test strip type (the test strip type can be a dry - chemical test strip, a colloidal gold test strip, etc.) based on the color, area, and distance information of the positioning block; judge the clarity of the test strip image through an image algorithm; analyze and calculate the positions of the chemical reaction color blocks and the white balance color block through the positioning block; perform white balance processing on the test strip image through the white balance color block to complete color correction. On the image after white balance processing, extract color features according to the color block coordinates to form a color feature vector.
[0083] In step S1033, extract color features according to the color block coordinates in the corrected actual test strip image to form a color feature vector; input multiple color feature vectors one by one into the initial classification model or the stage classification model to calculate the label data of the actual test strip image.
[0084] Step S1034, intercepting a second target image including a urine test paper image from the actual test paper image to be tested after the deviation correction, and generating the initial urine test data according to the actual test paper image to be tested after the deviation correction, the second target image, the color feature vector group of the actual test paper image to be tested after the deviation correction, and the label data.
[0085] Exemplarily, the second acquisition terminal 200 cyclically captures camera images, and stops acquisition after the number of successful automatically acquired and recognized image results reaches a threshold. Each image feature corresponds to a color feature vector, and multiple color feature vectors form a color feature vector group. The test paper type and the color feature vector group are uploaded to the server 400 through the HTTP interface.
[0086] Exemplarily, after the last result is identified, the second acquisition terminal 200 uses the rectangular border algorithm of Opencv (for example, the boundingRect() circumscribed rectangle method) to extract an image containing only the urine test strip. The test strip image is uploaded to the server 400, and the test strip image is associated with the test result. The received color feature vector group is input one by one into the running initial or intermediate classification algorithm model to calculate the result label, and then the final test result is sent to the second acquisition terminal 200. The server 400 stores the test data collected by the second acquisition terminal 200 and the calculated label data in a database.
[0087] See also Figure 9 , the second acquisition terminal 200 includes a second positioning module 210, a second acquisition module 220 and a second determination module 230. The actual test paper image to be tested taken by the camera is acquired through the second acquisition terminal 200, the complete urine test paper image is located through the positioning block of the actual test paper image to be tested, and the test paper type of the actual test paper image to be tested is determined through the color, area and distance information of the positioning block; the actual test paper image to be tested with the reaction completed to be detected is captured from the camera video stream through the second positioning module 210, and the positioning block position information of the actual test paper image to be tested is found, and the clarity of the actual test paper to be tested is judged; the chemical reaction color block information is acquired according to the positioning block information of the actual test paper image and the test paper image Mat matrix within the area of interest through the second acquisition module 220, and the color characteristics of each reaction color block are read; the validity of the feature vector data acquired each time is determined through the second determination module 230; when the preset number of feature vector data acquired is valid, the valid preset number of feature vector data is sent to the server through the HTTP interface.
[0088] Exemplarily, the second positioning module 210 captures an image of the test strip with the reaction completed to be detected from the camera video stream, finds the position information of the positioning block, and determines the clarity of the test strip image. The second acquisition module acquires the chemical reaction color block information according to the positioning block information and the Mat matrix of the test strip image within the ROI range. Read the color characteristics of each reaction color block. As shown in Figure 5 The 14 dry chemical test strips shown will read 14 color characteristic groups accordingly. The second determination module 230 determines the validity of the feature vector data obtained each time. For example, the color value cannot be close to or equal to pure white, pure black, etc. The valid data is added to the feature vector array. After collecting enough color feature vector data (such as 11 valid data), the second determination module 230 sends the data to the server 400 through the HTTP interface. The server 400 returns the detection result calculated by the classification model to the second collection terminal 200. The second collection terminal 200 presents the result to the user, ending the current collection and detection process.
[0089] Step S104, receive the user's selection operation and / or user annotation operation through the client, and classify the initial urine test data based on the user's selection operation and / or the user's annotation operation to obtain a second sample set.
[0090] In this embodiment, the client 300 allows multiple people to operate online simultaneously, provides an online annotation port based on the browser page. By viewing the online images and corresponding color characteristics saved by the browsing server, a person can visually observe the label information or gear information of the image. The label information can be represented by numbers, for example, 1, 2, 3, 4, 5, etc. The gear information can be represented by multiple plus signs such as +, ++, etc. Combining the color feature vector and the predicted label, the representative color feature vector and the modified or unmodified label are converged and stored in the server as new second sample data.
[0091] In this embodiment, the second sample includes the color feature vector information of the actual urine test strip image generated after the model runs online, the actual urine test strip image, and the label classification information obtained by the classification model running online for the actual urine image recognition.
[0092] In this embodiment, the server 400 obtains or provides data to other devices or modules through the Web HTTP service interface. The server 400 stores the first sample data, the second sample data, and multiple versions of the classification model, and the multiple versions of the classification model include the initial classification model, the intermediate classification model, the phased classification model, etc.
[0093] In this embodiment, the client 300 online previews and views the color feature vector group data, associated test strip images, and urine test results collected by the second collection terminal 200. The consistency between the manually visually judged results and the image test results is determined, the reasons for the inconsistency are analyzed, and whether this record should be classified into the second sample set. Appropriate test data is selected and added to the second sample set. If it is manually determined that the test results are inconsistent with the test results recognized by the classification model, the corresponding result label can be modified, and then the test data record is added to the second sample set.
[0094] In this embodiment, based on the client 300, model algorithm training can be initiated online, training results and accuracy can be viewed, historical model data can be viewed, and a classification algorithm model that meets the conditions can be applied and run.
[0095] See Figure 10 , step S104 includes:
[0096] Step S1041, display multiple urine test data collected by the second collection terminal through the client, and each urine test data includes color feature vector group data, associated test strip images, and urine test results.
[0097] Step S1042, determine the first target test data for which the manually judged test results are consistent with the urine test results based on the user annotation operation, and store the first target test data in the second sample set.
[0098] Step S1043, determine the second target test data for which the manually judged test results are inconsistent with the urine test results based on the user selection operation, modify the second target test data to the manually judged test results to obtain the modified test data, and store the modified test data in the second sample set.
[0099] See Figure 11 , the client 300 includes a third acquisition module 310 and a third determination module 320. Exemplarily, the third acquisition module 310 obtains the detection records and detection results generated by the second collection terminal 200 from the server 400 through an HTTP interface. The content is displayed in a list, including detection items, detection results, and associated collected test strip images. The color feature values are displayed by mouse click and floating window. The detection results and items, and the test strip images are directly displayed on the list for convenient and quick browsing. The third determination module facilitates manual archiving of the complete detection record feature vectors or certain items in the record into the second sample set, and the corresponding result label can be modified before submission. The third determination module 320 initiates model training, views the model training process, and views the model training results. Runs any type of urine test classification model stored in the server 400.
[0100] Step S105, the model trainer extracts the first sample set and the second sample set, trains them into a phased classification model, and uploads the phased classification model to the server; the server runs the phased classification model online.
[0101] See Figure 12 , the fourth acquisition module 410 of the server 400 receives the first sample set and urine test data, and stores them in the database. Provide external query and acquisition interfaces. The prediction module 420 inputs the color feature vector sample of the urine test image into the model trainer to obtain an intermediate classification result. The update module 430 includes a first update sub-module 431 and a second update sub-module 432. The first update sub-module 431 is used to update the second sample set; provide external query and acquisition interfaces.
[0102] The second update sub-module 432 is used to update the classification model data and maintain the model historical data. The fourth determination module 440 is used to run the classification model algorithm and count the running status.
[0103] In this embodiment, the model trainer reads the first sample set and the second sample set maintained by the server 400, and automatically completes model training under the instruction of the client 300 and uploads the trained classification model to the server.
[0104] See Figure 13 , step S105 includes:
[0105] Step S1051, download the first sample set and the second sample set through the model trainer, convert them into an overall sample set in text format, and split the overall sample set into a training sample set and a test sample set.
[0106] Step S1052, input the training sample set into the model trainer for training to obtain an intermediate classification model.
[0107] Step S1053, verify the intermediate classification model through the test sample set, and determine the intermediate classification model with qualified accuracy verification as the phased classification model.
[0108] See Figure 14 , the fifth acquisition module 510 obtains the first sample set and the second sample set from the server 400; the training module 520 adjusts the model parameters of the machine learning model (for example, various types of classification models) according to the obtained sample set for training algorithms and continues training until the training stop condition is met and then ends the training. The fifth determination module 530 uploads the trained model that meets the accuracy requirements back to the server 400.
[0109] Step S106: Iteratively train the stage classification model based on historical urine test strip data to obtain a final urine test classification model.
[0110] In this embodiment, through the long-term accumulation of historical urine test strip data by the second collection terminal 200, the existing classification model is trained through multiple rounds of periodic iteration. Through accuracy comparison and manual observation, a final urine test classification model with high accuracy can be obtained ultimately.
[0111] The training method of the urine test classification model provided in this embodiment effectively solves the weaknesses of insufficient sample in the experimental environment and insufficient representativeness of sample data. By continuously iteratively selecting real user urine test data and continuously training a new model online, the accuracy, accuracy, and consistency of the classification model are effectively improved. The accuracy of the detection results of the urine test method based on the collection terminal is improved to the same level or even higher than that of traditional urine test hardware devices.
[0112] Embodiment 2
[0113] In addition, the present application provides a training system for a urine test classification model, which includes:
[0114] A first collection terminal, configured to obtain a first sample set in an experimental environment, where the first sample set includes a test strip type, a color feature vector array, and a label set by a user;
[0115] A model trainer, configured to extract the first sample set into the model trainer, train an initial classification model, send the initial classification model to a server, and the server runs the initial classification model online;
[0116] The server is configured to run the initial classification model online;
[0117] A second collection terminal, configured to obtain initial urine test data in an actual environment, where the initial urine test data includes a real urine test strip image, a color feature vector array, and a label identified by the initial classification model;
[0118] A client, configured to receive a user selection operation and / or a user annotation operation, and classify the initial urine test data based on the user selection operation and / or the user annotation operation to obtain a second sample set;
[0119] A model trainer, configured to extract the first sample set and the second sample set and train a stage classification model, and upload the stage classification model to the server;
[0120] The server is further configured to run the stage classification model online;
[0121] The model trainer is further configured to train the stage classification model multiple times based on historical urine test strip data to obtain a final urine test classification model.
[0122] The training system for the urine test classification model provided in this embodiment can implement the training method for the urine test classification model provided in Embodiment 1. To avoid repetition, it will not be elaborated here.
[0123] The training system for the urine test classification model provided in this embodiment effectively solves the weaknesses of insufficient samples in the experimental environment and insufficient representativeness of sample data. By continuously iteratively selecting real user urine test data and continuously performing online iterative training on the new model, the accuracy, precision, and consistency of the classification model are effectively improved. The accuracy of the test results based on the urine test method of the acquisition terminal is improved to the same level as or even higher than that of traditional urine test hardware devices.
[0124] Embodiment 3
[0125] This application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the training method for the urine test classification model provided in Embodiment 1.
[0126] In this embodiment, the computer-readable storage medium can be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.
[0127] The computer-readable storage medium provided in this embodiment can implement the training method for the urine test classification model provided in Embodiment 1. To avoid repetition, it will not be elaborated here.
[0128] It should be noted that in this article, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article, or terminal comprising the element.
[0129] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present application.
[0130] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific implementation manners. The above specific implementation manners are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all of them fall within the protection scope of the present application.
Claims
1. A training method for a urine test classification model, characterized in that, Including: Obtain a first sample set in an experimental environment, where the first sample set includes test strip types, color feature vector arrays, and labels set by users; Extract the first sample set into a model trainer, train an initial classification model, send the initial classification model to a server, and the server runs the initial classification model online; Obtain initial urine test data in an actual environment, where the initial urine test data includes real urine test strip images, color feature vector arrays, and labels identified by the initial classification model; Receive a user selection operation and / or a user annotation operation through a client, and classify the initial urine test data based on the user selection operation and / or the user annotation operation to obtain a second sample set; The model trainer extracts the first sample set and the second sample set, trains them into a stage classification model, and uploads the stage classification model to the server; The server runs the stage classification model online; Perform iterative training on the stage classification model based on historical urine test strip data to obtain a final urine test classification model.
2. The method according to claim 1, characterized in that, The obtaining of the first sample set in the experimental environment includes: One by one, place the urine test strips to be collected with sufficient reaction under the fixed bracket of the first collection terminal, select the test strip type and items of each urine test strip to be collected through the first collection terminal, and set corresponding labels; obtain the initial urine test strip image captured by the camera through the first collection terminal, where the initial urine test strip image includes a positioning block, a white balance color block, and a chemical reaction color block; According to the test strip type, determine the positions of the chemical block and the white balance color block through the positioning block of the initial urine test strip image; Perform white balance processing on the initial urine test strip image through the white balance color block to complete color correction and obtain a white balance processed test strip image; Extract color features in the white balance processed test strip image according to the positions of the chemical reaction color blocks to form color feature vectors; Form the first sample set with the test strip type, color feature vector, and label corresponding to each urine test strip.
3. The method according to claim 2, wherein The first collection terminal includes a marking module, a first positioning module, a first obtaining module, and a first determining module. The selecting of the test strip type and items of each urine test strip to be collected through the first collection terminal and setting corresponding labels includes: Select the test strip type of the urine test strip to be collected through the marking module, and set the items, gears, and labels of the reaction color blocks of the urine test strip to be collected; The obtaining of the initial urine test strip image captured by the camera through the first collection terminal includes: Capture an image of the urine test strip to be detected with complete reaction from the camera video stream through the first positioning module as the initial urine test strip image; The determining of the positions of the chemical block and the white balance color block through the positioning block of the initial urine test strip image according to the test strip type includes: Convert the initial urine test strip image into a Mat format through the first obtaining module, use the scanning frame of the first collection terminal as the region of interest, and crop the initial urine test strip image through the region of interest to obtain a cropped urine test strip image; Convert the cropped urine test strip image into a first target image in HSV format from the RGB format, perform channel segmentation on the first target image, extract the S-channel Mat matrix of the first target image, and perform binarization processing on the S-channel Mat matrix using the Otsu threshold method to obtain a binary image; Process the binary image using a morphological operation function to remove the noise points in the binary image and obtain a denoised image; Obtain all the contours of the denoised image through a boundary finding function; Judge whether the number of contour arrays is greater than or equal to a preset number of contours. If the number of contour groups is less than the preset number of contours, it is determined that there is no valid test strip within the first target image area; If the number of contour groups is greater than or equal to the preset number of contours, exclude interfering contours according to the contour area threshold, whether the contour is rectangular, the contour area ratio, the color of the contour center point, and the distance between contours, and finally find the two positioning blocks and their position information of the initial urine test strip image; Obtain chemical reaction color block information according to the two positioning blocks, position information, and the S-channel Mat matrix; Extract color features at the positions of each chemical reaction color block in the test strip image after white balance processing to form a color feature vector, including: The first acquisition module calculates the center point position of each reaction color block according to the two positioning blocks and their position information; extracts the color feature vector at the center point position of each reaction color block corresponding to the test strip image after white balance processing; The first determination module determines the validity of the color feature vector obtained each time, and combines the valid color features into the color feature vector array.
4. The method according to claim 1, wherein Input the first sample set into a model trainer, train to obtain an initial classification model, and send the initial classification model to the server, including: The model trainer converts the first sample set into an initial sample set in text format; Input the initial sample set into the model trainer to obtain the initial classification model; When the initial classification model meets the accuracy verification standard, upload the initial classification model to the server.
5. The method according to any one of claims 1 to 4, characterized in that, Obtain the initial urine test data in the actual environment, including: Place the actual urine test strip under the bracket of the second acquisition terminal, obtain the actual test strip image to be detected captured by the camera through the second acquisition terminal, locate the complete urine test strip image through the positioning block of the actual test strip image to be detected, and determine the test strip type of the actual test strip image to be detected through the color, area, and distance information of the positioning block; Determine the clarity of the actual test strip image to be detected through an image analysis algorithm; determine the positions of the chemical reaction color blocks and the white balance color block of the actual test strip image to be detected through the positioning block of the actual test strip image to be detected, and perform white balance processing on the actual test strip image to be detected through the white balance color block of the actual test strip image to complete color correction and obtain the corrected actual test strip image to be detected; Extract color features from the corrected actual test strip image to be inspected according to the color block coordinates to form a color feature vector; input multiple color feature vectors one by one into the initial classification model or the stage classification model to calculate the label data of the actual test strip image to be inspected. Intercept a second target image containing the urine test strip image from the corrected actual test strip image to be inspected, and generate the initial urine test data according to the corrected actual test strip image, the second target image, the color feature vector group of the corrected actual test strip image, and the label data.
6. The method according to any one of claims 1-4, characterized in that The second acquisition terminal includes a second positioning module, a second acquisition module, and a second determination module. The acquisition of the initial urine test data in the actual environment includes: Obtain the actual test strip image to be inspected captured by the camera through the second acquisition terminal, locate the complete urine test strip image through the positioning block of the actual test strip image, and determine the test strip type of the actual test strip image through the color, area, and distance information of the positioning block. Capture the actual test strip image that has completed the reaction to be detected from the camera video stream through the second positioning module, find the position information of the positioning block of the actual test strip image, and judge the clarity of the actual test strip. Obtain the chemical reaction color block information through the second acquisition module according to the positioning block information of the actual test strip image and the Mat matrix of the test strip image within the region of interest, and read the color features of each reaction color block. Determine the validity of the feature vector data obtained each time through the second determination module. When a preset number of feature vector data are collected and valid, send the valid preset number of feature vector data to the server through the HTTP interface.
7. The method according to any one of claims 1-4, characterized in that, The classification of the initial urine test data based on the user selection operation and / or the user annotation operation received by the client includes: Display multiple urine test data collected by the second acquisition terminal through the client. Each urine test data includes color feature vector group data, the associated test strip image, and the urine test result. Determine the first target test data for which the manually determined test result is consistent with the urine test result based on the user annotation operation, and store the first target test data in the second sample set. Determine the second target test data for which the manually determined test result is inconsistent with the urine test result based on the user selection operation, modify the second target test data to the manually determined test result to obtain the corrected test data, and store the corrected test data in the second sample set.
8. The method according to any one of claims 1 to 4, characterized in that, The extraction of the first sample set and the second sample set to the model trainer and the training into a stage classification model includes: Download the first sample set and the second sample set through the model trainer, convert them into an overall sample set in text format, and split the overall sample set into a training sample set and a test sample set. Input the training sample set into the model trainer for training to obtain an intermediate classification model. Verify the intermediate classification model through the test sample set, and determine the intermediate classification model with qualified accuracy verification as the phased classification model.
9. A training system for a urine test classification model, characterized in that, Including: A first acquisition terminal for obtaining a first sample set in an experimental environment, where the first sample set includes test strip types, color feature vector arrays, and labels set by users; A model trainer for extracting the first sample set into the model trainer, training to obtain an initial classification model, and sending the initial classification model to the server, where the server runs the initial classification model online; The server for running the initial classification model online; A second acquisition terminal for obtaining initial urine test data in an actual environment, where the initial urine test data includes real urine test strip images, color feature vector arrays, and labels identified through the initial classification model; A client for receiving user selection operations and / or user annotation operations, and classifying the initial urine test data based on the user selection operations and / or the user annotation operations to obtain a second sample set; A model trainer for extracting the first sample set and the second sample set and training to obtain a phased classification model, and uploading the phased classification model to the server; The server is further used for running the phased classification model online; The model trainer is further used for training the phased classification model multiple times based on historical urine test strip data to obtain a final urine test classification model.
10. A computer-readable storage medium, characterized in that, It stores a computer program, and when the computer program runs on a processor, it executes the training method of the urine test classification model according to any one of claims 1 to 8.
Citation Information
Cited By
Grading method and device for urine protein detection
CN121483441A