Identification identification method and device for engineering drawing and electronic equipment

By introducing the Swin Transformer structure and depth-separable convolution into the YOLO model, combined with the sliding window and Patch Merging layer, the problem of inefficient identification of indexes and size marks in engineering drawings is solved, and high-accuracy and efficient recognition effects are achieved. .

CN118762369AActive Publication Date: 2024-10-11CISDI ENGINEERING CO LTD

Patent Information

Application Number
CN202410770146.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-10-11
Estimated Expiration
2044-06-14

AI Technical Summary

Technical Problem

It is difficult to accurately identify index marks and dimensional marks in engineering drawings with the existing technology. There are problems of missed identification and misidentification, and the traditional method is inefficient.

Method used

The YOLO model based on the Swin Transformer structure is used for index mark detection. Through cutting image fragments, sliding window detection and non-maximum suppression, combined with depth-separable convolution and Patch Merging layers, the index and size mark positions are extracted to reduce misidentification phenomena. .

Benefits of technology

It achieves accurate and comprehensive identification of index marks and dimensional marks in engineering drawings, improves detection efficiency and accuracy, and reduces misrecognition rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118762369A_ABST
    Figure CN118762369A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image detection, and discloses an identification identification method and device for an engineering drawing and electronic equipment, and the method comprises the steps: obtaining a to-be-detected image which comprises the engineering drawing, carrying out the index identification detection of the to-be-detected image through a preset index identification detection model, and obtaining an index identification position; detecting all identifiers in the to-be-detected image to obtain a first identifier position corresponding to the to-be-identified identifier, detecting a secondary identifier in the to-be-detected image to obtain a second identifier position corresponding to the secondary identifier, extracting from the first identifier position through the index identifier position and the second identifier position to obtain a size identifier position, and identifying the to-be-detected image according to the size identifier position. The to-be-identified identifier comprises a size identifier, an index identifier and a secondary identifier, and performing identifier identification on the position of the index identifier and / or the position of the size identifier to obtain an identification result corresponding to the engineering drawing; through the method, a more practical and more efficient identification method for engineering drawings is provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image detection technology, and in particular to a method, device and electronic equipment for identifying a mark in an engineering drawing. Background Art

[0002] Engineering drawings are technical documents that describe the design, size, materials, and construction requirements of buildings, structures, machinery, electrical engineering, and other projects. They are important reference documents that are indispensable in the construction of engineering projects and are often used to guide construction, review design, material procurement, cost estimation, quality control, and maintenance. The digital storage of engineering drawings and the extraction of information from engineering drawings have important practical significance in the fields of machinery and electronic systems, and have become a hot topic of research in academia and engineering.

[0003] With the rapid development of mapping technology, the number of engineering drawings is increasing. How to search and query a large number of engineering drawings has become an urgent problem that needs to be solved. The search process through manual comparison is cumbersome and inefficient, and long-term repetitive work may also lead to a high error rate. Traditional feature-based detection methods are inefficient, but deep learning can achieve better results by relying on its powerful learning and feature expression capabilities. Text detection technology based on OCR and deep learning has gradually become the mainstream method of text detection with its higher detection efficiency and accuracy.

[0004] Universal OCR models have achieved encouraging results in many fields such as digital tube recognition, universal form recognition, and license plate recognition, but these models cannot be directly used for text recognition in engineering drawings. Due to the different sizes of engineering drawings, the direction of the text in the drawings may be rotated, and symbols are easily misidentified as text. The related engineering drawing text recognition methods are prone to problems such as missed recognition and misidentification. Therefore, a new identification recognition method for engineering drawings is urgently needed to more accurately and comprehensively locate and identify index identification and size identification in engineering drawings.

[0005] It should be noted that the above content only provides background technical information related to the present application and does not necessarily constitute prior art. Summary of the invention

[0006] In view of the above-mentioned shortcomings of the prior art, the present application provides a method, device and electronic device for identifying markings in engineering drawings, so as to more accurately and comprehensively locate and identify index markings and dimension markings in engineering drawings.

[0007] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by the practice of the present application.

[0008] According to one aspect of an embodiment of the present application, a method for identifying a logo for an engineering drawing is provided, comprising: acquiring an image to be detected, wherein the image to be detected includes an engineering drawing; performing index logo detection on the image to be detected by using a preset index logo detection model to obtain an index logo position, wherein the index logo detection model is trained based on a basic model, and the basic model is a YOLO model in which a C2F structure in a backbone is replaced with a Swin Transformer structure; detecting all logos in the image to be detected to obtain a first logo position corresponding to the logo to be identified, and detecting secondary logos in the image to be detected to obtain a second logo position corresponding to the secondary logo, extracting from the first logo position by using the index logo position and the second logo position to obtain a size logo position, wherein the logo to be identified includes a size logo, an index logo and a secondary logo; performing logo identification on the index logo position and / or the size logo position to obtain a recognition result corresponding to the engineering drawing.

[0009] In one embodiment of the present application, based on the aforementioned scheme, index marker detection is performed on the image to be detected through a preset index marker detection model, including: cutting the image to be detected according to a first preset size to obtain one or more image segments, and performing index marker detection on the image segments through the index marker detection model.

[0010] In one embodiment of the present application, based on the aforementioned scheme, the method further includes: determining a sliding window from the image segment; controlling the sliding window to slide in the image segment, and performing index mark detection on the sliding window to obtain at least one sub-image position information corresponding to the image segment of an original detection frame and the index mark confidence corresponding to the original detection frame, wherein the index mark exists in the original detection frame; performing non-maximum suppression when integrating the image segment based on the offset position of the image to be detected; determining the original image position information corresponding to the original detection frame in the image to be detected according to the sub-image position information corresponding to the original detection frame in the image segment; determining any original detection frame as the first detection frame, The original detection frames except the first detection frame are respectively determined as second detection frames; a first area intersection-union ratio is calculated based on the intersection of the first area and the second area and the union of the first area and the second area, the first area is obtained based on the original image position information of the first detection frame, and the second area is obtained based on the original image position information of the second detection frame; if the first area intersection-union ratio is greater than a preset first area threshold, the index identifier confidence of the first detection frame and the index identifier confidence of the second detection frame are compared to determine the target detection frame with the highest index identifier confidence from the first detection frame and the second detection frame, and the original image position information corresponding to the target detection frame is used as the index identifier position.

[0011] In one embodiment of the present application, based on the aforementioned scheme, the secondary marker in the image to be detected is detected to obtain a second marker position corresponding to the secondary marker, including: proportionally reducing the image to be detected so that the long side is a second preset size, and recording the reduction ratio; inputting the adjusted image to be detected into a preset secondary marker detection model to obtain the secondary marker position, wherein the secondary marker detection model is trained based on marker samples with secondary marker labels, and the secondary marker position is the position of the secondary marker in the adjusted image to be detected; the second marker position is calculated based on the secondary marker position and the reduction ratio.

[0012] In one embodiment of the present application, based on the above-mentioned scheme, the size identification position is obtained by extracting from the first identification position through the index identification position and the second identification position, including: determining the area of ​​the region corresponding to the first identification position as the first area, determining the area of ​​the region corresponding to the index identification position as the index area, and determining the area of ​​the region corresponding to the second identification position as the second area; calculating the second area intersection-union ratio based on the intersection of the first area area and the index area area and the union of the first area area and the index area area, if the second area intersection-union ratio is greater than a first preset threshold, determining that the first identification position and the index identification position are the same position; calculating the intersection area of ​​the first area area and the second area area, and calculating the area ratio based on the intersection area and the second area area, if the area ratio is greater than a second preset threshold, determining that the first identification position is located inside the second identification position; filtering the index identification position and the second identification position from the first identification position to obtain the size identification position.

[0013] In one embodiment of the present application, based on the aforementioned scheme, the index identification position and / or the size identification position are identified to obtain an identification result corresponding to the engineering drawing, including: integrating the index identification position and the size identification position to obtain an integrated result, wherein the integrated result includes an identification position and an identification category; cropping from the image to be detected according to the identification position to obtain a cropped image including only the identification content; and identifying the cropped image to obtain an identification result corresponding to the engineering drawing.

[0014] In one embodiment of the present application, based on the aforementioned scheme, the Swin Transformer structure includes in sequence: a first stage, the first stage includes a Patch Embedding unit and a plurality of Block units, wherein the Patch Embedding unit is used to segment the input first image and embed it into a vector to obtain a feature map, the Block unit is used to perform layer normalization on the feature map, segment the feature map into a plurality of windows, calculate Attention and determine whether it is Window Attention or Shift Window Attention, merge windows, and if a Shift operation has been performed, perform ReverseShift, perform Dropout and residual connection, and then perform layer normalization, a fully connected layer, Dropout and residual connection; a plurality of second stages connected in sequence, the second stage includes a Patch Merging unit and a plurality of Block units, wherein the Patch Merging unit is used to perform downsampling to obtain a downsampling result, and splice the downsampling result to obtain a splicing result, and adjust the number of channels of the splicing result through a fully connected layer.

[0015] In one embodiment of the present application, based on the aforementioned scheme, the basic model is a YOLO model in which the CBS structure in the neck is replaced with a GSConv structure; wherein the GSConv structure is used to perform ordinary convolution downsampling on the input second image to obtain a downsampling result, and perform deep convolution on the input second image to obtain a deep convolution result; the downsampling result and the deep convolution result are spliced, and a shuffle operation is performed.

[0016] According to one aspect of an embodiment of the present application, a device for identifying an identification of an engineering drawing is provided, comprising: an acquisition module, for acquiring an image to be detected, wherein the image to be detected includes an engineering drawing; an index identification module, for performing index identification detection on the image to be detected by using a preset index identification detection model to obtain an index identification position, wherein the index identification detection model is obtained by training based on a basic model, and the basic model is a YOLO model in which the C2F structure in the backbone is replaced with a Swin Transformer structure; a size identification module, for detecting all identifications in the image to be detected to obtain a first identification position corresponding to the identification to be identified, and detecting secondary identifications in the image to be detected to obtain a second identification position corresponding to the secondary identification, extracting from the first identification position by using the index identification position and the second identification position to obtain a size identification position, wherein the identification to be identified includes a size identification, an index identification and a secondary identification; and a recognition module, for performing identification recognition on the index identification position and / or the size identification position to obtain a recognition result corresponding to the engineering drawing.

[0017] The present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device implements the identification method for engineering drawings as described in any of the above embodiments.

[0018] The beneficial effects of the present application are as follows: the present application performs index identification detection on an image to be detected through a preset index identification detection model to obtain an index identification position, wherein the index identification detection model is obtained based on training of a basic model, and the basic model is a YOLO model in which the C2F structure in the backbone is replaced with a Swin Transformer structure, and the YOLOv8 network is improved. Through the Swin Transformer module, the model can learn cross-window information without reducing the calculation rate; all identifications in the image to be detected are detected to obtain a first identification position corresponding to the identification to be identified, and secondary identifications in the image to be detected are detected to obtain a second identification position corresponding to the secondary identification, and the index identification position and the second identification position are extracted from the first identification position to obtain a size identification position, and obvious erroneous recognition results are removed, thereby reducing the phenomenon of misrecognition; identification recognition is performed on the index identification position and / or the size identification position to obtain a recognition result corresponding to the engineering drawing, so as to more accurately and comprehensively locate and identify the index identification and size identification in the engineering drawing.

[0019] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0021] Figure 1 is a schematic diagram of an exemplary system architecture shown in an exemplary embodiment of the present application;

[0022] Figure 2 is a flow chart of a method for identifying a mark of an engineering drawing according to an exemplary embodiment of the present application;

[0023] Figure 3 It is a sample diagram of a method for identifying a logo for an engineering drawing, shown in an exemplary embodiment of the present application;

[0024] Figure 4a It is a schematic diagram of the network structure flow of SwinTransformer for a marking recognition method for engineering drawings shown in an exemplary embodiment of the present application;

[0025] Figure 4b It is a schematic diagram of a two-stage Swin Transformer Block structure of a marking recognition method for engineering drawings shown in an exemplary embodiment of the present application;

[0026] Figure 5 is a structural diagram of GSConv for a marking recognition method for engineering drawings shown in an exemplary embodiment of the present application;

[0027] Figure 6 is a PR curve of a test result of a marking recognition method for engineering drawings shown in an exemplary embodiment of the present application;

[0028] Figure 7 It is a schematic diagram of a non-size identification area of ​​an identification recognition method for an engineering drawing shown in an exemplary embodiment of the present application;

[0029] Figure 8 It is a non-size identification sample diagram of an identification recognition method for engineering drawings shown in an exemplary embodiment of the present application;

[0030] Fig. 9 is a flow chart of a method for identifying a logo of an engineering drawing according to another exemplary embodiment of the present application;

[0031] Fig.10 is a block diagram of a marking recognition device for engineering drawings shown in an exemplary embodiment of the present application;

[0032] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION

[0033] The following will describe the implementation methods of the present application with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be understood that the preferred embodiments are only for illustrating the present application, not for limiting the scope of protection of the present application.

[0034] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present application in a schematic manner, and therefore the illustrations only show components related to the present application rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0035] In the following description, a large number of details are discussed to provide a more thorough explanation of the embodiments of the present application. However, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present application difficult to understand.

[0036] First of all, it should be noted that YOLOv8 is a target detection algorithm. On the basis of inheriting the advantages of the previous generation models, the algorithm has made many improvements and optimizations, significantly improving the accuracy and speed of target detection. YOLO (You Only Look Once) is a one-stage target detection algorithm, that is, it only needs to "look" once to identify the category and bounding box of the object in the picture. YOLOv8 is built on the basis of the historical versions of the Yolo series, introducing new features and improvements, such as a new backbone network, anchor-free detection head, and a new loss function to improve the performance and flexibility of the model. The YOLOv8 detection model is the latest target detection model based on the YOLO (You Only Look Once) series. While maintaining the real-time detection characteristics of the YOLO series, this model further improves performance and flexibility by introducing new features and improvements.

[0037] Optical Character Recognition (OCR) is a technology that converts text in scanned images into editable and searchable digital text. OCR technology is widely used in document management, automated processing, information extraction, barrier-free reading and other fields.

[0038] Text detection based on OCR (Optical Character Recognition) and deep learning is an important research field, especially in document analysis, autonomous driving, image search, and robot vision. OCR technology is mainly used to recognize and extract text from images, while deep learning provides a powerful tool for OCR, making text detection more accurate and efficient.

[0039] Intersection over Union (IoU) is a commonly used evaluation metric in tasks such as object detection, semantic segmentation, and tracking. It is used to measure the degree of overlap between the predicted bounding box and the actual target bounding box. It can also be used to measure the degree of overlap between two bounding boxes.

[0040] Depthwise Separable Convolution is an effective convolution operation that decomposes the standard convolution operation into two steps: depthwise convolution and pointwise convolution, also known as 1x1 convolution. This decomposition can significantly reduce the amount of computation and parameters of the model while maintaining the performance of the model. In feature fusion, depthwise separable convolution can be used to effectively combine features from different levels or sources.

[0041] Non-dimensional marking inspection, also known as non-standard inspection, is a quality inspection mode that does not follow the unified industry standards, but designs special inspection instruments according to actual inspection needs for precision inspection. This inspection method mainly focuses on other marks and features besides size, such as surface defects, material properties, shape, etc.

[0042] Layer Normalization is a commonly used technique in deep neural networks, mainly used to accelerate the training process of the model and improve the performance of the model. Layer Normalization is to standardize the neurons in a certain layer of the neural network, rather than standardizing the entire batch of data. Specifically, layer normalization independently standardizes the activation value of each sample, rather than standardizing the entire batch like batch normalization. Layer normalization calculates the mean and variance of the neurons in a certain layer, and then uses the mean and variance to standardize the activation values ​​of the layer.

[0043] Non-Maximum Suppression (NMS) is a commonly used technique in image processing, computer vision and other fields. It is mainly used to suppress non-maximum elements, which can be understood as local maximum search. By suppressing non-maximum elements, key information in the image can be effectively extracted, which facilitates subsequent processing and analysis.

[0044] Confidence is a key concept in statistics, which is used to describe the degree of trust or confidence in the estimated interval of a population parameter constructed by a sample statistic. Confidence, also known as confidence level, is a probability value used to indicate the probability that the true value of the population parameter falls within a certain interval constructed by the sample statistic.

[0045] In machine learning and data science, negative examples usually refer to samples that are labeled as not belonging to the target category in a classification task. In other words, they are instances that do not belong to the category we are trying to predict or classify. In contrast to positive examples, positive examples are those that are labeled as the target category.

[0046] Figure 1 It is a schematic diagram of an exemplary system architecture shown in an exemplary embodiment of the present application.

[0047] Reference Figure 1As shown, the system architecture may include an image acquisition device 101 and a computer device 102. The computer device 102 may be at least one of a desktop graphics processing unit (GPU) computer, a GPU computing cluster, a neural network computer, etc. The image acquisition device 101 is used to acquire an image to be detected, wherein the image to be detected includes an engineering drawing. In this embodiment, the image acquisition device 101 acquires the above image and provides it to the computer device 102 for processing. Relevant technicians can use the computer device 102 to perform index identification detection on the image to be detected through a preset index identification detection model to obtain the index identification position, wherein the index identification detection model is obtained based on the basic model training, and the basic model is a YOLO model in which the C2F structure in the backbone is replaced with the Swin Transformer structure, and all the identifications in the image to be detected are detected to obtain the first identification position corresponding to the identification to be identified, and the secondary identification in the image to be detected is detected to obtain the second identification position corresponding to the secondary identification, and the index identification position and the second identification position are extracted from the first identification position to obtain the size identification position, wherein the identification to be identified includes the size identification, the index identification and the secondary identification, and the index identification position and / or the size identification position are identified to obtain the identification result corresponding to the engineering drawing. It should be noted that the image acquisition device 101 and the computer device 102 provided in this embodiment are only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0048] It should be noted that the identification method for engineering drawings provided in the embodiment of the present application is generally executed by the computer device 102 , and accordingly, the identification device for engineering drawings is generally set in the computer device 102 .

[0049] Figure 2 is a flow chart of a method for identifying a logo of an engineering drawing according to an exemplary embodiment of the present invention. The method for identifying a logo of an engineering drawing can be executed by a computing and processing device. The computing and processing device can be Figure 1 The computer device 102 shown in FIG. Figure 2 As shown, the identification method for engineering drawings includes at least steps S210 to S240, which are described in detail as follows:

[0050] In step S210, an image to be detected is obtained.

[0051] In one embodiment of the present application, the images to be detected include but are not limited to drawings such as engineering drawings, and the engineering drawings include but are not limited to architectural drawings and mechanical drawings. The methods of obtaining the images to be detected include but are not limited to one or more of scanning the engineering drawings, taking screenshots of the engineering drawings, and storing the engineering drawings.

[0052] In step S220, index mark detection is performed on the image to be detected using a preset index mark detection model to obtain the index mark position.

[0053] Among them, the index mark detection model is trained based on the basic model, which is the YOLO model with the C2F structure in the backbone replaced by the Swin Transformer structure. It should be noted that the C2F structure in the backbone of YOLOv8 is a new network structure module introduced in YOLOv8. The C2F module draws on the ELAN idea in YOLOv7, and aims to obtain richer gradient flow information while ensuring lightweight by parallelizing more gradient flow branches. The number of channels of the input Tensor of each BottleNeck in C2f is only 0.5 times that of the previous level, so the amount of calculation is significantly reduced. In addition, the increase in gradient flow can also significantly improve the convergence speed and convergence effect. Swin Transformer is a transformer-based image classification network structure, which is characterized by: image block partitioning: dividing the input image into multiple non-overlapping small blocks; window partitioning: partitioning the small blocks according to a certain window size. Each partition is independently processed by a learnable linear transformation; deep network: the features of each partition are processed by the deep network to obtain a higher-level feature representation. The self-attention calculation of Swin Transformer is limited to the local window, which makes the computational complexity linear with the image size, rather than quadratic. This design not only improves the efficiency of the model, but also maintains a strong feature extraction capability. Swin Transformer can capture the details and global information of the image at different levels, becoming a powerful general backbone network for various visual tasks.

[0054] In this embodiment, a pre-trained improved YOLOv8 detection model, i.e., an index mark detection model, is used to perform index mark detection on an engineering drawing to be detected, i.e., an image to be detected, to obtain an index mark position; wherein, the YOLOv8 network, i.e., a basic model, is improved based on the features of the index mark to obtain an improved YOLOv8 detection model, i.e., an index mark detection model, which adopts a hierarchical design to extract features in the backbone network, and includes a total of four stages, each of which reduces the resolution of the input feature map to expand the receptive field layer by layer, and adopts a deeply separable convolutional fusion feature; the input drawing must first be cut according to a sliding window of a fixed size (a first preset size) to ensure that the input drawing size is the same.

[0055] In this embodiment, the index identifier includes three categories, namely, lead identifier, section identifier and sectional view identifier. The index identifier information in the drawings is pre-marked, and the index identifiers in the engineering drawings are divided into three categories, namely, lead identifier, section identifier and cross-section identifier, i.e., sectional view identifier. Figure 3 As shown, Figure 3 This is a sample drawing of a marking method for engineering drawings shown in an exemplary embodiment of the present application, in which serial numbers such as "(26)" represent lead markings, the letter "L" next to the broken line arrow represents the planing section marking, and "AA" represents the cross-section marking. Use labelme to mark the three types of marking information in the drawing respectively, and convert the obtained marking data into a data set in Ultralytics YOLO format. There is a type of data in the engineering drawing with a lead line below (the lead line is drawn with a thin solid line, and it is preferably a straight line at 30°, 45°, 60°, or 90° to the horizontal direction, or a broken line that passes through the above angles and then folds to a horizontal position). This type of data is called lead marking data, i.e., lead marking; lead marking data consists of numbers and numbers in brackets, as well as a small number of Roman numerals. Not every engineering drawing has lead marking information. There is a type of data in engineering drawings with arrows next to it (the arrows may be followed by straight lines and curves, indicating the direction from which the drawing should be viewed). This type of data is called section data or section identification; section data is usually composed of letters, and not every engineering drawing has section data. For each section data in an engineering drawing, there will be a section view data at the corresponding position on this drawing or a sub-drawing with the same drawing number. There are roughly six types of section view data: A direction, AA, view A, part 1, part number 1, III (Roman numerals). Section view data will correspond to section data.

[0056] In one embodiment of the present application, the Swin Transformer structure includes in sequence: a first stage, the first stage includes a Patch Embedding unit and a plurality of Block units, wherein the Patch Embedding unit is used to segment the input first image and embed it into a vector to obtain a first feature map, the Block unit is used to perform layer standardization on the first feature map, segment the first feature map into a plurality of windows, calculate Attention and determine whether it is Window Attention or ShiftWindow Attention, merge windows, if a Shift operation has been performed, perform ReverseShift, perform Dropout and residual connection, and then perform layer standardization, a fully connected layer, Dropout and residual connection; a plurality of second stages connected in sequence, the second stage includes a Patch Merging unit and a plurality of Block units, wherein the Patch Merging unit is used to perform downsampling, obtain a downsampling result, and splice the downsampling result to obtain a splicing result, and adjust the number of channels of the splicing result through the fully connected layer to obtain a second feature map; the Block unit is used to perform layer standardization on the second feature map, segment the second feature map into a plurality of windows, calculate Attention and determine whether it is Window Attention or ShiftWindow Attention, merge windows, if Shift operation has been performed, perform ReverseShift, perform Dropout and residual connection, then perform layer standardization, fully connected layer, Dropout and residual connection.

[0057] In this embodiment, reference Figure 4a As shown, Figure 4a This is a schematic diagram of the network structure flow of the Swin Transformer used for the identification method of engineering drawings shown in an exemplary embodiment of the present application. The Swin Transformer structure includes four stages. In the first stage, a PatchEmbedding is performed first and then multiple Blocks are made. In the subsequent stage, the second stage, each stage consists of a PatchMerging and multiple Blocks; PatchEmbedding cuts the image into patches and then embeds them into vectors. Preferably, patch_size=4 is set; PatchMerging performs downsampling to reduce the resolution and adjust the number of channels. Preferably, each downsampling is 2 times, so in the row and column directions, elements are selected at intervals of 2, and then spliced ​​together as a whole tensor, and finally expanded. At this time, the channel dimension will become 4 times the original, and then the channel dimension is adjusted to twice the original through a fully connected layer; refer to Figure 4b As shown, Figure 4b This is a schematic diagram of a two-stage Swin Transformer Block structure for a method for identifying identification of engineering drawings, shown in an exemplary embodiment of the present application. The number of blocks in each stage must be an even number. First, the feature map is layer-normalized, and then it is determined whether to perform a Shift operation. The feature map is cut into windows, and the Attention is calculated and it is determined whether it is Window Attention or Shift Window Attention. The windows are merged. If a Shift operation has been performed before, ReverseShift is performed, Dropout and residual connections are performed, and then layer normalization and fully connected layers, as well as Dropout and residual connections are performed. Among them, in Figure 4b In this article, LN refers to layer normalization, MLP refers to the fully connected layer, W-MSA is Window multi-head self-attention, Dropout and residual connection are in each node ( Figure 4b It is made at the place with a cross in a circle.

[0058] In this embodiment, the Swin Transformer structure can also refer to the following description. The basic process of Swin Transformer is: in the first stage, input an image [H*W*3][H*W*3][H*W*3], and segment the input image to be detected through the Patch Partition layer, and perform feature mapping on the segmented data through the Linear Embedding layer, and input the feature mapped data into the Transformer block (SwinTransformer) with improved self-attention calculation. In stages 2 to 4, Patch Merging is required for downsampling before inputting the model to produce a hierarchical representation. Finally, the data of the resulting stage 4 is classified through the output module.

[0059] In this embodiment, the Patch Partition structure divides the image data into non-overlapping M*M patches. Each patch is regarded as a "marker" and its features are set to the concatenation of the original pixel RGB values. In this application, a patch size of 4x4 is used, so the feature dimension of each patch is 4x4x3=48. A linear embedding layer (Linear Embedding) is applied to this original value feature and projected to an arbitrary dimension (denoted as C). In actual operation, Patch Partition and Linear Embedding are implemented through a two-dimensional convolutional layer (the output channel is the Embedding dimension, the convolution kernel size is patch_size, and the stride size is patch_size).

[0060] In this embodiment, the Patch Merging layer mainly performs downsampling to produce a hierarchical representation. As the network goes deeper, the number of tokens is reduced through the Patch Merging layer. The first Patch Merging layer concatenates the features of each group of 2x2 adjacent patches and applies a linear layer on the concatenated 4C-dimensional features. This reduces the number of tokens by a factor of 2x2=4 (downsampling by 2 times the resolution, the length and width become 1 / 2 of the original respectively), and sets the output dimension to 2C. The SwinTransformer block is then used for feature transformation, and the resolution is maintained at h8 x w8. The patch merging and feature transformation of this first block is called the "second stage". The process is repeated twice as "stage 3" and "stage 4", with output resolutions of h16 xw16 and h32x w32 respectively. From the above description, it can be seen that after the data passes through the Patch Merging layer, the length and width become 1 / 2 of the original, and the depth becomes twice the original. Among them, tokens are used to represent the features of the input data. Specifically, when processing visual data such as images, the input image is first divided into several small patches (Patches), and each patch is represented as a token after a linear transformation (such as a convolution operation). These tokens are then sent to different layers in the Transformer model for processing; in this embodiment, the original feature dimension of each patch is C (i.e., the dimension of each token).

[0061] In this embodiment, the Swin Transformer Block, i.e., the above-mentioned Block unit, generally appears in a two-stage series structure. In the first stage, Window based Multi-headed Self-Attention (W-MSA) is used, and in the second stage, Shifted Window based Multi-headed Self-Attention (SW-MSA) is used. Different self-attention calculation methods are selected according to whether the current Swin Transformer Block is an odd or even number.

[0062] In this embodiment, the Swin Transformer structure can also refer to the following description: Patch Partition (image segmentation): The input image is divided into several small patches, and each patch is treated as an independent unit for processing to convert the image information into processable features. Linear Embedding (linear embedding): Linear embedding operation is performed on the patch to convert it into a high-dimensional feature vector. Transformer Encoder (Transformer encoder): In the Swin Transformer, the Transformer structure is used as the core computing unit. Complex feature interaction and information fusion are achieved by stacking multiple layers of Transformer encoders. In each layer of the encoder, the self-attention mechanism (Self-Attention) and the positional attention mechanism (Positional Attention) are used to capture long-distance dependencies in the image. Shift Window (sliding window): By introducing the Shift Window mechanism, interactions are generated between adjacent windows, thereby enhancing the receptive field of the model. The Shift Window operation allows features in different windows to interact by translating the window to the right or downward by a certain number of positions. Patch Merging: In order to increase the receptive field of the model and improve the feature extraction capability, adjacent small patches are merged into large patches, which can reduce the dimension of the feature map while retaining important feature information. The purpose of Patch Merging is to perform downsampling similar to that in CNN networks, reduce resolution, and adjust the number of channels. The resolution of the feature map is reduced by two times in each downsampling process, so adjacent patches of size 2×2 and spacing 2 are selected for merging in the row and column directions. Stage-wise Feature Extraction: Swin Transformer adopts a multi-stage design, and the entire model contains a total of 4 stages. Except for the first stage, each stage will first reduce the resolution of the input feature map through the Patch Merging layer, perform downsampling operations, and expand the receptive field layer by layer to obtain global information. Multi-head Self-Attention (MSA): In the Block of Swin Transformer, there are two types of MSA, one is Window-based MSA (W-MSA) and the other is Shifted Window-based MSA (SW-MSA).W-MSA focuses attention on each window, while SW-MSA solves the problem that W-MSA cannot see global information. It allows the model to learn cross-window information by sliding windows. As a general backbone network (Backbone) for computer vision, Swin Transformer has achieved good performance and results in tasks such as object classification, target detection, semantics and instance segmentation. Through the above structure, Swin Transformer can capture local and global information in the image while maintaining efficient calculation, providing powerful feature representation capabilities.

[0063] In this embodiment, the network structure of the improved YOLOv8 detection model uses Swin Transformer to replace the C2F module of the 5th layer in the backbone network. The network structure is as follows: Figure 4a As shown in the figure. Swin Transformer constructs hierarchical feature maps through a moving window mechanism, allowing the model to learn cross-window information. At the same time, through the downsampling layer, the model can process images of multiple resolutions, reducing the computational requirements and enabling the model to focus on local details and overall structural information. Swin Transformer retains the self-attention mechanism of Transformer, which enables the model to capture long-range dependencies in the image. The self-attention mechanism is the core of Transformer, which allows the model to establish weight relationships between different positions in the sequence. The Attention mechanism allows the model to focus on specific parts when processing a sequence, improving the model's sensitivity to key information, thereby helping the model better understand the layout and structure of text in the image in text recognition. Given its powerful feature extraction capabilities, Swin Transformer can effectively capture long-range dependencies in the input data and extract rich features, so that it can process inputs of any size without complex downsampling operations. And through hierarchical design and sliding window operations, Swin Transformer reduces the amount of computation, improves computational efficiency, and solves the problem of huge computational complexity of Transformer based on global attention.

[0064] In one embodiment of the present application, the basic model is a YOLO model in which the CBS structure in the neck is replaced with the GSConv structure; wherein the GSConv structure is used to perform ordinary convolution downsampling on the input second image to obtain a downsampling result, and perform deep convolution on the input second image to obtain a deep convolution result; the downsampling result and the deep convolution result are spliced, and a shuffle operation is performed to splice the corresponding number of channels of the ordinary convolution and the corresponding number of channels of the deep convolution.

[0065] In this embodiment, the GSConv structure first performs a downsampling of the input second image by a normal convolution, then uses a deep convolution, and splices the results of the two convolutions; finally, a shuffle operation is performed to splice the corresponding number of channels of the previous two convolutions together. It should be noted that the neck part of the YOLO series model is responsible for connecting the backbone and the head for feature fusion and processing. The neck of YOLOv8 retains the PAN idea, and may use other types of structures (such as C2f or Slim-Neck, etc.) for feature fusion. The GSConv structure is a design introduced in the neck part of the target detector to optimize feature fusion and processing in the convolutional neural network (CNN). The introduction of GSConv is to retain the hidden connections between channels as much as possible while maintaining a low time complexity. In the Slim-Neck structure, GS bottleneck and cross-stage partial network (GSCSP) modules may continue to be introduced after GSConv to further improve performance.

[0066] In this embodiment, the GSConv structure is used to replace the CBS module of the sixth layer in the neck network in the improved YOLOv8 identification detection network structure, which improves the detection speed while ensuring accuracy. The network structure is as follows: Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of GSConv for a method for identifying a logo of an engineering drawing, shown in an exemplary embodiment of the present application. In order to reduce the number of parameters and computational complexity of the model and make the model more lightweight, GSConv combines the Slim-Neck design, which is a new detector architecture design paradigm that maintains the structure of the model head and backbone, and uses a channel shuffle operation in the neck to mix information from different channels, which helps to reduce the amount of calculation while retaining the information interaction between feature maps, so that the feature maps obtained by the Swin Transformer module can be better processed.

[0067] In this embodiment, the process of training using the YOLOv8 training identification detection model is illustrated. Using the YOLOv8 training identification detection model, the data set is divided into a training set, a validation set, and a test set at a ratio of 0.7 / 0.15 / 0.15, and the specific division is shown in Table 1. The training and testing of the network model are both performed on the server, and the configuration of the server can be CPU: Intel (R) Core (TM) i7-9700K / GPU: RTX 2080Ti, the operating system used is Ubuntu20.04.2LTS, and the Pytorch version is 1.12. It should be noted that this embodiment is an example for better understanding, and does not limit the parameters such as the division of the data set, the number of data sets, the configuration of the server, and the operating system version. In actual application, it can be modified according to actual needs.

[0068] Table 1

[0069] type Training set Validation set Test Set Contains index mark 2461 525 527 No index mark 3791 810 810

[0070] As can be seen from Table 1, the data set is divided into a training set, a validation set, and a test set with index identifiers, and a training set, a validation set, and a test set without index identifiers. The corresponding data quantity refers to the above Table 1 and will not be repeated here. It should be noted that this embodiment is only an example, and the classification of the data set can be increased, reduced, or changed according to actual needs, and its quantity can also be modified according to actual needs, and this application does not limit this.

[0071] Precision, recall and comprehensive index F1 value are used as evaluation criteria for the engineering drawing mark detection model. The PR curve (Precision-Recall Curve) is used to describe the relationship between the precision P and recall R of the classifier at different thresholds.

[0072] The calculation formula of accuracy is:

[0073]

[0074] The calculation formula for recall is:

[0075]

[0076] The calculation formula of F1 value is:

[0077]

[0078] Among them, in formulas (1) to (3), P is the precision; R is the recall; F1 is the comprehensive index; TP (True Positive) represents a true positive example, that is, the model correctly classifies the sample as a positive example; FP (False Positive) represents a false positive example, that is, the model incorrectly classifies the sample as a positive example; FN (False Negative) represents a false negative example, that is, the model incorrectly classifies the sample as a negative example.

[0079] The test results are shown in Table 2. Figure 6 Provides the corresponding PR curve, Figure 6 It is a PR curve of the test results of the identification method for engineering drawings shown in an exemplary embodiment of the present application.

[0080] Table 2

[0081] Index Identifier Category Accuracy Recall F1 value Lead identification 97.74% 99.20% 0.9846 Section mark 97.06% 97.06% 0.9706 Cross-section identification 96.09% 96.85% 0.9647

[0082] As can be seen from Table 2, the test results include the precision, recall and F1 value of the lead identification, the precision, recall and F1 value of the section identification, and the precision, recall and F1 value of the cross-section identification. The corresponding values ​​refer to the above Table 2 and are not repeated here. It should be noted that this embodiment is only an example, and the test items of the test results can be increased, reduced or changed according to actual needs, and their values ​​are also filled in according to the actual results, and this application does not limit this.

[0083] In one embodiment of the present application, the image to be detected is cut according to a first preset size to obtain one or more image segments, and index marker detection is performed on the image segments using an index marker detection model.

[0084] In this embodiment, a sub-graph cutting method is used to cut a sub-graph of a first preset size (for example, a fixed resolution of 1280*720) in the original drawing as a data set for detecting index identification. The data set of this embodiment is derived from a special engineering drawing provided by the enterprise, and the format is converted, for example, from PDF format to PNG format. Since there are fewer engineering drawings and they are of different sizes, they cannot be directly used as a training set. They should be pre-processed first, and the pre-processing includes but is not limited to at least one of format conversion, drawing segmentation, geometric transformation, edge detection and global threshold binarization. Since the resolution of engineering drawings is high, some drawings may reach a resolution of tens of thousands. In order to use the data set for training later, it is necessary to segment the drawings, for example, into pictures with a resolution of 1280*720, and make a data set based on this. When segmenting the pictures, redundancy will be left between each picture. The purpose of doing this is to prevent the text information in the drawing from being destroyed at the dividing line, thereby increasing the number of identification samples. In order to increase the recognition ability of rotated text, it is also necessary to perform geometric transformations on the drawings in the training set, such as rotation, flipping, scaling, translation, etc. These operations change the spatial structure of the image, but do not change the content of the image. At the same time, edge information is extracted by calculating the gradient of the image or edge detection such as Laplace operation, which helps to retain important structural information of the image while removing noise. Since engineering drawings only contain black and white, in drawings with higher resolution, the grayscale value of the data set obtained after cutting is low, and the effect of direct training is poor. In order to make the outline and shape of the target object in the drawing more obvious, global threshold binarization is required. A single threshold is selected to process the entire image. All pixels above this threshold are set to 1, and all pixels below the threshold are set to 0. Such operations are used to separate text from background for subsequent text recognition. The main purposes of preprocessing include: 1. Increase the number of training sets; 2. Unify the size of the training set; 3. Improve the quality of the training set.

[0085] In one embodiment of the present application, a sliding window is determined from an image segment; the sliding window is controlled to slide in the image segment, and index mark detection is performed on the sliding window to obtain sub-image position information corresponding to at least one original detection frame in the image segment and the confidence of the index mark corresponding to the original detection frame, wherein the index mark exists in the original detection frame; non-maximum suppression is performed when the image segment is integrated based on the offset position of the image to be detected; the original image position information of the original detection frame corresponding to the image to be detected is determined according to the sub-image position information corresponding to the original detection frame in the image segment; any original detection frame is determined as the first detection frame, and all the original detection frames except the first detection frame are determined as the first detection frame. The original detection frames outside the frame are respectively determined as second detection frames; a first area intersection-union ratio is calculated based on the intersection of the first area and the second area and the union of the first area and the second area, the first area is obtained based on the original image position information of the first detection frame, and the second area is obtained based on the original image position information of the second detection frame; if the first area intersection-union ratio is greater than a preset first area threshold, the index identifier confidence of the first detection frame and the index identifier confidence of the second detection frame are compared to determine the target detection frame with the highest index identifier confidence from the first detection frame and the second detection frame, and the original image position information corresponding to the target detection frame is used as the index identifier position.

[0086] In this embodiment, each time the control window slides horizontally or vertically, the horizontal sliding and vertical sliding respectively slide half of the width of the sub-image 640 and half of the height 360. In the detection result, the same mark of a drawing may be detected multiple times. Finally, the sub-image is integrated based on the offset position of the original image, and non-maximum suppression is performed. The area intersection and union ratio IoU between the detection frames is calculated. If it is greater than the first area threshold preset by the threshold (for example, 0.6), it is judged as the same mark, and the one with high confidence is retained, that is, the detection frame with high confidence is determined as the index mark. It should be noted that the sliding size of the sliding window is a preset size. The half of the width and half of the height of the sliding sub-image in this embodiment are only for example and can be changed according to actual needs.

[0087] In step S230, all the markers in the image to be detected are detected to obtain the first marker position corresponding to the marker to be identified, and the secondary markers in the image to be detected are detected to obtain the second marker position corresponding to the secondary marker. The index marker position and the second marker position are extracted from the first marker position to obtain the size marker position.

[0088] The identification marks to be identified include size identification marks, index identification marks and secondary identification marks.

[0089] In one embodiment of the present application, the image to be detected is proportionally reduced to a second preset size with the long side, and the reduction ratio is recorded; the adjusted image to be detected is input into a preset secondary marker detection model to obtain a secondary marker position, wherein the secondary marker detection model is trained based on marker samples with secondary marker labels, and the secondary marker position is the position of the secondary marker in the adjusted image to be detected; the second marker position is calculated based on the secondary marker position and the reduction ratio.

[0090] In this embodiment, the drawing to be inspected is first scaled down so that the longer side is shortened to a second preset size, such as a resolution of 640, and the reduction ratio is recorded, which is then input into the model to obtain the position of the non-size text information in the reduced image, i.e., the secondary identification position, and then restored to the original image size position according to the reduction ratio. Figure 7 As shown, Figure 7 It is a schematic diagram of the non-size identification area of ​​the identification recognition method for engineering drawings shown in an exemplary embodiment of the present application) mainly including various tables in the drawings (including parts list, drawing information table, responsible personnel table, etc.) and text descriptions such as technical specifications about the content of the drawings. YOLOv8 is used to classify and detect these non-size targets. Unlike the above-mentioned index identification detection training, since the index identification is usually small, it can be guaranteed that the identification is completely contained in a certain size window, while the bounding box size of the table and text description in the drawing is large and it is difficult to use a fixed size window to ensure that the content is contained. Therefore, the drawings are first proportionally reduced to a preset size (for example, 640*640 resolution) and then used as a data set. During reasoning, the reduction ratio is first recorded and then the non-size target position information output by the model is restored to the position based on the original drawing size according to the ratio. And because the non-size target is large enough, it has been verified that the key features sufficient for the model to learn and recognize can still be retained after the drawing is reduced.

[0091] In this embodiment, the general text detection in PaddleOCR is used to detect and locate all text information in the drawing image to be detected, and the first mark position corresponding to the mark to be identified is obtained. The pre-trained YOLOv8 detection model, that is, the secondary mark detection model, is used to perform non-size mark detection on the secondary mark in the engineering drawing to be detected, and the second mark position corresponding to the secondary mark is obtained; wherein, the pre-trained YOLOv8 detection model is called a non-size text information detection model, and the secondary mark includes a non-size mark, which is a mark that contains text in the drawing and does not belong to the size mark area. There are a large number of part dimension data in the engineering drawings, which are numerous, uncertain in position, and in various formats. If the dimension data is manually marked, it will take a lot of time and manpower. The general text detection model provided by PaddleOCR is used to detect and identify all texts in the engineering drawings, and exclude the mark data and other irrelevant texts in the engineering drawings, thereby filtering out the dimension data, which not only saves time and labor costs, but also improves the accuracy of detection and recognition.

[0092] In one embodiment of the present application, the area of ​​the region corresponding to the first identification position is determined as the first area, the area of ​​the region corresponding to the index identification position is determined as the index area, and the area of ​​the region corresponding to the second identification position is determined as the second area; the second area intersection-union ratio is calculated based on the intersection of the first area area and the index area area and the union of the first area area and the index area area. If the second area intersection-union ratio is greater than a first preset threshold, it is determined that the first identification position and the index identification position are the same position; the intersection area of ​​the first area area and the second area area is calculated, and the area ratio is calculated based on the intersection area and the second area area. If the area ratio is greater than the second preset threshold, it is determined that the first identification position is located inside the second identification position; the index identification position and the second identification position are filtered from the first identification position to obtain the size identification position.

[0093] In this embodiment, the detected text information position, i.e., the first identification position, is compared with the detected index identification position and the non-size text position, i.e., the second identification position, and the relevant area of ​​each text information position corresponding to the index identification position and the non-size text position is calculated, and the size identification position is obtained by screening. When compared with the index identification, the intersection and union ratio (IoU) of the candidate box areas of the two is calculated to determine whether the text candidate box represents the same identification position as the index candidate box. If it is greater than a first preset threshold (e.g., 0.6), it is determined to be the same identification and the candidate box is discarded; when compared with the non-size text information, the ratio of the intersection area of ​​the two to the non-size text information area is calculated. If it is greater than a second preset threshold (e.g., 0.9), it is determined that the text candidate box belongs to the non-size area, the candidate box is discarded, and the remaining candidate boxes are identified as size identifications.

[0094] In this embodiment, in terms of filtering strategy, the size candidate sample set is all text boxes detected by PaddleOCR, and the negative samples include index identification boxes, table boxes, and text description boxes. For each candidate box, the second area intersection and union ratio r1 needs to be calculated with the boxes in the negative samples. The calculation method is based on formula (4):

[0095]

[0096] Wherein, in formula (4), r1 is the second area intersection-union ratio, Sintersection is the intersection of the area of ​​the text box and the box in the negative sample, that is, the intersection of the area of ​​the first area and the area of ​​the index area, and Sunion is the union of the area of ​​the text box and the box in the negative sample, that is, the union of the area of ​​the first area and the area of ​​the index area.

[0097] If r1 exceeds the first preset threshold (e.g., 0.6), the candidate box is determined to be a non-size mark and should be removed; in addition, since the table and text description area are large, some candidate boxes will be included in them, such as Figure 8 As shown in the grey box area, Figure 8 This is a non-size identification sample diagram of an identification recognition method for engineering drawings shown in an exemplary embodiment of the present application. At this time, it is also necessary to calculate the ratio of the intersection area of ​​the two to the area of ​​the candidate frame. The calculation method refers to formula (5):

[0098]

[0099] Wherein, in formula (5), r2 is the ratio of the intersection area to the area of ​​the area corresponding to the second identification position, Sintersection is the intersection of the area of ​​the text box and the candidate box, that is, the intersection area of ​​the first area and the second area, and Scandidate box is the area of ​​the candidate box, that is, the area of ​​the second area.

[0100] If r2 exceeds a second preset threshold (eg, 0.9), it is determined that the candidate box is included in the non-size object and is also a non-size mark and should be removed. The candidate box that is finally retained is the size mark.

[0101] In step S240, the index mark position and / or the size mark position are identified and recognized to obtain an identification result corresponding to the engineering drawing.

[0102] In one embodiment of the present application, the index identification position and the size identification position are integrated to obtain an integration result, wherein the integration result includes the identification position and the identification category; the image to be detected is cropped according to the identification position to obtain a cropped image including only the identification content; the cropped image is identified to obtain an identification result corresponding to the engineering drawing.

[0103] In this embodiment, PaddleOCR is used to perform text recognition on all index logos and size logo areas. The detected index logos and size logos are integrated together and output as a json file, which contains information such as the file name, logo position, logo category, etc., where the logo position is represented by 4 point coordinates, representing the 4 vertices of the logo detection box. The general text recognition tool provided by PaddleOCR is used to identify the logo content. According to the logo position in the json file, a picture containing only the logo content is cropped from the drawing. The PP-OCRv4 model provided by PaddleOCR is used to identify the text content of the cropped picture, and the recognition result is written into the json file.

[0104] Fig. 9 FIG. 1 is a flow chart of a method for identifying a logo of an engineering drawing according to another exemplary embodiment of the present application. Fig. 9 As shown, in an exemplary embodiment, the original image of the engineering drawing, i.e., the image to be detected, is cut into sub-images and then input into the index identification model, and after position restoration and non-maximum suppression are performed on it, the index identification position is obtained; the original image of the engineering drawing, i.e., the image to be detected, is input into the general text detection model to obtain the text position, i.e., the first identification position; the original image of the engineering drawing, i.e., the image to be detected, is input into the non-size detection model, i.e., the secondary identification detection model, to obtain the non-size position, i.e., the second identification position; the index identification position and the non-size position are extracted from the text position, and the size identification position is obtained by screening; the PaddleOCR general text recognition model is used to identify the index identification position and the size identification position, and obtain the key identification content text information. Among them, the specific implementation method of this embodiment has been described in detail in the aforementioned embodiments, and will not be repeated here.

[0105] This application locates and identifies the index marks with relatively obvious features first, and the index marks include one or more of the lead marks, the section marks and the cross-section marks; the index mark detection model is an improved YOLOv8 detection model, which adopts a hierarchical design to extract features in the backbone network and uses deep separable convolution to fuse features; then locate all the text information in the original drawing, that is, the image to be detected, and then filter out the size marks from the text candidate frame by calculating the intersection and union ratio of the candidate frame area, and finally use the PaddleOCR general text recognition model to perform character recognition on all index marks and size mark areas. Thus, a method for detecting and identifying engineering drawing serial numbers with high precision and recall rate is provided.

[0106] Based on the characteristic that there are obvious signs around the index marks in engineering drawings, this application improves the YOLOv8 network. By using the Swin Transformer module in the backbone network, the model can learn cross-window information without reducing the calculation rate. This application introduces the deep separable convolution module GSConv to ensure that the feature map of the engineering drawing will not lose some semantic information due to spatial compression and channel expansion.

[0107] This application identifies index marks and size marks separately, and first identifies the index marks with more obvious features, so that the index marks can be accurately identified among the size marks with various symbols. When calculating the size mark, after detailed text recognition of the entire image, the obtained recognition result and the intersection and union ratio of the candidate box areas between the non-size marks and the index marks are calculated to remove obviously erroneous recognition results, thereby reducing the phenomenon of misrecognition. In this application, redundant processing is performed when the original drawings are cropped, and the number of samples is increased when the number of drawings is limited, thereby improving the detection accuracy.

[0108] Fig.10 is a block diagram of a device for identifying a logo of an engineering drawing, shown in an exemplary embodiment of the present application. The device can be applied to Figure 1 The implementation environment shown in the figure is specifically configured in the computer device 102. The device can also be applied to other exemplary implementation environments and specifically configured in other devices. This embodiment does not limit the implementation environment to which the device is applied.

[0109] like Fig.10 As shown, the exemplary identification recognition device for engineering drawings includes: an acquisition module 1010 , an index identification module 1020 , a size identification module 1030 and an identification module 1040 .

[0110] Among them, the acquisition module 1010 is used to acquire the image to be detected, wherein the image to be detected includes an engineering drawing; the index identification module 1020 is used to perform index identification detection on the image to be detected through a preset index identification detection model to obtain the index identification position, wherein the index identification detection model is obtained based on the basic model training, and the basic model is a YOLO model in which the C2F structure in the backbone is replaced with the Swin Transformer structure; the size identification module 1030 is used to detect all the identifiers in the image to be detected, obtain the first identification position corresponding to the identifier to be identified, and detect the secondary identifier in the image to be detected to obtain the second identification position corresponding to the secondary identifier, extract from the first identification position through the index identification position and the second identification position to obtain the size identification position, wherein the identifier to be identified includes the size identification, the index identification and the secondary identification; the identification module 1040 is used to identify the index identification position and / or the size identification position to obtain the identification result corresponding to the engineering drawing.

[0111] It should be noted that the identification device for engineering drawings provided in the above embodiment and the identification method for engineering drawings provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment and will not be repeated here. In actual application, the identification device for engineering drawings provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.

[0112] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by one or more processors, the electronic device implements the identification method for engineering drawings provided in the above-mentioned embodiments.

[0113] Fig.11 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0114] like Fig.11As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1102 or the program loaded from the storage part 1108 to the random access memory (RAM) 1103, such as executing the methods provided in the above-mentioned various embodiments. In the RAM 1103, various programs and data required for system operation are also stored. The CPU 1101, the ROM 1102 and the RAM 1103 are connected to each other through the bus 1104. The input / output (I / O) interface 1105 is also connected to the bus 1104.

[0115] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom is installed into the storage section 1108 as needed.

[0116] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1109, and / or installed from a removable medium 1111. When the computer program is executed by a central processing unit (CPU) 1101, various functions defined in the system of the present application are executed.

[0117] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0118] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0119] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0120] Another aspect of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the identification method for engineering drawings provided in the above embodiments. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently without being assembled into the electronic device.

[0121] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0122] Another aspect of the present application also provides a computer program product or a computer program, the computer program product or the computer program includes a computer instruction, the computer instruction is stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the identification recognition method for engineering drawings provided in the above-mentioned various embodiments.

[0123] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.

[0124] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.

[0125] The above embodiments are merely illustrative of the principles and effects of the present application, and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.

Claims

1. A method for identifying a logo in an engineering drawing, characterized in that: include: Acquire an image to be detected, wherein the image to be detected includes an engineering drawing; Performing index mark detection on the image to be detected by a preset index mark detection model to obtain the index mark position, wherein the index mark detection model is obtained by training based on a basic model, and the basic model is a YOLO model in which the C2F structure in the backbone is replaced with a Swin Transformer structure; Detect all the markers in the image to be detected to obtain a first marker position corresponding to the marker to be identified, and detect the secondary marker in the image to be detected to obtain a second marker position corresponding to the secondary marker, and extract the index marker position and the second marker position from the first marker position to obtain a size marker position, wherein the marker to be identified includes a size marker, an index marker and a secondary marker; The index identification position and / or the size identification position are identified and recognized to obtain an identification result corresponding to the engineering drawing.

2. The identification method for engineering drawings according to claim 1, characterized in that: Performing index mark detection on the image to be detected by using a preset index mark detection model includes: The image to be detected is cut into pieces to obtain one or more image segments, and index marker detection is performed on the image segments using the index marker detection model.

3. The identification method for engineering drawings according to claim 2, characterized in that: The method further comprises: Determining a sliding window from the image segment; Controlling the sliding window to slide in the image segment, and performing index mark detection on the sliding window to obtain sub-image position information corresponding to at least one original detection frame in the image segment and confidence of the index mark corresponding to the original detection frame, wherein the index mark exists in the original detection frame; Performing non-maximum suppression when integrating the image segments based on the offset positions of the image to be detected; Determine the original image position information corresponding to the original detection frame in the image to be detected according to the sub-image position information corresponding to the original detection frame in the image segment; Determine any original detection frame as a first detection frame, and determine the original detection frames other than the first detection frame as second detection frames respectively; Calculating a first area intersection-to-union ratio based on an intersection of a first area and a second area and a union of the first area and the second area, wherein the first area is obtained based on original image position information of the first detection frame, and the second area is obtained based on original image position information of the second detection frame; If the first area intersection-to-union ratio is greater than a preset first area threshold, the index identifier confidence of the first detection frame and the index identifier confidence of the second detection frame are compared to determine the target detection frame with the highest index identifier confidence from the first detection frame and the second detection frame, and the original image position information corresponding to the target detection frame is used as the index identifier position.

4. The identification method for engineering drawings according to claim 1, characterized in that: Detecting the secondary mark in the image to be detected to obtain a second mark position corresponding to the secondary mark includes: Reducing the image to be detected in proportion until the long side has a second preset size, and recording the reduction ratio; Inputting the adjusted image to be detected into a preset secondary mark detection model to obtain a secondary mark position, wherein the secondary mark detection model is trained based on mark samples with secondary mark labels, and the secondary mark position is the position of the secondary mark in the adjusted image to be detected; The second identification position is calculated based on the secondary identification position and the reduction ratio.

5. The marking recognition method for engineering drawings according to any one of claims 1 to 4, characterized in that: The step of extracting the first identification position from the first identification position through the index identification position and the second identification position to obtain the size identification position includes: Determine the area of ​​the region corresponding to the first identification position as the first area of ​​the region, determine the area of ​​the region corresponding to the index identification position as the index area of ​​the region, and determine the area of ​​the region corresponding to the second identification position as the second area of ​​the region; Calculating a second area intersection-to-union ratio based on the intersection of the first area area and the index area area and the union of the first area area and the index area area, and if the second area intersection-to-union ratio is greater than a first preset threshold, determining that the first marker position and the index marker position are the same position; Calculating the intersection area of ​​the first region and the second region, and calculating an area ratio according to the intersection area and the second region area, and if the area ratio is greater than a second preset threshold, determining that the first mark position is located inside the second mark position; The index identification position and the second identification position are filtered from the first identification position to obtain a size identification position.

6. The marking and recognition method for engineering drawings according to any one of claims 1 to 4, characterized in that: Identifying the index identification position and / or the size identification position to obtain an identification result corresponding to the engineering drawing includes: Integrate the index identification position and the size identification position to obtain an integration result, wherein the integration result includes an identification position and an identification category; Cropping the image to be detected according to the position of the mark to obtain a cropped image including only the mark content; The cropped image is identified and a recognition result corresponding to the engineering drawing is obtained.

7. The marking recognition method for engineering drawings according to any one of claims 1 to 4, characterized in that: The Swin Transformer structure includes: The first stage includes a Patch Embedding unit and a plurality of Block units, wherein the Patch Embedding unit is used to segment the input first image and embed it into a vector to obtain a feature map, and the Block unit is used to perform layer normalization on the feature map, segment the feature map into a plurality of windows, calculate Attention and determine whether it is Window Attention or Shift Window Attention, merge windows, perform ReverseShift if a Shift operation has been performed, perform Dropout and residual connection, and then perform layer normalization, fully connected layer, Dropout and residual connection; Multiple second stages are connected in sequence, and the second stage includes a Patch Merging unit and multiple Block units, wherein the Patch Merging unit is used to perform downsampling to obtain a downsampling result, and the downsampling result is spliced ​​to obtain a splicing result, and the number of channels of the splicing result is adjusted through a fully connected layer.

8. The marking and recognition method for engineering drawings according to any one of claims 1 to 4, characterized in that: The basic model is a YOLO model in which the CBS structure in the neck is replaced with the GSConv structure; The GSConv structure is used to perform ordinary convolution downsampling on the input second image to obtain a downsampling result, and perform deep convolution on the input second image to obtain a deep convolution result; The downsampling result and the depth convolution result are concatenated and a shuffle operation is performed.

9. A marking recognition device for engineering drawings, characterized in that: include: An acquisition module, used for acquiring an image to be detected, wherein the image to be detected includes an engineering drawing; An index identification module is used to perform index identification detection on the image to be detected through a preset index identification detection model to obtain the index identification position, wherein the index identification detection model is obtained by training based on a basic model, and the basic model is a YOLO model in which the C2F structure in the backbone is replaced with a Swin Transformer structure; A size identification module, used to detect all the identifiers in the image to be detected to obtain a first identifier position corresponding to the identifier to be identified, and detect the secondary identifier in the image to be detected to obtain a second identifier position corresponding to the secondary identifier, and extract the index identifier position and the second identifier position from the first identifier position to obtain a size identifier position, wherein the identifier to be identified includes a size identifier, an index identifier and a secondary identifier; The identification module is used to identify the index identification position and / or the size identification position to obtain an identification result corresponding to the engineering drawing.

10. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to implement the identification method for engineering drawings as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Engineering drawing character detection and recognition method and system based on improved YOLOv5s

    CN116597466A

  • Engineering drawing identification method and device and storage medium

    CN117576717A

  • Power equipment infrared image identification method and device and medium

    CN117746212A

  • YOLO-based image target recognition method and apparatus, electronic device, and storage medium

    WO2020164282A1

Cited By

  • Thermal infrared imager-based road appearance damage rapid detection and visualization method and system

    CN119579572A