Image recognition method, electronic device, and storage medium
By constructing and training a semantic segmentation network to re-annotate the initially labeled images, the problem of insufficient generalization ability of image recognition models is solved, and higher recognition accuracy and consistency are achieved.
Patent Information
- Application Number
- CN202210570817.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-24
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2042-05-24
AI Technical Summary
Because the training images have many dimensions and a small number of annotations, the generalization ability of existing image recognition models is poor, resulting in low recognition accuracy.
By constructing a first semantic segmentation network to re-annotate the initially labeled images, generating target images and training them, a second semantic segmentation network is formed. This unifies the annotation method for the same target object in different datasets, increases training data, unifies the annotation method, and improves the model's generalization ability.
It improves the accuracy and generalization ability of image recognition, ensures the consistency of annotation results for the same target object in different images, and enhances the effect of image recognition.
Smart Images

Figure CN117173442B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more particularly to an image recognition method, electronic device, and storage medium. Background Technology
[0002] In current image recognition solutions, the training images have many annotation dimensions, and the number of training images for each annotation dimension is small, which leads to poor generalization ability of the trained model and low accuracy of image recognition. Summary of the Invention
[0003] In view of the above, it is necessary to provide an image recognition method, electronic device, and storage medium that can improve the accuracy of image recognition.
[0004] This application provides an image recognition method, the image recognition method comprising:
[0005] A first semantic segmentation network is constructed. The initial annotation image and its initial annotation result are obtained. The initial annotation result is compared with a preset annotation result to obtain a comparison result. If the comparison result is that the initial annotation result is different from the preset annotation result, the initial annotation image is input into the first semantic segmentation network to obtain a target image corresponding to the initial annotation image and the target annotation result of the target image. The first semantic segmentation network is trained based on multiple target images and the target annotation result of each target image to obtain a second semantic segmentation network. The image to be identified is input into the second semantic segmentation network to obtain the image annotation result of the image to be identified.
[0006] According to an optional embodiment of this application, before comparing the initial annotation result with the preset annotation result, the method further includes:
[0007] Obtain multiple preset color labels, multiple preset values, and multiple preset categories; establish the correspondence between each preset value and each color label to obtain multiple target labels; establish the correspondence between each preset category and each target label to obtain the preset labeling results.
[0008] According to an optional embodiment of this application, the initial annotation result includes multiple initial categories and an initial label corresponding to each initial category, and the comparison of the initial annotation result with the preset annotation result to obtain the comparison result includes:
[0009] Obtain each initial object in the initial labeled image and determine the initial category corresponding to each initial object; if any initial category does not have a corresponding preset category, determine that the comparison result is that the initial labeling result is different from the preset labeling result; or, if each initial category has a corresponding preset category and the initial label corresponding to each initial category is different from the target label of the corresponding preset category, determine that the comparison result is that the initial labeling result is different from the preset labeling result.
[0010] According to an optional embodiment of this application, the first semantic segmentation network includes an autoencoder and a classifier, and the step of inputting the initial labeled image into the first semantic segmentation network to obtain a target image corresponding to the initial labeled image and the target labeling result of the target image includes:
[0011] The initial labeled image is processed using the autoencoder to generate a target feature map; each pixel in the target feature map is classified based on the classifier to obtain the label category corresponding to each pixel; the target feature map is labeled based on the label category corresponding to each pixel and the target label corresponding to the label category to generate the target image and the target labeling result.
[0012] According to an optional embodiment of this application, the autoencoder includes multiple cascaded structures and a decoder, and the step of processing the initial labeled image using the autoencoder to generate a target feature map includes:
[0013] Feature extraction is performed on the initial labeled image based on multiple hidden layers in any cascaded structure to obtain an initial feature map output by the last hidden layer; pooling is performed on the initial feature map based on the pooling layer of any cascaded structure to output a first feature map; the first feature map output by the current cascaded structure is input into the next cascaded structure until the first feature map output by the last cascaded structure is obtained as the second feature map; the pixel value of each pixel in the multiple first feature maps is obtained in the first pixel position of the corresponding initial feature map, and the pixel value of each pixel in the second feature map is obtained in the second pixel position of the corresponding initial feature map; the second feature map is decoded based on the decoder, the first pixel position, and the second pixel position to obtain the target feature map.
[0014] According to an optional embodiment of this application, classifying each pixel in the target feature map based on the classifier to obtain the labeled category corresponding to each pixel includes:
[0015] Calculate a single score value for each pixel in the target feature map based on the pixel value of each pixel in the target feature map; calculate the probability of the pixel corresponding to the single score value belonging to each preset category based on the single score value and the multiple preset categories; determine the preset category corresponding to the category with the largest category probability value as the label category corresponding to the pixel.
[0016] According to an optional embodiment of this application, the formula for calculating the category probability is:
[0017]
[0018] Among them, S i This represents the probability that each pixel belongs to the i-th preset category. z represents the single score value of the j-th pixel in the target feature map. j This represents the pixel value of the j-th pixel in the target feature map. The total score value of all pixels in the target feature map is represented by , i represents the i-th preset category, and k represents the number of preset categories.
[0019] According to an optional embodiment of this application, the step of annotating the target feature map based on the annotation category corresponding to each pixel and the target label corresponding to the annotation category, and generating the target image and the target annotation result, includes:
[0020] The region consisting of all pixels corresponding to the same label category in the target feature map is defined as a feature region; the pixel values of all pixels in the feature region are adjusted to preset values corresponding to the same label category; each pixel in the feature region is colored according to the color label corresponding to the preset value of the feature region to obtain a target region; the multiple target regions are spliced together according to their regional positions in the target feature map to obtain the target image; the preset value, color label, and label category corresponding to each target region in the target image are determined as the target labeling result.
[0021] This application provides an electronic device, the electronic device comprising:
[0022] Memory, storing at least one instruction; and
[0023] The processor executes the at least one instruction to implement the image recognition method.
[0024] This application provides a computer-readable storage medium storing at least one instruction, which is executed by a processor in an electronic device to implement the image recognition method.
[0025] As can be seen from the above technical solutions, since the initial labeled images in this application come from different datasets, the initial labeling results for the same target object are different between any two initial labeled images from different datasets (i.e., the labeling methods for the same target object in any two initial labeled images are different). The initial labeled images are re-labeled by the first semantic segmentation network. Since the first semantic segmentation network is trained based on the images with the preset labeling results, it can make the target images generated by the first semantic segmentation network have the same target labeling results for the same target object (i.e., the labeling methods for the same target object in the target images are unified). Then, the first semantic segmentation network is trained based on the multiple target images and the target labeling results of each target image to obtain the second semantic segmentation network. Since the training data of the first semantic segmentation network is increased and the labeling methods of the training images are unified, the generated second semantic segmentation network has better generalization ability, thereby improving the accuracy of the image labeling results. Attached Figure Description
[0026] Figure 1 This is a flowchart of a preferred embodiment of the image recognition method of this application.
[0027] Figure 2 This is a schematic diagram of the initial labeled image in the image recognition method of this application.
[0028] Figure 3 This is a schematic diagram of the structure of an electronic device that implements the image recognition method of this application. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this application clearer, the application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0030] The image recognition method can be applied to one or more electronic devices 1. The electronic device 1 is a device capable of automatically calculating parameter values and / or processing information according to pre-set or stored instructions. Its hardware includes, but is not limited to: microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0031] The electronic device 1 can be any electronic product that can interact with the user, such as a personal computer, tablet computer, smartphone, personal digital assistant (PDA), game console, interactive network television (IPTV), smart wearable device, etc.
[0032] The electronic device 1 may further include network devices and / or user devices. The network devices include, but are not limited to, a single network server, a server group consisting of multiple network servers, or a cloud based on cloud computing consisting of a large number of hosts or network servers.
[0033] The network in which the electronic device 1 is located includes, but is not limited to: the Internet, wide area network, metropolitan area network, local area network, virtual private network (VPN), etc.
[0034] like Figure 1 The diagram shown is a flowchart of a preferred embodiment of an image recognition method according to this application. Depending on different needs, the order of the steps in the flowchart can be adjusted according to actual detection requirements, and some steps can be omitted. The method is executed by an electronic device, for example... Figure 1 Electronic device 1 shown.
[0035] S10, acquire the image to be identified, and acquire the initial labeled image and the initial labeled result of the initial labeled image.
[0036] In at least one embodiment of this application, the initial labeled image refers to multiple images for which the initial labeling results are known. The initial labeled image contains multiple initial objects, wherein the same initial object in different datasets corresponds to multiple initial categories, multiple initial colors, and multiple initial numbers.
[0037] For example: Obtain a first initially labeled image from dataset A and a second initially labeled image from dataset B. Both the first and second initially labeled images contain the initial object vehicle. The initial category of the initial object vehicle in the first initially labeled image is sedan and bus.
[0038] The initial color of the sedan is blue, and its initial number is 3. The initial color of the bus is purple, and its initial number is 5. In the second initial labeled image, the initial categories of the initial object vehicles are motorcycles and trucks. The initial color of the motorcycle is blue, and its initial number is 1. The initial color of the truck is black, and its initial number is 8.
[0039] In at least one embodiment of this application, the initial annotation result refers to the correspondence between the initial category of each initial object in the initial annotation image and each initial label, and each initial label refers to the correspondence between the initial color of each initial object in the initial annotation image and the initial number of each initial object.
[0040] The initial category of the initial object can be: car, tree, telephone pole, pedestrian, double yellow line, white line, etc. The initial color can be: gray, red, orange, yellow, yellow-green, brown, and light blue, etc.
[0041] For example, the initial objects in any initially labeled image are: people, vehicles, trees, road facilities, roads, and lane lines. The initial categories corresponding to each initial object are: pedestrians, cars, trees, utility poles, roads, double yellow lines, and white lines. The initial labeling results of any initially labeled image are shown in Table 1.
[0042] Table 1 Initial annotation results
[0043]
[0044] In at least one embodiment of this application, the electronic device obtains the initial labeled image and the initial labeled image's initial labeling result from databases such as KITTI, Mapillary, CityScapes, and DaimlerUrban.
[0045] like Figure 2 The image shown is the initial labeled image obtained from the aforementioned databases in this application. Figure 2 It includes multiple initial categories such as buildings, buses, trees, cars, pedestrians, driveways, sidewalks, and utility poles, but only some of the initial categories are listed, and the initial color and initial number of each initial category are different.
[0046] To facilitate the presentation of the initial category, initial color, and initial number corresponding to different initial objects (e.g., people, vehicles, roads, etc.), in Figure 2 Multiple dashed boxes are used to illustrate the initial category, initial color, and initial number of each initial object. The text within the dashed boxes is only an illustrative description of each initial object in the image. In actual applications, the initial labeled image does not include the dashed boxes.
[0047] In at least one embodiment of this application, the image to be identified contains multiple objects to be identified, and the image to be identified refers to an image in which the category, color, and other information of each object to be identified are not labeled.
[0048] In at least one embodiment of this application, the electronic device acquires images captured by a dashcam or an in-vehicle camera to obtain the image to be identified.
[0049] S11, construct the first semantic segmentation network.
[0050] In at least one embodiment of this application, the first semantic segmentation network refers to a network that re-annotates the initially labeled image.
[0051] In at least one embodiment of this application, the first semantic segmentation network includes an autoencoder and a classifier. The autoencoder includes multiple cascaded structures and a decoder; each cascaded structure includes multiple hidden layers and pooling layers; the decoder includes multiple serial structures; each serial structure includes an unpooling layer and multiple computational layers; and the electronic device constructs the first semantic segmentation network by:
[0052] The electronic device constructs a cascaded structure of multiple hidden layers and pooling layers, and uses the multiple cascaded structures as encoders. The electronic device constructs a serial structure of an unpooling layer and multiple operational layers, uses the multiple serial structures as decoders, and constructs a classifier. Furthermore, the electronic device generates a learner based on the encoder, the decoder, and the classifier. Furthermore, the electronic device acquires training images and trains the learner based on the training images, calculates the loss value of the learner, and continues until the loss value is less than a preset value, thereby obtaining the first semantic segmentation network.
[0053] Each hidden layer includes multiple convolutional layers, batch standard layers, and activation function layers. The pooling layer is a max pooling layer. Each operational layer includes multiple deconvolutional layers, the batch standard layers, and the activation function layers. The activation function layers can be ReLU linear rectified functions.
[0054] The encoder refers to a network that extracts features from the initial labeled image, and the decoder refers to a network that restores the features extracted by the encoder. The encoder and the decoder have a symmetrical structure, and the decoding process is the inverse process of the encoding process.
[0055] In other embodiments of this application, the first semantic segmentation network may also be a network such as U-Net, DeepLabv1, DeepLabv2, and MaskR-CNN, and this application does not limit it.
[0056] S12, compare the initial annotation result with the preset annotation result to obtain the comparison result.
[0057] In at least one embodiment of this application, the preset labeling result refers to the correspondence between each preset category, each preset color label, and each preset value.
[0058] In at least one embodiment of this application, the comparison result includes: the initial annotation result is the same as the preset annotation result, or the initial annotation result is different from the preset annotation result.
[0059] In at least one embodiment of this application, before comparing the initial annotation result with the preset annotation result, the method further includes:
[0060] The electronic device acquires multiple preset color labels, multiple preset values, and multiple preset categories. Further, the electronic device establishes a correspondence between each preset value and each color label to obtain multiple target labels. Even further, the electronic device establishes a correspondence between each preset category and each target label to obtain the preset labeling result.
[0061] The multiple color labels include red, green, blue, gray, etc., and the multiple preset values can be 1, 2, 3, 4, etc.
[0062] The preset categories can be: lanes, lane lines, intersections, zebra crossings, curbs, trees, sidewalks, cars, bicycles, motorcycles, pedestrians, strollers, large vehicles, trucks, traffic lights, traffic signals, road signs, buildings, streetlights, utility poles, static obstacles, and dynamic obstacles, etc. It is understood that the preset categories should, as far as possible, encompass the category of every target object appearing on the road.
[0063] For example, the target objects are: people, vehicles, trees, road facilities, roads, lane lines, and obstacles. The initial categories corresponding to each target object are: pedestrians, cars, trucks, vans, trees, utility poles, roads, lane lines, dynamic obstacles, and static obstacles, etc.
[0064] For example, the preset annotation results can be shown in Table 2:
[0065] Table 2 Preset Labeling Results
[0066]
[0067] In at least one embodiment of this application, the initial annotation result includes multiple initial categories and an initial label corresponding to each initial category, and the comparison of the initial annotation result with a preset annotation result to obtain a comparison result includes:
[0068] The electronic device acquires each initial object in the initial labeled image and determines the initial category corresponding to each initial object. If any initial category does not have a corresponding preset category, the electronic device determines that the comparison result is that the initial labeling result is different from the preset labeling result. Alternatively, if each initial category has a corresponding preset category and the initial label corresponding to each initial category is different from the target label of the corresponding preset category, the electronic device determines that the comparison result is that the initial labeling result is different from the preset labeling result.
[0069] In this embodiment, when any initial category does not have a corresponding preset category, the following situations apply: the initial object corresponding to any initial category is the same as the target object corresponding to the plurality of preset categories, or the initial object corresponding to any initial category is different from the target object corresponding to the plurality of preset categories.
[0070] Furthermore, when the initial object corresponding to any initial category is the same as the target object corresponding to the plurality of preset categories, there are several situations. For example, the initial category and the preset category have different names, so that the initial category does not have a corresponding preset category; or, the preset category is too low-level, so that the initial category does not have a corresponding preset category; or, the preset category is too high-level, so that the initial category does not have a corresponding preset category.
[0071] The difference between the initial label corresponding to each initial category and the target label of the corresponding preset category means that the correspondence between the initial color label and the initial value is inconsistent with the correspondence between the preset value and the color label.
[0072] In this embodiment, if each initial category has a corresponding preset category, and the initial label corresponding to each initial category is the same as the target label of the corresponding preset category, the electronic device determines that the comparison result is the same as the initial labeling result and the preset labeling result.
[0073] Through the above implementation method, it is possible to determine whether the initial annotation result of any initial annotation image is the same as the preset annotation result. When the initial annotation result of the initial annotation image is the same as the preset annotation result, there is no need to re-annotate the initial annotation image, which can improve annotation efficiency.
[0074] Following the above embodiments, comparing Table 1 and Table 2, it can be seen that the roads, double yellow lines, and white lines in the initial labeling results of Table 1 do not have corresponding preset categories in Table 2. After comparison, the preset category of roads in the preset labeling results is road, and the preset category of double yellow lines and white lines in the preset labeling results is lane lines. Therefore, the initial labeling results of Table 1 and the preset labeling results of Table 2 are different.
[0075] S13, if the comparison result is that the initial annotation result is different from the preset annotation result, then the initial annotation image is input into the first semantic segmentation network to obtain the target image corresponding to the initial annotation image and the target annotation result of the target image.
[0076] In at least one embodiment of this application, the target image refers to an image generated after the initial labeled image is re-labeled according to the first semantic segmentation network.
[0077] In at least one embodiment of this application, the electronic device inputs the initial labeled image into the first semantic segmentation network to obtain a target image corresponding to the initial labeled image and the target labeling result of the target image, including:
[0078] The electronic device processes the initial labeled image using the autoencoder to generate a target feature map. Further, the electronic device classifies each pixel in the target feature map based on the classifier to obtain the label category corresponding to each pixel. Even further, the electronic device labels the target feature map based on the label category corresponding to each pixel and the target label corresponding to the label category to generate the target image and the target labeling result.
[0079] Through the above implementation method, the initial labeled image is compressed and decompressed based on the autoencoder to obtain the target feature map. Since the image noise of the initial labeled image is filtered during the compression process, the generated target feature map can be clearer. Multiple initial labeled images corresponding to initial labeled results that are different from the preset labeled results are re-labeled using the preset labeled results to obtain multiple target images, which can ensure that the labeling results of the multiple target images for the same object are consistent.
[0080] Specifically, the electronic device processes the initial labeled image using the autoencoder to generate a target feature map, including:
[0081] The electronic device extracts features from the initial labeled image based on multiple hidden layers in any cascaded structure to obtain an initial feature map output by the last hidden layer. Further, the electronic device performs pooling operations on the initial feature map based on the pooling layer of the cascaded structure to output a first feature map. Even further, the electronic device inputs the first feature map output by the current cascaded structure into the next cascaded structure until the first feature map output by the last cascaded structure is obtained as a second feature map. The electronic device obtains the pixel value of each pixel in the multiple first feature maps at the first pixel position in the corresponding initial feature map, and obtains the pixel value of each pixel in the second feature map at the second pixel position in the corresponding initial feature map. Further, the electronic device performs decoding operations on the second feature map based on the decoder, the first pixel position, and the second pixel position to obtain the target feature map.
[0082] Specifically, the electronic device performs a decoding operation on the second feature map based on the decoder, the first pixel position, and the second pixel position to obtain the target feature map, including:
[0083] The electronic device constructs a zero-based feature map of corresponding size based on the size of the initial feature map output by each cascaded structure, and fills each pixel value in the second feature map into the corresponding zero-based feature map according to the second pixel position, thereby obtaining the third feature map output by the depooling layer in the first cascaded structure. Further, the electronic device performs a deconvolution operation on the third feature map based on multiple operational layers in the first cascaded structure to obtain the fourth feature map output by the first cascaded structure. Further still, the electronic device inputs the fourth feature map into the next cascaded structure, and generates the fifth feature map of the next cascaded structure based on the fourth feature map, the corresponding first pixel position, and multiple operational layers in the next cascaded structure. The electronic device obtains the fifth feature map output by the last cascaded structure as the target feature map.
[0084] In this embodiment, the second feature map is decoded based on the first pixel position and the second pixel position to obtain the target feature map. Since more pixel position information is retained, the features contained in the target feature map are more complete.
[0085] Specifically, the electronic device classifies each pixel in the target feature map based on the classifier, obtaining the labeled category corresponding to each pixel, including:
[0086] The electronic device calculates a single score value for each pixel in the target feature map based on the pixel value of each pixel in the target feature map. Further, the electronic device calculates the category probability of the pixel corresponding to the single score value belonging to each preset category based on the single score value and the multiple preset categories. Furthermore, the electronic device determines the preset category corresponding to the category with the highest category probability value as the labeled category corresponding to the pixel.
[0087] In this embodiment, the preset category corresponding to the category with the highest value is determined as the label category corresponding to the pixel, which can improve the accuracy of classification of each pixel.
[0088] Specifically, the formula for calculating the category probability is:
[0089]
[0090] Among them, S i This represents the probability that each pixel belongs to the i-th preset category. z represents the single score value of the j-th pixel in the target feature map. j This represents the pixel value of the j-th pixel in the target feature map. The total score value of all pixels in the target feature map is represented by , i represents the i-th preset category, and k represents the number of preset categories.
[0091] Specifically, the electronic device uses the pixel value of each pixel as the logarithm of the exp exponential function to obtain a single score value for each pixel, where the exp exponential function is an exponential function with base e.
[0092] Specifically, the electronic device annotates the target feature map based on the annotation category corresponding to each pixel and the target label corresponding to the annotation category, generating the target image and the target annotation result, including:
[0093] The electronic device determines the region formed by all pixels corresponding to the same label category in the target feature map as a feature region. Further, the electronic device adjusts the pixel values of all pixels in the feature region to preset values corresponding to the same label category. Further still, the electronic device colors each pixel in the feature region according to the color label corresponding to the preset value of the feature region to obtain a target region. Further still, the electronic device splices the multiple target regions according to their regional positions in the target feature map to obtain the target image. Further still, the electronic device determines the preset value, color label, and label category corresponding to each target region in the target image as the target labeling result.
[0094] In this embodiment, the pixel value of each pixel in the feature region can be quickly adjusted based on the preset annotation results, making each region in the target image more prominent.
[0095] Following the examples above, the target annotation results for any of the initial annotated images are shown in Table 3:
[0096] Table 3 Target Labeling Results
[0097]
[0098]
[0099] S14, the first semantic segmentation network is trained based on multiple target images and the target annotation results of each target image to obtain the second semantic segmentation network.
[0100] In at least one embodiment of this application, the second semantic segmentation network refers to a network generated after training the first semantic segmentation network using the multiple target images and the target annotation results of each target image.
[0101] In at least one embodiment of this application, the generation process of the second semantic segmentation network is basically the same as the generation process of the first semantic segmentation network, and this application will not elaborate on this.
[0102] Through the above implementation method, the first semantic segmentation network is trained using the multiple target images and the target annotation results corresponding to each target image to obtain the second semantic segmentation image. By increasing the number of training images, the second semantic segmentation network has higher recognition accuracy. Since the annotation results of the multiple target images for the same object are consistent, the second semantic segmentation network can automatically perform unified annotation on the multiple images to be recognized.
[0103] S15, the image to be identified is input into the second semantic segmentation network to obtain the image annotation result of the image to be identified.
[0104] In at least one embodiment of this application, the image annotation result includes the category of each object to be identified, the number of each object to be identified, and the color label of each object to be identified.
[0105] In at least one embodiment of this application, the process of generating the image annotation result is substantially the same as the process of generating the target annotation result, and this application does not impose any limitations on this.
[0106] In this embodiment, since the image to be identified is an image captured by a dashcam or an in-vehicle camera, the second semantic segmentation network can accurately identify each object in the image to be identified and obtain the image annotation results. During driving, the driver can obtain accurate road condition information based on multiple image annotation results, thereby improving driving safety.
[0107] As can be seen from the above technical solutions, since the initial labeled images in this application come from different datasets, the initial labeling results for the same target object are different between any two initial labeled images from different datasets (i.e., the labeling methods for the same target object in any two initial labeled images are different). The initial labeled images are re-labeled by the first semantic segmentation network. Since the first semantic segmentation network is trained based on the images with the preset labeling results, it can make the target images generated by the first semantic segmentation network have the same target labeling results for the same target object (i.e., the labeling methods for the same target object in the target images are unified). Then, the first semantic segmentation network is trained based on the multiple target images and the target labeling results of each target image to obtain the second semantic segmentation network. Since the training data of the first semantic segmentation network is increased and the labeling methods of the training images are unified, the generated second semantic segmentation network has better generalization ability, thereby improving the accuracy of the image labeling results.
[0108] like Figure 3 The diagram shown is a schematic representation of the structure of an electronic device that implements the image recognition method of this application.
[0109] In one embodiment of this application, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program, such as an image recognition program, stored in the memory 12 and executable on the processor 13.
[0110] Those skilled in the art will understand that the schematic diagram is merely an example of electronic device 1 and does not constitute a limitation on electronic device 1. It may include more or fewer components than shown in the diagram, or combine certain components, or different components. For example, electronic device 1 may also include input / output devices, network access devices, buses, etc.
[0111] The processor 13 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor, or any conventional processor. The processor 13 is the computing core and control center of the electronic device 1, connecting various parts of the electronic device 1 through various interfaces and lines, and obtaining the operating system and installed applications and program code of the electronic device 1.
[0112] The processor 13 acquires the operating system and various installed applications of the electronic device 1. The processor 13 acquires these applications to implement the steps in the above-described image recognition method embodiments, for example... Figure 1 The steps are shown.
[0113] For example, the computer program may be divided into one or more modules / units, which are stored in the memory 12 and retrieved by the processor 13 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing specific functions, the instruction segments describing the retrieval process of the computer program in the electronic device 1.
[0114] The memory 12 can be used to store the computer programs and / or modules. The processor 13 implements various functions of the electronic device 1 by running or retrieving the computer programs and / or modules stored in the memory 12, and by calling the data stored in the memory 12. The memory 12 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 12 may include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD) card, flash card, at least one disk storage device, flash memory device, or other non-volatile solid-state storage device.
[0115] The memory 12 can be the external memory and / or internal memory of the electronic device 1. Furthermore, the memory 12 can be a physical memory, such as a memory module, a TF card (Trans-flash Card), etc.
[0116] If the modules / units integrated in the electronic device 1 are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when the computer program is acquired by a processor, it can implement the steps of the various method embodiments described above.
[0117] The computer program includes computer program code, which may be in the form of source code, object code, accessible file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, and read-only memory (ROM).
[0118] Combination Figure 1 The memory 12 in the electronic device 1 stores multiple instructions to implement an image recognition method. The processor 13 can acquire the multiple instructions to implement: acquiring an image to be recognized, and acquiring an initial labeled image and an initial labeled result of the initial labeled image; constructing a first semantic segmentation network; comparing the initial labeled result with a preset labeled result to obtain a comparison result; if the comparison result is that the initial labeled result is different from the preset labeled result, then inputting the initial labeled image into the first semantic segmentation network to obtain a target image corresponding to the initial labeled image and a target labeled result of the target image; training the first semantic segmentation network based on multiple target images and the target labeled result of each target image to obtain a second semantic segmentation network; inputting the image to be recognized into the second semantic segmentation network to obtain an image labeled result of the image to be recognized.
[0119] Specifically, the processor 13's implementation method for the above instructions can be found in [reference needed]. Figure 2 The descriptions of the relevant steps in the corresponding embodiments are not repeated here.
[0120] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and other division methods may be used in actual implementation.
[0121] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0122] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in the form of hardware plus software functional modules.
[0123] Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be embraced within this application. No appended diagram markings in the claims should be construed as limiting the scope of the claims.
[0124] Furthermore, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices described in this application may also be implemented by a single unit or device through software or hardware. The terms "first," "second," etc., are used to indicate names and do not indicate any specific order.
[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application and are not intended to limit it. Although this application has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of this application without departing from the spirit and scope of the technical solutions of this application.
Claims
1. An image recognition method characterized by, The image recognition method comprises: acquiring an image to be recognized, and acquiring an initial labeled image and an initial labeling result of the initial labeled image, the initial labeled image being from different data sets, and the initial labeling results of any two initial labeled images from different data sets being different for a same target object; constructing a first semantic segmentation network; acquiring a plurality of preset color labels, a plurality of preset numerical values and a plurality of preset categories, establishing a correspondence between each preset numerical value and each color label to obtain a plurality of target labels, and establishing a correspondence between each preset category and each target label to obtain a preset labeling result; comparing the initial labeling result with the preset labeling result to obtain a comparison result; if the comparison result is that the initial labeling result is different from the preset labeling result, inputting the initial labeled image into the first semantic segmentation network to obtain a target image corresponding to the initial labeled image and a target labeling result of the target image; training the first semantic segmentation network based on a plurality of target images and the target labeling result of each target image to obtain a second semantic segmentation network; inputting the image to be recognized into the second semantic segmentation network to obtain an image labeling result of the image to be recognized.
2. The image recognition method of claim 1, wherein, The initial labeling result comprises a plurality of initial categories and an initial label corresponding to each initial category, and the comparison between the initial labeling result and the preset labeling result to obtain a comparison result comprises: acquiring each initial object in the initial labeled image and determining an initial category corresponding to each initial object; if any initial category does not have a corresponding preset category, determining that the comparison result is that the initial labeling result is different from the preset labeling result; or if each initial category has a corresponding preset category and the initial label corresponding to each initial category is different from the target label of the corresponding preset category, determining that the comparison result is that the initial labeling result is different from the preset labeling result.
3. The image recognition method of claim 1, wherein, The first semantic segmentation network comprises a self-encoder and a classifier, and the inputting of the initial labeled image into the first semantic segmentation network to obtain a target image corresponding to the initial labeled image and a target labeling result of the target image comprises: processing the initial labeled image by using the self-encoder to generate a target feature map; classifying each pixel point in the target feature map based on the classifier to obtain a labeling category corresponding to each pixel point; labeling the target feature map based on the labeling category corresponding to each pixel point and the target label corresponding to the labeling category to generate the target image and the target labeling result.
4. The image recognition method of claim 3, wherein, The self-encoder comprises a plurality of cascaded structures and a decoder, and the processing of the initial labeled image by using the self-encoder to generate a target feature map comprises: performing feature extraction on the initial labeled image based on a plurality of hidden layers in any cascaded structure to obtain an initial feature map output by a last hidden layer; performing a pooling operation on the initial feature map based on a pooling layer of the any cascaded structure to output a first feature map; The first feature map output by the current cascade structure is input into the next cascade structure until the first feature map output by the last cascade structure is obtained as the second feature map; A first pixel position of a pixel value of each pixel point in the plurality of first feature maps in the corresponding initial feature map is obtained, and a second pixel position of a pixel value of each pixel point in the second feature map in the corresponding initial feature map is obtained; The second feature map is subjected to a decoding operation based on the decoder, the first pixel position and the second pixel position, to obtain the target feature map.
5. The image recognition method according to claim 3 or 4, characterized in that, The classification of each pixel point in the target feature map based on the classifier includes: A single score value of each pixel point in the target feature map is calculated based on the pixel value of each pixel point in the target feature map; A class probability of the pixel point belonging to each preset category corresponding to the single score value is calculated based on the single score value and the plurality of preset categories; The preset category corresponding to the class probability with the maximum value is determined as the labeled category corresponding to the pixel point.
6. The image recognition method of claim 5, wherein, The calculation formula of the class probability is: wherein, denotes a class probability of each pixel point belonging to the i-th preset class, denotes a single score value of the j-th pixel point in the target feature map, denotes a pixel value of the j-th pixel point in the target feature map, denotes a total score value of all pixel points in the target feature map, denotes the i-th preset class, denotes the i-th preset class, denotes a number of the plurality of preset classes.
7. The image recognition method of claim 4, wherein, The target feature map is labeled based on the labeled category corresponding to each pixel point and the target label corresponding to the labeled category, to generate the target image and the target labeling result, including: An area formed by all pixel points corresponding to the same labeled category in the target feature map is determined as a feature area; Pixel values of all pixel points in the feature area are adjusted to preset values corresponding to the same labeled category; Each pixel point in the feature area is subjected to coloring processing according to a color label corresponding to the preset value of the feature area, to obtain a target area; The plurality of target areas are spliced according to the area positions of the plurality of target areas in the target feature map, to obtain the target image; The preset value, color label and labeled category corresponding to each target area in the target image are determined as the target labeling result.
8. An electronic device, comprising: The electronic device includes a processor and a memory, and the processor is configured to execute a computer program stored in the memory to implement the image recognition method of any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores at least one instruction, and the at least one instruction is executed by the processor to implement the image recognition method of any one of claims 1 to 7.
Citation Information
Patent Citations
Neural network training method and device and image semantic segmentation method and device
CN111489366A
Picture training set screening method, device and equipment, and readable storage medium
CN112598007A
System and method for analysis of microscopic image data and for generating an annotated data set for classifier training
US20210166076A1