Image recognition method and device
By performing data enhancement processing on the initial image, generating training images and training the initial information recognition model, the problem of low training efficiency of a small number of training images is solved, and the recognition efficiency and accuracy of the model are improved.
Patent Information
- Application Number
- CN202110326234.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-26
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-03-26
AI Technical Summary
In the existing technology, when training an initial information recognition model based on a small number of training images, the training efficiency is low and the model accuracy is low.
By performing data enhancement processing on the initial image, training images are generated, and these training images are used to train the initial information recognition model, including data enhancement methods such as brightness adjustment, background replacement, and image splicing, to improve the recognition ability of the model.
It achieves efficient and rapid training of a target information recognition model with a small number of training images, improving the recognition efficiency and accuracy of the model.
Smart Images

Figure CN113076983B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image recognition, and in particular to an image recognition method and device. Background Art
[0002] The maintenance and inspection of rail transit vehicles is a very important task in daily operation. With the development of artificial intelligence technology, some semi-automatic or fully automatic fault identification algorithms have emerged. Before the maintenance workers check, the algorithm can know which locations may have faults, which can effectively assist and speed up the maintenance workers' work efficiency. In the related technology, the target detection and recognition method based on deep learning only requires the labeled data to be used for offline training of model files. When using it, input the picture, call the model file for reasoning, and get the detection result in one step. However, this also puts forward certain requirements on the quality and quantity of training data. When the quantity and quality of training data are poor, the training effect is not good and the accuracy of the model is low.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The present application provides an image recognition method and device to at least solve the technical problem in the related art that the training efficiency is low when an initial information recognition model is trained based on a small number of training images.
[0005] According to one aspect of an embodiment of the present application, there is provided an image recognition method, comprising: acquiring an image to be tested of a rail transit vehicle; performing target recognition on the image to be tested based on a target information recognition model to obtain target information of a target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, the training image is obtained by performing data enhancement processing on the initial image, and the initial image is an image with label information of a target area annotated.
[0006] Optionally, before performing the target recognition based on that the target information recognition model is larger than the image to be tested, the method further includes: acquiring a first image to be processed and a predetermined number of second images from a plurality of initial images included in an image training set, wherein the first image has different attribute information from the second image; performing the data enhancement processing on the first image and the second image to obtain the training image; and training the initial information recognition model based on the training image to obtain the target information recognition model.
[0007] Optionally, performing the data enhancement processing on the first image and the second image to obtain the training image includes: adjusting the brightness of the first image and the second image to obtain an adjusted third image; replacing the background of the third image to obtain a fourth image; performing image stitching on the fourth image according to a target position relationship to obtain a fifth image; and determining the fifth image as the training image.
[0008] Optionally, performing brightness adjustment on the first image and the second image to obtain the adjusted third image includes: obtaining a reference brightness value of the image training set; determining initial image brightness values of the first image and the second image; comparing the initial image brightness values with the reference brightness values; when the initial image brightness value is less than the reference brightness value, adjusting the initial image brightness value of the corresponding image upward to a first brightness value to obtain the third image, wherein the first brightness value is within a set threshold range; when the initial image brightness value is greater than the reference brightness value, adjusting the initial image brightness value of the corresponding image downward to a second brightness value to obtain the third image, wherein the second brightness value is within the set threshold range.
[0009] Optionally, obtaining the reference brightness value of the image training set includes: determining an initial brightness ratio of each initial image contained in the image training set, wherein the initial brightness ratio is a ratio of the brightness of each initial image to the number of pixels in the initial image; screening out a target brightness ratio greater than a set threshold from multiple initial brightness ratios; and determining an average value of the target brightness ratios as the reference brightness value of the image training set.
[0010] Optionally, performing background replacement on the third image to obtain the fourth image includes: obtaining the label information of the target area in the third image; when the label information is the first label information, performing background replacement on the target area based on a preset probability to obtain a sixth image, wherein the background replacement is to replace an image of any area in the background image with an image of the target area, the background image is an image selected from the image training set, and the attribute information of the background image is different from that of the first image; performing target processing on the sixth image to obtain the fourth image, wherein the target processing includes flipping, rotating, adding noise, and mirroring.
[0011] Optionally, after acquiring the label information of the target area in the third image, the method further includes: when the label information is second label information, performing the target processing on the third image to obtain the fourth image.
[0012] According to another aspect of an embodiment of the present application, there is also provided an image recognition device, comprising: a first acquisition module, for acquiring an image to be tested of a rail transit vehicle; and a recognition module, for performing target recognition on the image to be tested based on a target information recognition model to obtain target information of the target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of the target area annotated.
[0013] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above method is executed when the program is run.
[0014] According to another aspect of an embodiment of the present application, an electronic device is further provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above method through the computer program.
[0015] In an embodiment of the present application, a test image of a rail transit vehicle is acquired; target recognition is performed on the test image based on a target information recognition model to obtain target information of the target object contained in the test image, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of the target area annotated. The training image is obtained by performing data enhancement processing on the initial image with label information of the target area on the image, and the initial information recognition model is trained using the training image. The trained target information recognition model can efficiently and quickly identify the target information contained in the test image of the rail transit vehicle. Compared with the related art in which a target information recognition model is obtained by preparing a large number of high-quality training images in advance to train the initial information recognition model, the embodiment of the present invention can achieve the purpose of efficiently and quickly training the initial information recognition model by preparing a small number of training images, thereby achieving the technical effect of improving the training efficiency when training the initial information recognition model based on a small number of training images, and then solving the technical problem of low training efficiency when training the initial information recognition model based on a small number of training images. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0018] Figure 1 is a schematic diagram of a hardware environment of an image recognition method according to an embodiment of the present application;
[0019] Figure 2 is a flowchart of an optional image recognition method according to an embodiment of the present application;
[0020] Figure 3 is an optional brightness adjustment flow chart according to an embodiment of the present application;
[0021] Figure 4 is an optional background replacement flow chart according to an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of an optional image recognition device according to an embodiment of the present application;
[0023] Figure 6 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0026] According to one aspect of the embodiments of the present application, a method embodiment of image recognition is provided.
[0027] Optionally, in this embodiment, the above image recognition method can be applied to Figure 1 The hardware environment shown is composed of a terminal 101 and a server 103. Figure 1 is a schematic diagram of the hardware environment of the image recognition method according to an embodiment of the present application, such as Figure 1 As shown, the server 103 is connected to the terminal 101 through a network, and can be used to provide services (such as data processing services, etc.) to the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 103. The above network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 101 is not limited to a PC, a mobile phone, a tablet computer, etc. The image recognition method of the embodiment of the present application can be executed by the server 103, or by the terminal 101, or by the server 103 and the terminal 101. Among them, the terminal 101 executes the image recognition method of the embodiment of the present application, and it can also be executed by the client installed thereon.
[0028] Figure 2 is a flow chart of an optional image recognition method according to an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps:
[0029] Step S202, obtaining an image of a rail transit vehicle to be tested;
[0030] Step S204, performing target recognition on the image to be tested based on a target information recognition model to obtain target information of the target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of the target area annotated.
[0031] Through the above steps S202 to S204, data enhancement processing is performed on the initial image with the label information of the target area on the image to obtain a training image, and the training image is used to train the initial information recognition model. The trained target information recognition model can efficiently and quickly identify the target confidence contained in the image to be tested of the rail transit vehicle. Compared with the related technology of obtaining the target information recognition model by preparing a large number of high-quality training images in advance to train the initial information recognition model, the embodiment of the present invention can achieve the purpose of efficiently and quickly training the initial information recognition model by preparing a small number of training images, thereby achieving the technical effect of improving the training efficiency of the initial model based on a small number of training images, and then solving the technical problem of low training efficiency of the initial model based on a small number of training images.
[0032] In the technical solution provided in step S202, the method for obtaining the image to be tested may be to photograph the rail transit vehicle using a camera installed in a fixed position, or to capture the image from a captured video, which is not limited in this solution.
[0033] In the technical solution provided in step S204, the initial information recognition model may include, but is not limited to, a constructed neural network model.
[0034] Optionally, in this embodiment, the target object contained in the image to be measured may be a component on a rail transit vehicle, such as an axle, a bolt, a nut, and the like.
[0035] Optionally, in this embodiment, the target information may be, but is not limited to, position information of the target object in the image to be tested, attribute information of the target object, a fault cause of the target object, and the like.
[0036] Optionally, in this embodiment, the label information of the target area may be, but is not limited to, the location information of the parts contained in the initial image of the training model to be used (such as the four coordinate points of the box where the selected parts are located), the additional attribute information of the parts in the target area, and the like.
[0037] Optionally, in this embodiment, the data enhancement processing may include but is not limited to brightness adjustment, background replacement, image stitching, image translation, image flipping, image rotation, etc.
[0038] As an optional embodiment, before performing the target recognition based on that the target information recognition model is larger than the image to be tested, the method further includes:
[0039] S11, acquiring a first image to be processed and a predetermined number of second images from a plurality of initial images included in an image training set, wherein attribute information of the first image is different from that of the second image;
[0040] S12, performing the data enhancement process on the first image and the second image to obtain the training image;
[0041] S13, training the initial information recognition model based on the training image to obtain the target information recognition model.
[0042] Optionally, in this embodiment, the image training set contains multiple initial images. When performing data enhancement processing, the initial images in the image training set are extracted in sequence for data enhancement processing. The first image can be the initial image in the training set to be subjected to data enhancement processing.
[0043] Optionally, in this embodiment, the number of the second images may include, but is not limited to, 1, 2, 3, etc.
[0044] As an optional embodiment, performing the data enhancement process on the first image and the second image to obtain the training image includes:
[0045] S21, performing brightness adjustment on the first image and the second image to obtain an adjusted third image;
[0046] S22, performing background replacement on the third image to obtain a fourth image;
[0047] S23, performing image stitching on the fourth image according to the target position relationship to obtain a fifth image;
[0048] S24: Determine the fifth image as the training image.
[0049] Optionally, in this embodiment, the brightness adjustment may be, but is not limited to, adjusting the brightness of a certain area in the first image and the second image, or adjusting the brightness of the entire area of the first image and the second image, which is not limited in this solution.
[0050] Optionally, in this embodiment, the background replacement method may be, but is not limited to, replacing a corresponding area in the second image with a target area in the first image, and may also be replacing a specified area in a background image with a target area in the first image and the second image, which is not limited in this solution.
[0051] Optionally, in this example, the target position relationship may include, but is not limited to, randomly splicing all images horizontally, randomly splicing all images vertically, randomly splicing all images in a square pattern, etc., and this solution does not limit this.
[0052] As an optional embodiment, performing brightness adjustment on the first image and the second image to obtain the adjusted third image includes:
[0053] S31, obtaining a reference brightness value of the image training set;
[0054] S32, determining initial image brightness values of the first image and the second image;
[0055] S33, comparing the initial image brightness value and the reference brightness value;
[0056] S34, when the brightness value of the initial image is less than the reference brightness value, adjusting the brightness value of the initial image of the corresponding image upward to a first brightness value to obtain the third image, wherein the first brightness value is within a set threshold range;
[0057] S35, when the brightness value of the initial image is greater than the reference brightness value, adjusting the brightness value of the initial image of the corresponding image downward to a second brightness value to obtain the third image, wherein the second brightness value is within the set threshold range.
[0058] Optionally, in this embodiment, the method for obtaining the brightness reference value may be a brightness reference value sent by other devices, or may be calculated according to brightness parameters of images in an image training set.
[0059] Optionally, in this embodiment, the method of adjusting the initial image brightness value upward to the first brightness value may include, but is not limited to, randomly adding a certain value to the brightness value of the image on the basis of the initial image brightness value, so that the brightness value of the image is the first brightness value, such as adding 5, 10, 14, etc. to the initial brightness value.
[0060] Optionally, in this embodiment, the method of adjusting the brightness value of the initial image downward to the second brightness value may include, but is not limited to, randomly reducing the brightness value of the image by a certain value based on the brightness value of the initial image, so that the brightness value of the image is the second brightness value, such as reducing the brightness value by 5, 10, 14, etc. based on the initial brightness value.
[0061] Through the above steps, by comparing the initial brightness value of the image with the reference brightness value of the image training set, the method for adjusting the brightness of the image is determined, thereby ensuring the accuracy of the brightness adjustment.
[0062] As an optional embodiment, obtaining the reference brightness value of the image training set includes:
[0063] S41, determining an initial brightness ratio of each initial image included in the image training set, wherein the initial brightness ratio is a ratio of the brightness of each initial image to the number of pixels in the initial image;
[0064] S42, selecting a target brightness ratio greater than a set threshold from the plurality of initial brightness ratios;
[0065] S43, determining an average value of the target brightness ratio as the reference brightness value of the image training set.
[0066] Optionally, in this embodiment, the set threshold may be a pre-set value. When the value is greater than the pre-set value, it can be considered that the brightness quality of the image is good. The set threshold may include but is not limited to 0.5, 0.6, 0.61, etc.
[0067] Through the above steps, by calculating the initial brightness ratio of the initial image in the training set image, and screening out the target measurement ratio greater than a certain set threshold, and taking the average value of the target brightness ratio as the reference brightness value, the authenticity and reliability of the determined reference brightness value are improved.
[0068] As an optional embodiment, performing background replacement on the third image to obtain the fourth image includes:
[0069] S51, acquiring the label information of the target area in the third image;
[0070] S52, when the label information is the first label information, performing the background replacement on the target area based on a preset probability to obtain a sixth image, wherein the background replacement is to replace an image of any area in a background image with an image of the target area, the background image is an image selected from the image training set, and the attribute information of the background image is different from that of the first image;
[0071] S53, performing target processing on the sixth image to obtain the fourth image, wherein the target processing includes flipping, rotating, adding noise, and mirroring.
[0072] Optionally, in this embodiment, the first label information may include, but is not limited to, that the image of the target area is an image of a faulty part.
[0073] Optionally, in this embodiment, the preset probability is the probability of performing background replacement on the image, and the preset probability may include but is not limited to 50%, 60%, 70% and the like.
[0074] Optionally, in this embodiment, the background is replaced by an image of any area in the background image and replaced by an image of the target area. For example, the size of the image to be cut is (w, h), and the size of the background image is (w0, h0). First, select the coordinates of the point in the upper left corner of the background image (x1, y1), where x1 can be a randomly selected value from 0 to (w0-w-10) (minus 10 is to have a margin), and y1 can be a randomly selected value from 0 to (h0-h-10) (minus 10 is to have a margin). After selecting x1 and y1, the coordinates of the lower right corner point of the cutout area (x2, y2) can be determined, where x2 can be x1+w, and y2 can be y1+h. Finally, cut the image. Assuming the original image is img, new_img=img[y1:y2,x1:x2].
[0075] As an optional embodiment, after acquiring the label information of the target area in the third image, the method further includes:
[0076] S61, when the label information is the second label information, performing the target processing on the third image to obtain the fourth image.
[0077] Optionally, in this embodiment, the second label information may include, but is not limited to, that the image of the target area is an image of a non-faulty part.
[0078] Optionally, in this embodiment, the target processing may include, but is not limited to, image flipping, image rotation, adding noise, mirroring, and the like.
[0079] Figure 3 is an optional brightness adjustment flow chart according to an embodiment of the present application, such as Figure 3 As shown:
[0080] S301, obtaining initial brightness ratios of all images in a training set, where the initial brightness ratio is a ratio of the brightness of an image to the total number of pixels in the image;
[0081] S302, clustering the images in the training set according to the initial brightness ratios, where different clusters correspond to different ratio intervals.
[0082] S303, selecting a cluster whose ratio interval is greater than a certain set threshold, and when the ratio interval is greater than the set threshold, determining that the imaging quality of the cluster meets the use requirement.
[0083] S304, calculating the average value of the initial brightness ratio of each cluster brightness after filtering, then taking the average value of the initial brightness ratio of all filtered clusters, and determining the average value as the brightness reference value for the new leveling.
[0084] S305: Input the picture to be processed.
[0085] S306, calculating the brightness value of the image.
[0086] S307, determining whether the initial brightness value of the image is greater than the brightness reference value.
[0087] S308, when the initial brightness value of the image is greater than the brightness reference value, a setting parameter (a value between 0 and the difference between the initial brightness value and the measurement reference value) is subtracted from the initial brightness value to obtain an adjusted target brightness value.
[0088] S309, when the initial brightness value of the image is less than the brightness reference value, add a setting parameter (a value between 0 and the difference between the initial brightness value and the measurement reference value) to the initial brightness value, thereby obtaining an adjusted target brightness value.
[0089] Figure 4 is an optional background replacement flow chart according to an embodiment of the present application, such as Figure 4 As shown:
[0090] S401, randomly extracting a picture from the training set that does not contain the target area marked in the input picture, and saving the picture as the background picture;
[0091] S402, input the target image for background replacement.
[0092] S403, traverse all the marked areas in the image, and parse the marked information of the marked areas.
[0093] S404, detecting the labeling information of the analyzed target area, and detecting whether there is a target fault in the target image.
[0094] S405, when it is detected that there is a target fault in the target image, a picture block with the same size as the target area is randomly deducted from the background image, and the target area image is used to replace the position of the picture block, and step S406 is executed.
[0095] S406, when it is detected that there is no target fault in the target image, flip, rotate, add noise, and mirror the image.
[0096] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for an electronic device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0098] According to another aspect of the embodiments of the present application, an image recognition device for implementing the above-mentioned image recognition method is also provided. Figure 5 is a schematic diagram of an optional image recognition device according to an embodiment of the present application, such as Figure 5 As shown, the device may include:
[0099] A first acquisition module 52 is used to acquire an image of a rail transit vehicle to be tested;
[0100] The recognition module 54 is used to perform target recognition on the image to be tested based on a target information recognition model to obtain target information of the target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, and the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of the target area annotated.
[0101] It should be noted that the first acquisition module 52 in this embodiment can be used to execute step S202 in the embodiment of the present application, and the identification module 54 in this embodiment can be used to execute step S204 in the embodiment of the present application.
[0102] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware.
[0103] Through the above modules, the technical problem of low training efficiency when training the initial information recognition model based on a small number of training images can be solved, thereby achieving the technical effect of improving the training efficiency when training the initial information recognition model based on a small number of training images.
[0104] Optionally, the device also includes: a second acquisition module, used to acquire a first image to be processed and a predetermined number of second images from multiple initial images included in an image training set before performing the target recognition based on the target information recognition model being larger than the image to be tested, wherein the first image has different attribute information from the second image; a first processing module, used to perform the data enhancement processing on the first image and the second image to obtain the training image; and a training module, used to train the initial information recognition model based on the training image to obtain the target information recognition model.
[0105] Optionally, the first processing module includes: an adjustment unit, used to adjust the brightness of the first image and the second image to obtain an adjusted third image; a replacement unit, used to replace the background of the third image to obtain a fourth image; a stitching unit, used to stitch the fourth image according to a target position relationship to obtain a fifth image; and a determination unit, used to determine the fifth image as the training image.
[0106] Optionally, the adjustment unit is used to: obtain a reference brightness value of the image training set; determine initial image brightness values of the first image and the second image; compare the initial image brightness values and the reference brightness values; when the initial image brightness value is less than the reference brightness value, adjust the initial image brightness value of the corresponding image upward to a first brightness value to obtain the third image, wherein the first brightness value is within a set threshold range; when the initial image brightness value is greater than the reference brightness value, adjust the initial image brightness value of the corresponding image downward to a second brightness value to obtain the third image, wherein the second brightness value is within the set threshold range.
[0107] Optionally, the adjustment unit is used to: determine an initial brightness ratio of each initial image contained in the image training set, wherein the initial brightness ratio is the ratio of the brightness of each initial image to the number of pixels in the initial image; screen out a target brightness ratio greater than a set threshold from the multiple initial brightness ratios; and determine an average value of the target brightness ratios as the reference brightness value of the image training set.
[0108] Optionally, the replacement unit is used to: obtain the label information of the target area in the third image; when the label information is the first label information, perform the background replacement on the target area based on a preset probability to obtain a sixth image, wherein the background replacement is to replace the image of any area in the background image with the image of the target area, the background image is an image selected from the image training set, and the attribute information of the background image is different from that of the first image; perform target processing on the sixth image to obtain the fourth image, wherein the target processing includes flipping, rotating, adding noise, and mirroring.
[0109] Optionally, the device further includes: a second processing module, configured to, after acquiring the label information of the target area in the third image, perform the target processing on the third image when the label information is the second label information, so as to obtain the fourth image.
[0110] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.
[0111] According to another aspect of an embodiment of the present application, an electronic device for implementing the above-mentioned image recognition method is also provided.
[0112] Figure 6 is a structural block diagram of an electronic device according to an embodiment of the present application, such as Figure 6 As shown, the electronic device may include: one or more (only one is shown in the figure) processors 601, a memory 603, and a transmission device 605, such as Figure 6 As shown, the electronic device may further include an input / output device 607 .
[0113] Among them, the memory 603 can be used to store software programs and modules, such as program instructions / modules corresponding to the image recognition method and device in the embodiment of the present application. The processor 601 executes various functional applications and data processing by running the software programs and modules stored in the memory 603, that is, realizing the above-mentioned image recognition method. The memory 603 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 603 may further include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0114] The above-mentioned transmission device 605 is used to receive or send data via a network, and can also be used for data transmission between a processor and a memory. Specific examples of the above-mentioned network may include a wired network and a wireless network. In one example, the transmission device 605 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 605 is a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.
[0115] Specifically, the memory 603 is used to store application programs.
[0116] The processor 601 can call the application stored in the memory 603 through the transmission device 605 to execute the following steps: obtain the image to be tested of the rail transit vehicle; perform target recognition on the image to be tested based on the target information recognition model to obtain the target information of the target object contained in the image to be tested, wherein the target information recognition model is obtained by training the initial information recognition model using the training image, the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of the target area marked.
[0117] By adopting the embodiment of the present application, a scheme of an image recognition method and device is provided. By performing data enhancement processing on the initial image with the label information of the target area on the image, a training image is obtained, and the training image is used to train the initial information recognition model. The trained target information recognition model can efficiently and quickly recognize the target information contained in the image to be tested of the rail transit vehicle. Compared with the method of preparing a large number of high-quality training images in advance to train the initial information recognition model in the related art, the target information recognition model is obtained by preparing a small number of training images to complete the efficient and rapid training of the initial information recognition model, thereby achieving the technical effect of improving the training efficiency of the initial information recognition model based on a small number of training images, and then solving the technical problem of low training efficiency when training the initial information recognition model based on a small number of training images.
[0118] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0119] It can be understood by those skilled in the art that Figure 6 The structure shown is for illustration only, and the electronic device may be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other electronic devices. Figure 6 The structure of the electronic device is not limited. Figure 6 More or fewer components (such as network interfaces, display devices, etc.) shown in, or having Figure 6 Different configurations shown.
[0120] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the electronic device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0121] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to execute the program code of the image recognition method.
[0122] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.
[0123] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps: obtaining an image to be tested of a rail transit vehicle; performing target recognition on the image to be tested based on a target information recognition model to obtain target information of a target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of the target area annotated.
[0124] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0125] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0126] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0127] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0128] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0129] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0130] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0132] The above is only a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A method for recognizing an image, characterized in that: include: Acquire the image of the rail transit vehicle to be tested; Performing target recognition on the image to be tested based on a target information recognition model to obtain target information of the target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, and the training image is obtained after performing data enhancement processing on the initial image, and the initial image is an image with label information of the target area annotated; the training image is obtained by performing data enhancement processing on the first image and the second image, and the attribute information of the target object of the first image is different from that of the second image; The training image is obtained by performing data enhancement processing on the first image and the second image, including: adjusting the brightness of the first image and the second image to obtain an adjusted third image; replacing the background of the third image to obtain a fourth image; stitching the fourth image according to the target position relationship to obtain a fifth image; and determining the fifth image as the training image; Adjusting the brightness of the first image and the second image to obtain the adjusted third image includes: obtaining a reference brightness value of the training image; determining initial image brightness values of the first image and the second image; comparing the initial image brightness values with the reference brightness values; when the initial image brightness value is less than the reference brightness value, adjusting the initial image brightness value of the corresponding image upward to a first brightness value to obtain the third image, wherein the first brightness value is within a set threshold range; when the initial image brightness value is greater than the reference brightness value, adjusting the initial image brightness value of the corresponding image downward to a second brightness value to obtain the third image, wherein the second brightness value is within the set threshold range.
2. The method according to claim 1, characterized in that Acquiring the reference brightness value of the training image includes: Determine an initial brightness ratio of each initial image included in the training image, wherein the initial brightness ratio is a ratio of the brightness of each initial image to the number of pixels in the initial image; Screening out a target brightness ratio value greater than a set threshold value from the plurality of initial brightness ratio values; An average value of the target brightness ratios is determined as the reference brightness value of the training image.
3. The method according to claim 1, characterized in that: Performing background replacement on the third image to obtain the fourth image includes: Acquire the label information of the target area in the third image; When the label information is the first label information, the background replacement is performed on the target area based on a preset probability to obtain a sixth image, wherein the background replacement is to replace an image of any area in a background image with an image of the target area, the background image is an image selected from the training images, and the attribute information of the background image is different from that of the first image; The sixth image is subjected to target processing to obtain the fourth image, wherein the target processing includes flipping, rotating, adding noise, and mirroring.
4. The method according to claim 3, characterized in that After acquiring the label information of the target area in the third image, the method further includes: When the label information is the second label information, the target processing is performed on the third image to obtain the fourth image.
5. An image recognition device, characterized in that: include: A first acquisition module is used to acquire an image to be tested of a rail transit vehicle; A recognition module, used for performing target recognition on the image to be tested based on a target information recognition model to obtain target information of a target object contained in the image to be tested, wherein the target information recognition model is obtained by training an initial information recognition model using a training image, and the training image is obtained after data enhancement processing is performed on the initial image, and the initial image is an image with label information of a target area annotated; the training image is obtained by performing data enhancement processing on a first image and a second image, and the attribute information of the target object of the first image is different from that of the second image; It also includes a module for obtaining the training image by performing data enhancement processing on the first image and the second image, including: adjusting the brightness of the first image and the second image to obtain an adjusted third image; replacing the background of the third image to obtain a fourth image; stitching the fourth image according to the target position relationship to obtain a fifth image; determining the fifth image as the training image; adjusting the brightness of the first image and the second image to obtain the adjusted third image includes: obtaining a reference brightness value of the training image; determining the initial image brightness value of the first image and the second image; comparing the initial image brightness value and the reference brightness value; when the initial image brightness value is less than the reference brightness value, adjusting the initial image brightness value of the corresponding image upward to a first brightness value to obtain the third image, wherein the first brightness value is within a set threshold range; when the initial image brightness value is greater than the reference brightness value, adjusting the initial image brightness value of the corresponding image downward to a second brightness value to obtain the third image, wherein the second brightness value is within the set threshold range.
6. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 5 when executed.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: The processor executes the method described in any one of claims 1 to 5 through the computer program.
