Label generation method, model training and measurement method, device, equipment and medium
By employing edge detection and label adjustment methods in image measuring devices, the problem of low labeling efficiency in sample images is solved, achieving efficient and accurate label generation.
Patent Information
- Application Number
- CN202511528434.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2045-10-24
AI Technical Summary
Traditional image measuring instruments have low efficiency in labeling sample images and require a lot of manual operation.
Scanned images are acquired using an image measurement device, feature measurement regions are drawn for edge detection, initial labels are generated based on the edge detection results, and target labels are obtained by adjusting them according to the actual edge conditions.
It enables the rapid and accurate generation of image labels, improving label generation efficiency and accuracy while reducing manual operations.
Smart Images

Figure CN120997601B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a label generation method, a model training method and a measurement method, device, computer equipment, computer readable storage medium and computer program product. BACKGROUND
[0002] An image measurement device (such as an image measuring instrument or a flash measuring instrument) can realize precise measurement of surface size, contour, angle, position and geometric tolerance of various complex parts. In actual application, the geometric features (such as planes, lines and points) of a workpiece can be extracted by the image measuring instrument, the length or angle information of the geometric features can be calculated, and then it can be judged whether the machining precision of the workpiece meets the requirements. With the rapid development of artificial intelligence technology, image measurement can be carried out based on an artificial intelligence (AI) model. However, when training the AI model in the image measuring instrument, a large number of sample images are often required, and each sample image needs to be labeled.
[0003] In the traditional technology, when labeling the sample images, it is often drawn one by one by artificial, which needs a lot of repetitive labor, and the efficiency of label generation is low. SUMMARY
[0004] Therefore, it is necessary to provide a label generation method, device, computer equipment, computer readable storage medium and computer program product capable of improving the efficiency of label generation in view of the above technical problems.
[0005] In a first aspect, the present application provides a label generation method applied to an image measurement device, comprising:
[0006] acquiring a scanning image by using the image measurement device;
[0007] drawing a feature measurement region in the scanning image to perform edge detection, so as to obtain an edge detection result of a target edge in the feature measurement region;
[0008] obtaining a to-be-recognized image based on the feature measurement region and the scanning image, and obtaining an initial label of the to-be-recognized image based on the edge detection result;
[0009] adjusting the initial label according to a real edge condition corresponding to the to-be-recognized image, to obtain a target label of the to-be-recognized image.
[0010] In a second aspect, the present application further provides a label generation device, comprising:
[0011] An edge detection module is configured to acquire a scan image by using the image measuring device, and perform edge detection on a feature measurement region in the scan image to obtain an edge detection result of a target edge in the feature measurement region.
[0012] A label acquisition module is configured to obtain a to-be-recognized image based on the feature measurement region and the scan image, and obtain an initial label of the to-be-recognized image based on the edge detection result.
[0013] A label adjustment module is configured to adjust the initial label according to a real edge condition corresponding to the to-be-recognized image to obtain a target label of the to-be-recognized image.
[0014] In a third aspect, the present application provides a computer device, including a memory and a processor, the memory stores a computer program, and the processor implements the steps of the label generation method provided in the first aspect when executing the computer program.
[0015] In a fourth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the label generation method provided in the first aspect when executed by a processor.
[0016] In a fifth aspect, the present application provides a computer program product, including a computer program, and the computer program implements the steps of the label generation method provided in the first aspect when executed by a processor.
[0017] In a sixth aspect, the present application provides a model training method, including:
[0018] Obtaining a to-be-recognized image with a label generated according to the label generation method;
[0019] Training a candidate detection model based on the to-be-recognized image and the target label of the to-be-recognized image until a training condition is reached to obtain a target detection model.
[0020] In a seventh aspect, the present application provides a model training device, including:
[0021] An image acquisition module is configured to acquire a to-be-recognized image with a label generated according to the label generation method;
[0022] A model training module is configured to train an initial detection model based on the to-be-recognized image and the target label of the to-be-recognized image until a training condition is reached to obtain a target detection model.
[0023] In an eighth aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the model training method in the sixth aspect when executing the computer program.
[0024] In a ninth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the model training method in the sixth aspect when executed by a processor.
[0025] In a tenth aspect, the present application provides a computer program product, comprising a computer program, and the computer program implements the steps of the model training method in the sixth aspect when executed by a processor.
[0026] In an eleventh aspect, the present application provides a measurement method, comprising:
[0027] obtaining a target image corresponding to a to-be-measured object;
[0028] performing edge detection on the target image by using a target detection model obtained based on the model training method to obtain a target edge;
[0029] determining a target size of the target edge, and determining a measurement result of the to-be-measured object based on the target size.
[0030] In a twelfth aspect, the present application provides a measurement device, comprising:
[0031] an image obtaining module, configured to obtain a target image corresponding to a to-be-measured object;
[0032] an edge detecting module, configured to perform edge detection on the target image by using a target detection model obtained based on the model training method to obtain a target edge;
[0033] a result determining module, configured to determine a target size of the target edge, and determine a measurement result of the to-be-measured object based on the target size.
[0034] In a thirteenth aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the measurement method in the eleventh aspect when executing the computer program.
[0035] In a fourteenth aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program implements the steps of the measurement method in the eleventh aspect when executed by a processor.
[0036] In a fifteenth aspect, the present application also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the measurement method of the eleventh aspect.
[0037] The label generation method, the model training method and the measurement method, the device, the computer device, the computer readable storage medium and the computer program product can obtain a scanning image by using an image measurement device, perform edge detection on a feature measurement region drawn in the scanning image to obtain an edge detection result of a target edge in the feature measurement region, obtain a to-be-identified image based on the feature measurement region and the scanning image, obtain an initial label of the to-be-identified image based on the edge detection result, adjust the initial label according to a real edge condition corresponding to the to-be-identified image to obtain a target label of the to-be-identified image, and can avoid obtaining image labels by manually drawing one by one, realize rapid and accurate generation of labels of images based on the edge detection result, and improve label generation efficiency and accuracy. BRIEF DESCRIPTION OF DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the drawings needed to be used in the description of the embodiments of the present application or the related art will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can also be obtained without creative labor on the basis of these drawings.
[0039] Figure 1 An application environment diagram of the label generation method in an embodiment;
[0040] Figure 2 A flowchart of the label generation method in an embodiment;
[0041] Figure 3 A determination diagram of the feature measurement region in an embodiment;
[0042] Figure 4 A generation diagram of the initial label in an embodiment;
[0043] Figure 5 A diagram of adjusting the initial label to the target label in an embodiment;
[0044] Figure 6 A diagram of different label categories on the same sample image in an embodiment;
[0045] Figure 7 A structural block diagram of the label generation device in an embodiment;
[0046] Figure 8 An internal structure diagram of the computer device in an embodiment. DETAILED DESCRIPTION
[0047] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not intended to limit the present application.
[0048] It should be noted that the terms "first", "second" and the like used in the present application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "include" and "have" and any variations thereof used in the present application are intended to cover non-exclusive inclusion. The term "multiple" used in the present application refers to two and more. The term "and / or" used in the present application refers to one of the options or any combination of multiple options.
[0049] The label generation method (or label acquisition method, label labeling method, etc.) provided by the embodiments of the present application can be applied to the application environment as shown in the figure. Figure 1 The terminal 102 communicates with the server 104 through the network. The data storage system can store the data required by the server 104 to process. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. The server 104 receives the scanning image obtained by the image measurement device sent by the terminal 102, performs edge detection on the feature measurement region drawn in the scanning image to obtain the edge detection result of the target edge in the feature measurement region, obtains the to-be-recognized image based on the feature measurement region and the scanning image, obtains the initial label of the to-be-recognized image based on the edge detection result, adjusts the initial label according to the real edge situation corresponding to the to-be-recognized image, and obtains the target label of the to-be-recognized image. The server 104 can return the target label of the to-be-recognized image to the terminal 102. The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, unmanned aerial vehicles, low-altitude flying vehicles, image measurement devices, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be a standalone physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. It should be noted that the label generation method provided by the embodiments of the present application is not only applicable to the application scenario of the interaction between the server and the terminal, but also applicable to the application scenario of a single server or a single terminal.
[0050] In an exemplary embodiment, as shown in Figure 2 , a label generation method is provided, which is applied to a server in Figure 1 for example, and includes the following steps 202 to 206. Among them:
[0051] Step 202, acquiring a scanning image by using an image measuring device, and performing edge detection on a feature measurement region drawn in the scanning image to obtain an edge detection result of a target edge in the feature measurement region.
[0052] The scanning image can be obtained by the image measuring device (such as an image measuring instrument or a flash measuring instrument) shooting the sample to be measured. The scanning image can be an image obtained by shooting the entire sample to be measured, or an image obtained by shooting a local area of the sample to be measured. The scanning image can be an image obtained by collecting a target area of the sample to be measured, which can cover the edge to be measured by the user. In other words, the scanning image can be an image obtained by collecting a local area of the sample to be measured, and the scanning image at least includes the target edge in the local area of the sample, which corresponds to the edge to be measured by the user. In some embodiments, the number of target edges in the same scanning image can be one or more. The same target edge corresponding to the theoretical drawing refers to a local edge that is continuous and only contains one shape (such as a straight line, an arc, or a circle, etc.).
[0053] The feature measurement region is used to represent the area to be measured by the user, and the feature measurement region can be selected by the user. Specifically, the image measuring instrument can perform effective measurement analysis on the scanning image of the sample to be measured within the range of the feature measurement region. The feature measurement region can cover the target edge to be measured. That is, the feature information of the workpiece in the feature measurement region can be extracted to obtain the target feature element based on the feature measurement region, that is, the edge feature extracted based on the target edge, corresponding to the edge detection result. In the embodiments of the present application, the edge detection result is used to represent the edge feature of the target edge in the feature measurement region. The edge detection result can be represented in the form of a point data set, that is, an edge feature point.
[0054] In some embodiments, the same feature measurement region includes one target edge, that is, one-to-one correspondence. Alternatively, the same feature measurement region does not cover other edges except the target edge, thereby reducing the influence of other edges on the identification of the target edge, and effectively improving the identification accuracy of the target edge.
[0055] In a specific application scenario, referring to Figure 3 , the generation process of the feature measurement region is specifically: selecting a tool type with a shape matching the target edge to be measured from the measurement tool, such as Figure 3The selected line is drawn along the target edge, the image measuring instrument takes the selected line as a center line, and generates a feature measurement region based on the length of the scan line and the length of the selected line. At this time, the length of the selected line is the length of the feature measurement region, and the length of the scan line is the width of the feature measurement region. At this time, the feature measurement region is a sector that can cover the edge feature formed in the arc shape. It can be understood that if the target edge is a straight line, the tool type selected by the measurement tool is a straight line, and the feature measurement region formed is a rectangle.
[0056] It is easy to understand that the selected line can be selected by a person, and therefore the length of the feature measurement region can also be understood as being selected by a person. The drawing of the selected line can be determined by selecting points. For example, if the measurement tool is a line feature, a straight line can be drawn by clicking two positions to determine the positions of two selected points on the display interface. If the measurement tool is an arc or a circle feature, a curved line or a circle can be drawn by clicking three positions to determine the positions of three selected points on the display interface.
[0057] The width of the feature measurement region can be adjusted by setting the extraction parameter (i.e., the length of the scan line) of the built-in edge extraction algorithm. In this case, the edge extraction algorithm extracts point data sets from the feature information of the workpiece in the feature measurement region by using a plurality of scan lines, and extracts the target feature elements corresponding to the feature measurement region, i.e., the edge detection result. Alternatively, the point data sets can also be fitted as an edge line.
[0058] For example, in addition to the edge extraction algorithm, an edge detection model can also be used to detect the edges of the feature measurement region in the scan image to obtain an edge detection result. The edge detection model can be obtained by training or can be an existing model capable of recognizing image edge features. Alternatively, the edge detection algorithm can be used to detect the edges of the scan image to obtain an edge detection result. The edge detection algorithm can include, for example, Roberts operator, Prewitt operator, Sobel operator, Scharr operator, Laplacian operator, LoG (Laplacian of Gaussian) operator, DoG (Difference of Gaussians) operator, Canny operator, Kirsch operator, etc. In actual application scenarios, the edge detection model or the edge extraction algorithm can be loaded into the measurement software of the image measuring device, and the target edge detection of the scan image can be realized through the measurement software to obtain the edge detection result of the target edge.
[0059] In step 204, a to-be-recognized image is obtained based on the feature measurement region and the scan image, and an initial label of the to-be-recognized image is obtained based on the edge detection result.
[0060] The to-be-recognized image (or sample image) can be an image to be labeled. The to-be-recognized image can be obtained based on the scanned image.
[0061] In some embodiments, the size of the sample image is positively correlated with the size of the feature measurement region. For example, the sample image is a part of the scanned image and covers at least the feature measurement region. In some application scenarios, the to-be-recognized image can be obtained by appropriately expanding the image based on the feature measurement region. Here, the appropriate expansion can mean expanding the feature measurement region outward by a certain region, but the to-be-recognized image formed after the expansion does not increase the edge features in the image too much, which can ensure complete recognition of the edge features (i.e., target edges) of the feature measurement region, while reducing the influence of other edges (except the target edges) on the edge detection result, improving the recognition efficiency and accuracy.
[0062] Alternatively, the entire scanned image can also be used as the to-be-recognized image.
[0063] The edge detection result can be represented in the form of point data set (i.e., edge feature point data). The edge feature point data includes the coordinates of a plurality of edge feature points (i.e., target marker points). In this case, the edge feature point data can be associated with the corresponding to-be-recognized image and saved. The edge feature point data can be saved as label data of the corresponding to-be-recognized image. The edge feature point data can correspond to the target marker points. Thus, the initial label of the to-be-recognized image can be obtained based on the edge detection result.
[0064] For example, after the corresponding software (e.g., training software) loads the to-be-recognized image and the label data associated therewith, the plurality of target marker points are connected or fitted to obtain a target marker line. The target marker line can be a straight line or a curve, which can be set according to the actual edge features. For example, if the detected edge is a straight line, the fitting is set to be a straight line, and if the detected edge is a curve, the fitting is set to be a curve.
[0065] In this embodiment, the initial label of the to-be-recognized image can be obtained based on the target marker line and the preset label width.
[0066] The preset label width is a pre-set label width. The preset label width can be set according to an actual application scenario. A label region can be determined with the target marking line as the center and the preset label width, and a border of the label region is the initial label of the target edge in the image to be recognized. In other words, the initial label is a closed contour that can enclose the region where the target edge is located. It should be noted that the label involved in the embodiments of the present application can be used to represent the edge feature of the target edge, and the label is a closed contour, rather than only a line or a point. The label corresponds to a region including the target edge feature. It can be understood that the label is generated based on the edge feature point data, and therefore the same label includes a target edge, that is, the two are one-to-one. Alternatively, the closed contour of the same label does not cover other edges except the target edge, thereby reducing the influence of other edges on the identification of the target edge, especially when used to train a target detection model, which can effectively improve the identification accuracy of the target edge feature of the trained target detection model.
[0067] Exemplarily, in the target marking points corresponding to the edge detection result, two adjacent target marking points can be connected by a straight line to obtain a target marking line. Based on the target marking line, an initial label of a preset label width can be generated. It is easy to understand that the overall shape trajectory of the initial label is the same as that of the target marking line. That is, a border of the preset label width is generated around the target marking line according to the trajectory of the target marking line, and the initial label is obtained. The target marking line can be at the center position or the edge position of the initial label.
[0068] Exemplarily, a curve fitting algorithm can be used to perform curve fitting on the plurality of target marking points to obtain a target marking line, and then an initial label of a preset label width is generated based on the target marking line.
[0069] Exemplarily, a first boundary line and a second boundary line are generated on both sides of the target marking line with the target marking line as the center, and the distance between the first boundary line and the second boundary line is the preset label width. The border of the region formed by the first boundary line and the second boundary line is taken as the initial label of the image to be recognized. The starting position and the ending position of the initial label can be determined according to the starting position and the ending position of the target marking line.
[0070] In step 206, the initial label is adjusted according to the real edge situation corresponding to the image to be recognized to obtain a target label of the image to be recognized.
[0071] The real edge case refers to an actual edge feature. The marking line in the initial label is adjusted based on the actual edge feature of the image to be recognized, so that the marking line in the initial label is more fitted to the actual edge feature, thereby obtaining a target label. The marking line of the initial label can be adjusted according to the real edge situation of the image to be recognized by manual or equipment, and the target label of the image to be recognized is obtained. It is easy to understand that if the marking line changes, the label corresponding to the marking line will also change.
[0072] Exemplarily, the marking points in the initial label can be adjusted according to the real edge situation of the image to be recognized, so that the similarity between the marking line determined by the marking points and the real edge situation of the image to be recognized is greater than or equal to a threshold value, and the label formed based on the adjusted marking line is the target label of the image to be recognized.
[0073] In the above label generation method, the edge detection result of the target edge is obtained by performing edge detection on the feature measurement region in the image to be recognized, the target marking line is determined according to the edge detection result, the initial label of the image to be recognized is generated according to the target marking line and the preset label width, the initial label is adjusted according to the real edge situation corresponding to the image to be recognized, and the target label of the image to be recognized is obtained. This can avoid manually drawing image labels one by one, realize fast and accurate generation of image labels based on edge detection results, and improve the label generation efficiency and accuracy.
[0074] In some embodiments, the initial label of the image to be recognized is obtained based on the edge detection result in step 204, including:
[0075] The target marking points are determined according to the edge detection result; the target marking line is obtained by fitting the target marking points; and the initial label of the image to be recognized is generated based on the target marking line and the preset label width.
[0076] The edge detection result can be presented in the form of a point set, and the corresponding edge feature points can be selected from the point set to determine the target marking points. In general, feature points can be sampled at a fixed distance on the detected edge features as target marking points. Alternatively, the feature point with the highest feature confidence (e.g., the best edge fitting degree) can be selected as the target marking point. It can be understood that if the number of selected target marking points is large, the similarity between the generated initial label and the real edge situation can be higher than the threshold value, and there is no need to adjust the label in step 206. Of course, it is not limited to this, and the entire point set can be saved as the target marking point.
[0077] Exemplarily, the target marking line can be obtained by connecting two adjacent target marking points. Alternatively, the target marking line can be obtained by fitting the target marking points through a curve fitting algorithm.
[0078] In this embodiment, the target mark line is obtained by fitting the target mark points corresponding to the edge detection result, so that a more accurate target mark line can be obtained, and the accuracy of the target mark line is improved.
[0079] In some embodiments, the edge detection on the feature measurement region drawn in the scanned image in step 202 to obtain the edge detection result of the target edge in the feature measurement region includes:
[0080] The edge detection model is obtained by training the to-be-recognized image obtained by the image measuring instrument.
[0081] The sample image can be obtained by the image measuring instrument, and the sample image is labeled to obtain the labeled sample image. The edge detection model can be obtained by training a small amount of labeled sample images. The sample image can be an image obtained by the image measuring device by photographing the whole or part of the sample to be measured. Of course, it can also be the same as the generation method of the above-mentioned to-be-recognized image, for example, at least part of the to-be-recognized image obtained can be used as a sample image to train and generate the edge detection model.
[0082] Exemplarily, the sample image can be labeled by manual or label annotation algorithm to obtain the label of the sample image. For example, the target edge of the sample image can be drawn to form a mark line fitting the image edge by selecting an appropriate label drawing style (such as line, arc, circle or curve, etc.) in the drawing software, and a region with a preset width range is formed around the mark line, and the edge frame of the region is the label of the sample image. The preset width range can be set according to the actual application scenario. Alternatively, the sample image can also be labeled by automatic labeling. Specifically, a target region is selected, the edge in the target region of the sample image is detected by an edge detection algorithm, the detected edge is labeled in the form of a mark point, the mark points are fitted to form a mark line, and a region with a preset width range is formed around the mark line, and the edge frame of the region is the label of the sample image.
[0083] Of course, the edge detection model can also be trained by the to-be-identified images and their associated target labels obtained via the above label generation method. Specifically, step 202 in the above label generation method can first select an edge extraction algorithm for a small number of scan images to obtain edge detection results, and then obtain to-be-identified images and their associated target labels in subsequent steps, and then train the edge detection model using these to-be-identified images and their associated target labels. Then, the edge detection model is loaded into the measurement software, so that step 202 can be replaced by using the edge detection model to identify the edge detection results of other scan images. That is, the sample image and the label associated therewith can be the to-be-identified image and the target label thereof obtained by the above label generation method.
[0084] In actual application scenarios, an initial detection model can be trained by a small number of annotated sample images to obtain an edge detection model, and then the edge detection model is used to detect the edges of the feature measurement region of a to-be-identified image to obtain the edge detection result of the target edge. The initial detection model can be, for example, a convolutional neural network architecture for edge detection, such as U-Net, FCN, Mask R-CNN, or a generative adversarial network (GAN).
[0085] In this embodiment, the edge detection result of the target edge is obtained by detecting the edge of the feature measurement region in the to-be-identified image based on the trained edge detection model, which can improve the efficiency of edge detection and improve the accuracy of edge detection.
[0086] In some embodiments, the initial label is adjusted according to the real edge situation corresponding to the to-be-identified image in step 206 to obtain the target label of the to-be-identified image, including:
[0087] The initial label is adjusted in overall position according to the real edge situation corresponding to the to-be-identified image until the similarity between the marking line of the label and the real edge situation of the to-be-identified image reaches a threshold, and the target label of the to-be-identified image is obtained.
[0088] As can be easily understood, the initial label generated based on the edge detection result identified by the edge detection model can have errors, and if the initial label does not match the real edge situation of the to-be-identified image, the initial label needs to be adjusted so that the marking line of the label matches the real edge situation of the corresponding to-be-identified image. If the similarity between the marking line of the label and the real edge situation in the image reaches a threshold, it means that the label matches the real edge feature in the corresponding image. As can be easily understood, adjusting the label actually adjusts the position of the marking point on the marking line. If the marking line changes, the corresponding label will also change. The change of the marking line is often realized by the position change of the marking point.
[0089] In an actual application scenario, the marking line in the initial label can be moved as a whole according to the real edge situation corresponding to the to-be-recognized image, that is, all the marking points in the initial label are simultaneously moved in the same direction by the same step size, until the similarity between the marking line and the real edge situation of the to-be-recognized image reaches a threshold, and a target label of the to-be-recognized image is obtained. It is easy to understand that after the marking points of the label are adjusted, the marking line changes, and the label changes according to the predetermined rule along with the marking line, so as to realize the adjustment of the label based on the marking points.
[0090] In this embodiment, the initial label is adjusted in position as a whole according to the real edge situation of the to-be-recognized image, until the similarity between the marking line of the label and the real edge situation of the to-be-recognized image reaches a threshold, and a target label of the to-be-recognized image is obtained, which can improve the adjustment rate and obtain the target label of the to-be-recognized image more quickly.
[0091] In one exemplary embodiment, the embodiments of the present application provide a model training method, comprising:
[0092] A to-be-recognized image with a label is obtained according to the label generation method described above; a candidate detection model is trained based on the to-be-recognized image and the label of the to-be-recognized image, until a training condition is reached, and a target detection model is obtained.
[0093] Wherein, the to-be-recognized image can include multiple images, each to-be-recognized image can be an image obtained by an image measuring instrument or a flash measuring instrument. The obtained to-be-recognized image is an image without label annotation, and the label (such as the target label associated therewith) of the to-be-recognized image can be generated by the label generation method described above to obtain the to-be-recognized image with the label. The candidate detection model can be a convolutional neural network architecture for edge detection, such as U-Net, FCN, Mask R-CNN or generative adversarial network (GAN), etc. Wherein, the candidate detection model can be an untrained model or a trained model. Exemplarily, the candidate detection model can adopt the edge detection model in the above embodiments.
[0094] Exemplarily, the candidate detection model can be trained based on the to-be-identified image and the label of the to-be-identified image until a training condition is met, to obtain a target detection model for edge detection. The training condition is, for example, that a difference between the label and a predicted edge is less than a preset difference threshold, or that a training frequency reaches a preset frequency. The predicted edge is an edge obtained by the candidate detection model based on prediction of the to-be-identified image. In the process of training the candidate detection model, the to-be-identified image is input into the candidate detection model, edge features in the to-be-identified image are identified based on the candidate detection model to obtain the predicted edge, parameters of the candidate detection model are adjusted based on a difference between the predicted edge and a target edge represented by the label of the to-be-identified image, until the difference between the predicted edge and the target edge represented by the label of the to-be-identified image is less than the difference threshold, or until the training frequency reaches the preset frequency, that is, the target detection model for edge detection is obtained. It should be noted that the difference between the predicted edge and the target edge represented by the label of the to-be-identified image can be represented by a similarity between the two, or can be represented based on a training loss.
[0095] In some examples, the label of the to-be-identified image can be classified according to the edge features represented by the label to obtain at least one label category. For example, labels corresponding to edge features with a similarity higher than a threshold are classified into the same category. The candidate detection model can be trained by the to-be-identified images corresponding to each label category in turn until the predicted results (predicted edges) of the to-be-identified images corresponding to each label category by the model all meet a preset condition, to obtain the target detection model. The target detection model obtained in this way can accurately identify edge features of more categories. In actual application scenarios, the candidate detection model can also be trained by the to-be-identified images corresponding to the target category label to obtain the target detection model. The target detection model obtained in this way is more accurate in identifying edge features of the target category. The target category can be any label category, for example, a label category specified by a user.
[0096] The above model training method generates to-be-identified images with labels by the label generation method, trains the candidate detection model based on the to-be-identified images and the labels of the to-be-identified images until a training condition is met, to obtain a target detection model, can quickly and accurately obtain a large number of to-be-identified images with labels for model training, and improves model training efficiency and training accuracy.
[0097] In one exemplary embodiment, the embodiments of the present application provide a measurement method, comprising:
[0098] obtaining a target image corresponding to the object to be measured; performing edge detection on the target image by using a target detection model obtained by the model training method to obtain a target edge; determining a target size of the target edge, and determining a measurement result of the object to be measured based on the target size.
[0099] The target image can be an overall image or a partial image of the object to be measured. For example, only a part of the object to be measured that needs to be measured can be photographed to obtain the target image.
[0100] For example, the target image corresponding to the object to be measured can be obtained by using a video measuring instrument, and the target edge can be obtained by performing edge detection on the target image by using a target detection model embedded in the video measuring instrument. The size of the target edge can be measured according to the measurement requirement to obtain a target size, and the measurement result of the object to be measured can be calculated according to the target size. In an actual application scenario, the target detection model obtained by training can be loaded into the measurement software of the video measuring instrument. After a user selects a feature measurement region in the target image by using a feature selection tool (or a measurement tool), the target detection model can identify the edge features in the selected feature measurement region to obtain the target edge. The video measuring device can measure the size of the target edge to obtain the target size, and the measurement result of the object to be measured can be obtained according to the target size. For example, the process in which the target detection model identifies the edge features in the target image can include obtaining a target image based on the feature measurement region, and using the knowledge obtained by training to analyze the information in the target image to identify the potential target edge, and displaying the target edge in the form of a contour line in the measurement software. The target image can be obtained by appropriately expanding the image based on the feature measurement region to the outside. The appropriate expansion to the outside can mean that a certain region is expanded outside the feature measurement region, but the target image formed after the expansion does not increase the edge features in the image too much, which can ensure complete identification of the edge features (i.e., the target edge) in the feature measurement region, and can also reduce the influence of other edges (except the target edge) on the target detection model, thereby improving the identification efficiency and accuracy.
[0101] In this embodiment, the target edge is obtained by performing edge detection on the target image corresponding to the object to be measured by using the target detection model, and the measurement result is obtained based on the target size of the target edge. This can realize accurate detection of the edge in the target image based on the target detection model, thereby improving the accuracy of the measurement result.
[0102] In actual application scenarios, when performing label drawing, a target edge of a sample image is manually labeled each time, that is, the edge in the sample image is artificially depicted from scratch by using a tool in the form of a line or an arc, which requires a large amount of repetitive labor, greatly reduces the label drawing efficiency, and increases the labor cost and production cost. Based on this, the embodiment of the present application provides a model training method. When an image measuring instrument photographs a sample image, the edge features of a feature measurement region in the sample image are identified by using measurement software, so that the edge features (i.e., edge detection results) of the target edge and specific measurement dimensions can be obtained. After the sample image and the identified edge features are imported into training software, the initial label of the corresponding sample image can be directly generated based on the edge features (edge detection results), the target label meeting the conditions is obtained by adjusting the initial label, and the AI model (target detection model) capable of performing edge detection is trained based on the sample image and the target label of the sample image. The size measurement and feature identification of the sample can be simultaneously completed in the process of photographing the sample by the image measuring instrument, the initial label is generated according to the edge features (edge detection results) obtained by feature identification, and there is no need to manually draw the image label one by one. The target label meeting the conditions can be obtained only by fine-tuning the automatically generated initial label, a large amount of repetitive labor is reduced, and the label generation efficiency is improved. The following describes a specific implementation process, and the related operations described in steps S1-S5 below can also be applied to the above label generation method, model training method, and measurement method without too many limitations. Specifically, the following steps S1-S5 are described:
[0103] S1: placing a sample on a sample stage
[0104] Since a large number of sample images are needed for training, a plurality of samples having the same detection requirement are prepared, a plurality of samples are placed on the sample stage of the image measuring instrument at the same time each time, and then the samples are photographed one by one to obtain scanning images, thereby improving the photographing efficiency.
[0105] S2: moving the camera field of view to the sample and photographing to obtain a scanning image at a specific position
[0106] The power of the image measuring instrument is turned on, the corresponding measurement software is started, and the instrument is brought into a working state. The camera is moved so that its field of view reaches each sample in turn, and a scanning image is obtained by photographing at a specific position (a local region of the sample) of each sample. In this embodiment, the scanning image does not reflect the entire sample, but only the region image of the sample that the user is more concerned about, for example, the region image covers the target edge whose corresponding dimensions the user wants to measure, so that the image region of interest can be better focused and the clarity of the obtained scanning image is ensured.
[0107] For the convenience of subsequent measurement, each sample can establish a workpiece coordinate system, which can be established manually and automatically. Among them, the manual establishment method is: through the handle, mouse dragging in the measurement software or inputting the moving distance in the measurement software, etc. to control the field of view to move to the target sample. After moving the field of view to the target sample, the workpiece coordinate system can be manually created, and the camera can be controlled to shoot at a specific position of the target sample to obtain a scanning image. The automatic establishment method is: if the imaging measuring instrument includes multiple regularly placed samples on the sample table, and the positions of different samples have been obtained and input in advance, at this time, the workpiece coordinate of one sample is established first, after the shooting and measurement are completed, the camera moves according to the input position information, and the established workpiece coordinate system can be regarded as moving to the next sample in the same way as the camera field of view to synchronize to the workpiece coordinate system of the sample, and the camera shoots a scanning image at a specific position of the current sample.
[0108] It should be noted that the specific position of the camera in each sample can be more than one, that is, multiple scanning images can be obtained in the same sample, and the number of scanning images can be controlled by the user according to the characteristics to be measured, such as two characteristics in the characteristics to be measured being far apart, which cannot be displayed in the same image to ensure image clarity, at this time, two scanning images can be obtained by shooting at two positions respectively.
[0109] S3: using the measurement tool of the imaging measuring instrument to measure the target characteristics in the current image area, and extracting the edge characteristics and measuring the size
[0110] When the camera shoots the sample to obtain a scanning image, the measurement tool in the measurement software can be used to measure the target characteristics (target edge) of the scanning image in the field of view area. Specifically, in the current field of view area, a characteristic measurement area (also called creating a characteristic) is created: the shape of the target edge to be measured is determined, such as a line, an arc or a circle, a measurement tool with the same shape (such as a measurement tool with a line, an arc or a circle as the drawing shape) is selected in the toolbar of the measurement software, and then the selected measurement tool is used to calibrate the target edge in the image display interface. Taking a common arc characteristic as an example for description: after selecting the arc tool in the toolbar, a selected line can be drawn along the edge characteristics (i.e. the target edge) to be extracted in the image display interface, the software takes the selected line as the center line and generates a characteristic measurement area according to the pre-set scanning line length, point density and other parameters, and displays it in the current scanning image. It can be understood that the relative position coordinates of the characteristic measurement area in the current workpiece coordinate system can be determined, and when measuring other samples, the characteristic measurement area can be generated at the same position after establishing the workpiece coordinate system, without the need to manually draw again.
[0111] The scanning line length refers to the length of the scanning line. For example Figure 3As shown, the scan line is used to identify the line feature of the feature measurement region, and a plurality of scan lines perpendicular to the selected line drawn above can be included in one feature measurement region. In the process of identifying the line feature, the point feature (edge feature point data) associated with the edge can be identified on the scan line based on the configured edge identification algorithm based on conditions such as contrast and distance, wherein each scan line can correspond to one point feature (target marker point), and then the line feature (target marker line) is fitted based on a plurality of point features, thereby completing the identification. Wherein the width of the feature measurement region is confirmed by the scan line length, and the length of the feature measurement region is determined by the selected line length. When saving the obtained sample image (to be identified image), the size of the feature measurement region will affect the size of the extracted sample image (to be identified image).
[0112] The point density refers to the distance between adjacent scan lines in the selected line. As can be seen, the edge feature extracted by the measurement software is a point set (edge feature point data), which is directly saved as label data (see the following description) through corresponding software processing and stored in the training folder. Create measurement size: according to the selected feature, set the size that needs to be concerned, after creating the feature, first select the type of size (such as length, distance, radius, angle, etc.) in the toolbar of the software, then select the related feature in the scan image, and the software automatically presents the size diagram based on the type of size and the type of the feature. Thus, the required size data can be obtained.
[0113] In this embodiment, after the measurement size is measured, it can also be compared with the theoretical value. If the measurement size of the sample is qualified, the evaluation result is OK (evaluation passed), otherwise the evaluation result is NG (evaluation failed). If the AI model (target detection model) is loaded in the measurement software later, the sample with the current evaluation result displayed as NG can be re-measured, and the sample with the evaluation result displayed as OK can not be re-measured, thereby reducing repetitive measurement and improving the measurement efficiency of the sample. Of course, this is not limited, and the sample with the current display result as OK can also be re-measured to further confirm to improve the measurement accuracy.
[0114] In this step, the number of features measured in each scan image can be more than one. For example, in the current scan image, the target edge to be measured has two shapes, one line and one arc, so when setting the feature measurement region, the corresponding measurement tool can be selected to select the two features, thereby completing the extraction. The extracted sample image saved later can cover the two features, of course, one feature can also correspond to one extracted sample image. That is, one sample image can include one or more feature measurement regions, but only the edge of one feature measurement region is detected each time the edge detection is performed.
[0115] In step S3, after the selected feature measurement region is selected, in addition to using the scanning line and the edge recognition algorithm configured in the software, the feature recognition can also be performed by loading the initial AI model (edge detection model) prepared in advance, so as to extract the edge features (edge detection result of the target edge) in the feature measurement region. The sample image for training the initial AI model (edge detection model) is obtained by the image measuring instrument, and the specific process is as follows: a small amount of sample images are first obtained, then the sample images are labeled in the training software, and the initial AI model (edge detection model) is trained based on the sample images with labels. The sample images for training the initial AI model are less and the accuracy is not high, and the subsequent label data and sample images can be optimized and trained based on the initial AI model (edge detection model).
[0116] S4: save the sample image (to-be-recognized image) based on the current scanning image, and obtain the label data (edge feature point data) associated with the sample image (to-be-recognized image) based on the extracted edge features (edge detection result)
[0117] The current scanning image is saved to obtain the sample image (to-be-recognized image). The sample image (to-be-recognized image) can be the entire scanning image, or the sample image (to-be-recognized image) can be a part of the scanning image including the feature measurement region, and the specific size can be determined by the range size of the feature measurement region, that is, the size of the sample image (to-be-recognized image) is positively correlated with the range size of the feature measurement region. That is, the smaller the feature measurement region, the smaller the sample image (to-be-recognized image), and the sample image (to-be-recognized image) needs to include the feature measurement region. Similarly, the larger the feature measurement region, the larger the sample image (to-be-recognized image). By extracting only a part of the scanning image as the sample image (to-be-recognized image), other unwanted edges in the scanning image can be removed, thereby facilitating the training of the subsequent AI model (target detection model).
[0118] When the sample image (to-be-recognized image) is saved, the corresponding software also screens the edge features to obtain a plurality of marker point coordinates, thereby corresponding to generate label data, for example, a plurality of points are selected at a set interval from the point set constituting the edge features and the coordinates of the points are recorded to obtain the marker point coordinates, and then the label width is adaptively set based on the image size of the sample image, so as to save the marker point coordinates and the label width as the label data associated with the sample image. That is, the label can be determined based on the marker point coordinates and the label width. For example, Figure 4As shown, adjacent marking points 402 are connected to fit to form a marking line 404, and according to the label width, a region with a certain width range can be determined, and the contour of the region is the generated initial label 406. As can be seen, according to the edge features (edge detection results) extracted in the measurement software, the label of the corresponding sample image can be determined, and there is no need to manually draw a label again in the training software, which can greatly reduce the labor cost and improve the drawing efficiency of the label.
[0119] In the subsequent step, the sample image (to be identified image) and the associated label data (edge feature point data) are imported into the training software, and the sample image with the drawn label can be directly obtained, so that the AI model (target detection model) can be directly trained.
[0120] It should be noted that the label in the embodiment is set as a closed contour, and the region corresponding to the label includes the target edge feature, rather than only an edge line. By determining a range through the label, even if there is a small error in the boundary when the marking line is drawn, the judgment of the overall feature of the target edge will not be affected to a certain extent, which can effectively reduce the marking error. Of course, the more the marking line fits the target edge, the more the label region formed can more accurately include the target edge, and the higher the edge recognition accuracy of the AI model (target detection model) trained subsequently.
[0121] S4.1 Adjusting the initial label according to the target edge (real edge condition) in the sample image (to be identified image) to obtain an optimized target label
[0122] Since the edge feature data is obtained based on the algorithm in the measurement software, the accuracy may not be high enough, resulting in that the initial label directly generated does not fit the target edge (real edge condition) well, that is, there may be a number of marking points in the marking line that do not fit the target edge. Therefore, the initial label can be adjusted according to the actual edge condition of the target edge in the sample image, so as to obtain an optimized target label, so that the marking line of the label fits the target edge better. It is easy to understand that if the similarity between the initial label and the actual edge condition of the sample image is higher than a threshold, the initial label can be directly used as the target label without adjustment.
[0123] The label adjustment manner includes: the label as a whole is movable, so that the position of the marking line is coincided with the target edge. Each marking point in the label is deletable or movable, so as to adjust the position of the marking point that does not match. The marking point can also be additionally added at the selected position. The marking point can be added between the generated marking points, so as to enrich the internal details and make the marking line as a whole more match the target edge. The marking point can also be added outward along the original shape track (such as the original arc) at the head and tail of the marking line, so that the marking line can be entirely covered to the selected target edge. The schematic diagram of adjusting the initial label to the target label is shown in Figure 5
[0124] In the embodiment, the labels can also be classified. The labels corresponding to the same or highly similar target edges in the sample image can belong to a class. Whether the two target edges are the same or highly similar can be determined by comparing the edge conditions such as the edge shape contour, the edge texture, or the edge intensity. The edges with close edge conditions belong to the same class, and the labels corresponding to the edges in the same class belong to the same class of labels. The labels belonging to the same class can participate in the training of the subsequent AI model (target detection model) for the same class of edges, so that the trained AI model can realize the recognition of edges with similar edge conditions. In the training of the same AI model, the sample images of the same image class are preferably used for training, so as to ensure the recognition accuracy of the AI model for the edges with similar edge conditions. Of course, it is not limited to this. If different image classes of sample images are used to train the same AI model, the AI model can recognize a wider range of edge types, but the recognition accuracy is lower than that of the AI model trained by using a single image class.
[0125] The same AI model can have multiple classes of labels participating in the training, so as to improve the applicability of the AI model and recognize multiple edges with different edge conditions. Preferably, the classes of the multiple classes of labels refer to the classes of the labels corresponding to different target edges on the same sample image, as shown in Figure 6 The labels participating in the training are at least 10, and the labels of different classes can be distinguished by different colors. For example, in the same sample image, two edges with different shapes need to be focused on and measured, so two labels can be generated in the sample image, and the two labels are of different classes and are displayed in different colors. The labels on different sample images can be displayed in the same color if they belong to the same class of labels.
[0126] The training software can also be provided with a label list interface, which can include label color, label name, label width, image quantity, etc. The label list interface can be used to batch manage labels, such as adjusting label width and label naming, etc. The label color corresponds to the corresponding label category, and the image quantity corresponds to the number of sample images with this type of label.
[0127] S5: training based on the image with the drawn label (to-be-identified image) to obtain an AI model (target detection model)
[0128] The sample image (to-be-identified image) and its associated label data are imported into the training software, and the sample image (to-be-identified image) that needs to participate in the training is set in the corresponding image list interface. The selected sample image (to-be-identified image) and the corresponding label data are input as a training set (i.e., training data) into the selected model architecture for training, thereby obtaining an AI model (target detection model) for feature recognition. The model architecture can be selected as a convolutional neural network architecture for edge detection, such as U-Net, FCN, Mask R-CNN, etc., or some architecture based on a generative adversarial network (GAN). The present embodiment does not make too many limitations.
[0129] Additional training: After the AI model is trained, the AI model can be loaded in the training software to identify the sample image and obtain an inference result. The accuracy of the AI model is evaluated according to the inference result. If the accuracy of the AI model is low, it means that the number of training sets participating in the training is still too small. The number of sample images can be increased (such as adding new samples, repeating steps S2 to S4 or S4.1 to obtain new sample images and label data associated therewith), and the new sample images and the label data associated therewith are added to the training set to perform additional training on the AI model, i.e., training based on the original AI model, thereby improving the accuracy of the AI model.
[0130] Dynamic training: Further, because in steps S2 and S3, the measurement software is characteristic measurement for each sample, that is, the saved sample image and label data in step S4 are gradually increased, the training process of the AI model can be dynamic. Specifically, as the number of samples measured by the image measuring instrument increases, the number of sample images and label data in the training folder also increases accordingly; the import path of the training software is set to the training folder where the sample image and label data information are saved by default, and the training software can monitor the number of sample images in the training folder. When the number of newly added sample images reaches a certain threshold, the training can be started. If there is no AI model at the beginning, the newly added sample images and label data are input into the selected model architecture for training to obtain the AI model. If there is already an AI model, the AI model is further trained based on the AI model to obtain a further optimized AI model. Of course, in addition to monitoring the number of sample images, it can also be set to start training every predetermined time.
[0131] After the AI model is evaluated to be qualified, the AI model (target detection model) can be loaded into the measurement software of the image measuring instrument. When the user performs characteristic measurement on the sample, after selecting the characteristic measurement region by using the characteristic measurement tool, the AI model can recognize the target edge (i.e. the measured feature in the measurement software, the red line in the following figure is the recognized feature) according to the selected characteristic measurement region, and label the size to be measured according to the recognized feature (characteristic measurement result), thereby completing the characteristic measurement. Compared with the edge recognition algorithm provided by the measurement software, the AI model can achieve more accurate feature recognition.
[0132] Alternatively, after obtaining an AI model, the current AI model is directly loaded into the measurement software, and then steps S2 and S3 are repeated. However, after selecting the characteristic measurement region by using the characteristic measurement tool, the edge feature is not extracted by using the scanning line and the edge recognition algorithm provided by the measurement software, but is directly extracted by the AI model to obtain the edge feature point data, and then the subsequent steps are performed to obtain a new sample image with labels in the training software. The new AI model (optimized target detection model) is obtained by training the current AI model according to the newly added sample image with labels. This specific process can be combined with the above dynamic training. At this time, the AI model is optimized, and the new AI model can be loaded into the measurement software. Then, the process is repeated until the AI model is qualified or the total number of sample images participating in the training reaches a set number.
[0133] Exemplarily, multiple different AI models can be loaded in the measurement software for samples with the same detection requirements, and when one AI model fails to identify a feature, the next AI model is automatically switched to, and when the identification is successful, the AI model is stopped from being replaced. In actual application scenarios, because the structures of samples can be the same but the colors are different, different colors can also affect the identification of the AI model. For example, when the first AI model is trained, the sample images taken are all from black samples, and when the first AI model is loaded into the measurement software to identify the target edge of a white sample, it is likely to fail. At this time, in order to enable normal measurement, a second AI model can be trained, and the sample images taken are from white samples. Then the first AI model and the second AI model are loaded into the measurement software. When a sample is measured by using the feature measurement tool to select a feature measurement region to start feature identification, the identification can be performed in sequence according to the order of the AI models. For example, the first AI model is used for identification first, if the identification is successful, the edge feature is directly extracted without replacing the AI model; if the identification fails, the second AI model is switched to for identification, if the identification is successful, the edge feature is extracted and the AI model is stopped from being replaced, if the identification fails, if there is an AI model, the identification is continued to be switched, if there is no AI model, the identification is prompted to fail or the extraction result is not displayed. Of course, after all the AI models fail to identify, the edge feature can be extracted by means of the scan line and the configured algorithm to avoid the feature measurement on the sample.
[0134] It should be understood that, although each step in the flowchart involved in the above embodiments is shown in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified herein, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other sequences. Moreover, at least part of the steps in the flowchart involved in the above embodiments can include multiple steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or stages. It can be understood that the steps in different embodiments can be freely combined as needed, and various non-contradictory schemes formed by the combination all belong to the scope of protection of the present application.
[0135] Based on the same inventive concept, the embodiments of the present application also provide a label generation device for implementing the above-mentioned label generation method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, and therefore the specific limitations in one or more label generation device embodiments provided below can refer to the limitations of the label generation method in the above text, which will not be described here again.
[0136] In one example embodiment, as shown in Figure 7 a label generation apparatus 700 is provided, comprising an edge detection module 702, a label obtaining module 704 and a label adjustment module 706, wherein:
[0137] The edge detection module 702 is configured to acquire a scan image by using the image measurement apparatus, perform edge detection on a feature measurement region drawn in the scan image, and acquire an edge detection result of a target edge in the feature measurement region.
[0138] The label obtaining module 704 is configured to obtain a to-be-recognized image based on the feature measurement region and the scan image, and obtain an initial label of the to-be-recognized image based on the edge detection result.
[0139] The label adjustment module 706 is configured to adjust the initial label according to a real edge situation corresponding to the to-be-recognized image, and obtain a target label of the to-be-recognized image.
[0140] In some embodiments, the edge detection module 702 is further configured to perform edge detection on the feature measurement region drawn in the scan image based on a loaded edge detection model, and obtain the edge detection result of the target edge in the feature measurement region. The edge detection model is obtained by training based on the to-be-recognized image acquired by the image measurement apparatus.
[0141] In some embodiments, the label adjustment module 706 is further configured to perform overall position adjustment on the initial label according to the real edge situation corresponding to the to-be-recognized image, until a similarity between a marking line of the label and the real edge situation of the to-be-recognized image reaches a threshold, and obtain the target label of the to-be-recognized image.
[0142] Based on the same inventive concept, the embodiments of the present application also provide a model training apparatus for implementing the above-mentioned model training method. The implementation scheme for solving the problem provided by the apparatus is similar to the implementation scheme described in the above method, and therefore the specific limitations in one or more model training apparatus embodiments provided below can refer to the limitations of the model training method described above, which will not be described here again.
[0143] In one example embodiment, a model training apparatus is provided, comprising:
[0144] An image acquisition module is configured to acquire a to-be-recognized image with a label generated according to the above-mentioned label generation method.
[0145] A model training module is configured to train a candidate detection model based on the to-be-recognized image and the label of the to-be-recognized image, until a training condition is reached, and obtain a target detection model.
[0146] Based on the same inventive concept, the embodiments of the present application also provide a measuring device for implementing the above-mentioned measuring method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above-mentioned method, so the specific limitations in one or more measuring device embodiments provided below can refer to the limitations of the measuring method in the foregoing, which will not be described here again.
[0147] In one exemplary embodiment, a measuring device is provided, comprising:
[0148] an image acquisition module configured to acquire a target image corresponding to the object to be measured;
[0149] an edge detection module configured to perform edge detection on the target image by using a target detection model obtained based on the above-mentioned model training method, to obtain a target edge;
[0150] a result determination module configured to determine a target size of the target edge, and determine a measurement result of the object to be measured based on the target size.
[0151] Each module in the above-mentioned label generation device, model training device or measuring device can be realized by software, hardware and a combination thereof, in whole or in part. Each module can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.
[0152] In one exemplary embodiment, a computer device is provided, which can be a server, and the internal structure diagram thereof can be as shown in Figure 8 The computer device includes a processor, a memory, an input / output interface (I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The database of the computer device is configured to store data related to the label generation method. The input / output interface of the computer device is configured to exchange information between the processor and external devices. The communication interface of the computer device is configured to communicate with external terminals through network connection. The computer program is executed by the processor to implement a label generation method.
[0153] Those skilled in the art can understand that, Figure 8The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0154] In an exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0155] In an embodiment, a computer readable storage medium is provided, storing a computer program, and the computer program implementing the steps in the above method embodiments when executed by a processor.
[0156] In an embodiment, a computer program product is provided, including a computer program, and the computer program implementing the steps in the above method embodiments when executed by a processor.
[0157] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.
[0158] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., without being limited thereto.
[0159] The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combinations of the technical features do not exist contradictory, they should be considered as the scope of the present application.
[0160] The above-described embodiments are merely illustrative of several embodiments of the present application, and the description is relatively specific and detailed, but should not be understood as a limitation on the scope of the patent. It should be noted that for those skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are all within the scope of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.
Claims
1. A label generation method applied to an image measuring device, characterized by, The method comprises: acquiring a scanning image by using the image measuring device; drawing a feature measurement region in the scanning image to perform edge detection, so as to acquire an edge detection result of a target edge in the feature measurement region; obtaining a to-be-recognized image based on the feature measurement region and the scanning image, and determining a target mark point according to the edge detection result; fitting the target mark point to obtain a target mark line; generating a frame of a preset label width around the periphery of the target mark line according to the track of the target mark line, so as to obtain an initial label of the to-be-recognized image; adjusting the initial label according to a real edge condition corresponding to the to-be-recognized image, so as to obtain a target label of the to-be-recognized image.
2. The method of claim 1, wherein, The size of the to-be-recognized image is positively correlated with the range size of the feature measurement region; or the entire scanning image is taken as the to-be-recognized image.
3. The method of claim 1, wherein, The drawing of the feature measurement region in the scanning image to perform edge detection, so as to acquire an edge detection result of a target edge in the feature measurement region, comprises: performing edge detection on the feature measurement region drawn in the scanning image based on a loaded edge detection model, so as to obtain an edge detection result of a target edge in the feature measurement region; the edge detection model is obtained by training sample images acquired by the image measuring device.
4. The method of claim 1, wherein, The adjusting of the initial label according to a real edge condition corresponding to the to-be-recognized image, so as to obtain a target label of the to-be-recognized image, comprises: performing overall position adjustment on the initial label according to the real edge condition corresponding to the to-be-recognized image, until the similarity between the mark line of the label and the real edge condition of the to-be-recognized image reaches a threshold value, so as to obtain a target label of the to-be-recognized image.
5. A model training method, comprising: The method comprises: acquiring the to-be-recognized image with a label generated by the label generation method according to any one of claims 1 to 4; training a candidate detection model based on the to-be-recognized image and the target label of the to-be-recognized image, until a training condition is reached, so as to obtain a target detection model.
6. A method of measuring, characterized by, The method comprises: acquiring a target image corresponding to a to-be-measured object; performing edge detection on the target image by using the target detection model obtained by the model training method according to claim 5, so as to obtain a target edge; determining a target size of the target edge, and determining a measurement result of the to-be-measured object based on the target size.
7. A label generating apparatus characterized by comprising: The device comprises: an edge detection module, configured to acquire a scanning image by using an image measuring device, and draw a feature measurement region in the scanning image to perform edge detection, so as to acquire an edge detection result of a target edge in the feature measurement region; a label acquisition module, configured to obtain a to-be-recognized image based on the feature measurement region and the scanning image, and determine a target mark point according to the edge detection result; fit the target mark point to obtain a target mark line; and generate a frame of a preset label width around the periphery of the target mark line according to the track of the target mark line, so as to obtain an initial label of the to-be-recognized image. A label adjusting module is configured to adjust the initial label according to a real edge condition corresponding to the image to be recognized, so as to obtain a target label of the image to be recognized.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6. The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.
Citation Information
Patent Citations
Model training method and device, electronic equipment and computer-readable storage medium
CN108921161A