Image processing method and device based on step-by-step thread and storage medium

By adopting a step-by-step thread processing method in the deep neural network and using multiple threads to process data in the message queue respectively, the problem of low efficiency of the deep neural network in image processing is solved and the effect of improving image processing efficiency is achieved.

CN112036503BActive Publication Date: 2024-09-17ZHEJIANG DAHUA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010955167.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-11
Publication Date
2024-09-17
Estimated Expiration
2040-09-11

AI Technical Summary

Technical Problem

Deep neural networks have many network layers and large parameters in image processing, resulting in low image processing efficiency. Existing technologies cannot effectively solve this problem.

Method used

An image processing method based on step-by-step threads is used to process data in the message queue separately through multiple threads. The first target thread preprocesses the image data and stores it in the second message queue. The second target thread performs inference processing on the processing results and Post-processing, threads do not interfere with each other to speed up image data processing.

Benefits of technology

The image processing efficiency of the neural network model is improved, the image data processing speed is accelerated through multi-thread processing, and the problem of low efficiency in performing image processing is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112036503B
    Figure CN112036503B
Patent Text Reader

Abstract

The present invention discloses an image processing method and device based on step-by-step threads and a storage medium. The method comprises: when there is image data to be processed in the first message queue of the target neural network model, the first image data to be processed is obtained from the first message queue through the first target thread, a first processing operation is performed on the first image data, a first processing result is obtained, and the first processing result is stored in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; when there is a processing result to be processed in the second message queue, the first processing result to be processed is obtained from the second message queue through the second target thread, and a second processing operation is performed on the first processing result to obtain the second processing result. The present invention solves the technical problem of low efficiency in performing image processing through a neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and in particular to an image processing method and device based on step-by-step threads and a storage medium. Background Art

[0002] Deep neural network technology is widely used in the field of image processing, such as target detection, recognition and tracking. Its principle is roughly as follows: design a deep neural network model, train the network model in labeled training samples, and continuously adjust the weight parameter value of each layer in the network to make the gap between the predicted value calculated by the neural network and the true value smaller and smaller. Test the network model stage: use the trained neural network model to preprocess the test data. The usual preprocessing includes: color conversion, scaling, and then perform inference pre-calculation on the processed data. Finally, perform post-processing on the inferred data to obtain the detection or recognition of the target in the image.

[0003] However, in order to make the trained neural network model more generalizable, the network layers of the designed deep neural network are getting deeper and deeper, and the structure is becoming more and more complex. At the same time, some problems are also brought about, such as: more network layers, larger number of parameters, and more time-consuming for the previous calculation. Therefore, there is a problem of low efficiency in performing image processing through neural network models.

[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present invention provide a step-by-step thread-based image processing method and device and a storage medium to at least solve the technical problem of low efficiency in performing image processing through a neural network model.

[0006] According to one aspect of an embodiment of the present invention, there is provided an image processing method based on step-by-step threads, including: when there is image data to be processed in the first message queue of the target neural network model, obtaining the first image data to be processed from the first message queue through the first target thread, performing a first processing operation on the first image data to obtain a first processing result, and storing the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; when there is a processing result to be processed in the second message queue, obtaining the first processing result to be processed from the second message queue through the second target thread, and performing a second processing operation on the first processing result to obtain a second processing result.

[0007] As an optional solution, the performing of the first processing operation on the first image data through the first target thread includes: performing a preprocessing operation on the first image data through the first target thread to obtain a first preprocessing result.

[0008] As an optional scheme, the above-mentioned storing the above-mentioned first processing result into the second message queue of the above-mentioned target neural network model through the first target thread includes: storing the above-mentioned first preprocessing result into the above-mentioned second message queue through the first target thread; or storing the above-mentioned first preprocessing result into the target memory address through the first target thread, and storing the above-mentioned target memory address into the above-mentioned second message queue.

[0009] As an optional solution, the above method also includes: when there is an image to be processed, obtaining a target image from the image to be processed through a third target thread; decoding the target image through the third target thread to obtain target image data; and storing the target image data into the first message queue through the third target thread.

[0010] As an optional solution, the target image is decoded through the third target thread to obtain target image data, including: decoding the image data of the target image into YUV image data through the third target thread, wherein the target image data includes the YUV image data.

[0011] As an optional solution, the obtaining of the first processing result to be processed from the second message queue through the second target thread also includes: performing an inference processing operation on the first processing result through the second target thread to obtain a target inference processing result.

[0012] As an optional scheme, the above-mentioned performing inference processing operations on the above-mentioned first image data through the above-mentioned first target thread to obtain the target inference processing result also includes: storing the above-mentioned target inference processing result into a third message queue through the second target thread; or storing the above-mentioned target inference processing result into a target memory address through the second target thread, and storing the above-mentioned target memory address into the above-mentioned third message queue.

[0013] As an optional scheme, the above-mentioned obtaining the first processing result to be processed from the above-mentioned second message queue through the second target thread also includes: performing a post-processing operation on the above-mentioned target reasoning processing result through the above-mentioned second target thread to obtain a target post-processing result, wherein the above-mentioned post-processing operation post-processes the above-mentioned target reasoning processing result according to the business scenario.

[0014] As an optional solution, before obtaining the first processing result to be processed from the second message queue through the second target thread, it also includes: obtaining a status identifier of the first processing result, wherein the status identifier is used to indicate that the first processing result has been stored in the second message queue, and the status identifier is used to indicate that obtaining the first processing result is allowed.

[0015] According to another aspect of an embodiment of the present invention, there is also provided an image processing device based on step-by-step threads, including: a first acquisition unit, used to, when there is image data to be processed in the first message queue of the target neural network model, acquire the first image data to be processed from the first message queue through the first target thread, perform a first processing operation on the first image data to obtain a first processing result, and store the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; a second acquisition unit, used to, when there is a processing result to be processed in the second message queue, acquire the first processing result to be processed from the second message queue through the second target thread, and perform a second processing operation on the first processing result to obtain a second processing result.

[0016] As an optional solution, the first acquisition unit includes: a first execution module, configured to perform a preprocessing operation on the first image data through the first target thread to obtain a first preprocessing result.

[0017] As an optional solution, the above-mentioned first execution module includes: a first storage sub-module, used to store the above-mentioned first preprocessing result into the above-mentioned second message queue through the first target thread; or a second storage sub-module, used to store the above-mentioned first preprocessing result into the target memory address through the first target thread, and store the above-mentioned target memory address into the above-mentioned second message queue.

[0018] As an optional solution, the above-mentioned device also includes: a third acquisition unit, which is used to acquire the target image from the image to be processed through the third target thread when there is an image to be processed; a decoding unit, which is used to decode the above-mentioned target image through the above-mentioned third target thread to obtain target image data; and a storage unit, which is used to store the above-mentioned target image data into the above-mentioned first message queue through the above-mentioned third target thread.

[0019] As an optional solution, the above decoding unit includes: a decoding module, used to decode the image data of the above target image into YUV image data through the above third target thread, wherein the above target image data includes the above YUV image data.

[0020] As an optional solution, the second acquisition unit includes: a second execution module, used to perform an inference processing operation on the first processing result through the second target thread to obtain a target inference processing result.

[0021] As an optional scheme, the above-mentioned second execution module also includes: a third storage sub-module, used to store the above-mentioned target reasoning processing result into the above-mentioned third message queue through the second target thread; or a fourth storage sub-module, used to store the above-mentioned target reasoning processing result into the target memory address through the second target thread, and store the above-mentioned target memory address into the above-mentioned third message queue.

[0022] As an optional solution, the above-mentioned second acquisition unit also includes: a third execution module, which is used to perform a post-processing operation on the above-mentioned target reasoning processing result through the above-mentioned second target thread to obtain a target post-processing result, wherein the above-mentioned post-processing operation post-processes the above-mentioned target reasoning processing result according to a business scenario.

[0023] As an optional solution, it also includes: a fourth acquisition unit, used to obtain the status identifier of the above-mentioned first processing result before obtaining the first processing result to be processed from the above-mentioned second message queue through the second target thread, wherein the above-mentioned status identifier is used to indicate that the above-mentioned first processing result has been stored in the above-mentioned second message queue, and the above-mentioned status identifier is used to indicate that the above-mentioned first processing result is allowed to be obtained.

[0024] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned step-by-step thread-based image processing method when running.

[0025] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the step-by-step thread-based image processing method through the computer program.

[0026] In an embodiment of the present invention, when there is image data to be processed in the first message queue of the target neural network model, the first image data to be processed is obtained from the first message queue through the first target thread, a first processing operation is performed on the first image data to obtain a first processing result, and the first processing result is stored in the second message queue of the target neural network model, wherein the above-mentioned target neural network model is used to process the above-mentioned image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; when there is a processing result to be processed in the second message queue, the first processing result to be processed is obtained from the second message queue through the second target thread, and a second processing operation is performed on the first processing result to obtain a second processing result, and the data obtained from the message queue is processed separately by multiple threads, and threads do not interfere with each other, thereby achieving the purpose of speeding up the processing speed of image data, thereby achieving the technical effect of improving the image processing efficiency of the neural network model, and then solving the technical problem of low efficiency of image processing performed by the neural network model. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0028] Figure 1 is a schematic diagram of a flow chart of an optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0029] Figure 2 is a schematic diagram of an optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0030] Figure 3 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0031] Figure 4 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0032] Figure 5 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0033] Figure 6 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0034] Figure 7is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0035] Figure 8 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0036] Fig. 9 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0037] Fig.10 is a schematic diagram of another optional step-by-step thread-based image processing method according to an embodiment of the present invention;

[0038] Fig.11 is a schematic diagram of an optional step-by-step thread-based image processing device according to an embodiment of the present invention;

[0039] Fig.12 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention 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 interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0042] Optionally, as an optional implementation, as Figure 1 As shown, the step-by-step thread-based image processing method includes:

[0043] S102, when there is image data to be processed in the first message queue of the target neural network model, obtaining the first image data to be processed from the first message queue through the first target thread, performing a first processing operation on the first image data, obtaining a first processing result, and storing the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue;

[0044] S104, when there is a processing result to be processed in the second message queue, obtain the first processing result to be processed from the second message queue through the second target thread, and perform a second processing operation on the first processing result to obtain a second processing result.

[0045] Optionally, the step-by-step thread-based image processing method can be applied, but is not limited to, in scenarios where multi-core hardware products run neural network models. Optionally, the target neural network model can be, but is not limited to, a deep neural network applied in the field of images, such as image recognition, detection, tracking and other fields. The application of the target neural network model can also be, but is not limited to, pre-designing different neural network structures, manually labeling some image data to produce training samples, training the neural network on a computer based on an open source framework or an independently designed training framework using the training data, and continuously adjusting the weight parameters in each layer of the network so that the final loss of the model becomes smaller and smaller. Specifically, for example, 1) designing a deep neural network model and training the network model stage; 2) training in labeled training samples, and continuously adjusting the weight parameter values ​​of each layer in the network so that the gap between the predicted value calculated by the neural network and the true value becomes smaller and smaller; 3) testing the network model stage, using the trained neural network model to pre-process the test data, and the usual pre-processing includes: color conversion, scaling, and then performing inference pre-calculation on the processed data; 4) finally performing post-processing on the inferred data to obtain results such as detection or recognition of targets in the image. Optionally, distributed threads can be, but are not limited to, a thread technology extended from multi-thread technology, wherein multi-threading can be, but are not limited to, a technology for realizing concurrent execution of multiple threads from software or hardware, and threads can be, but are not limited to, the smallest unit that the operating system can perform computational scheduling. Processing operations can be, but are not limited to, various types of operations for processing image data, such as color space conversion processing, scaling processing, normalization processing, mean subtraction processing, and other operations. The message queue can be, but are not limited to, used to store data or data storage addresses, wherein the data storage address is used to find storage space stored in a storage address that matches the data storage address. For example, if the target data is stored in a target memory array on the heap, the target data can be found and called according to the memory address of the target memory array, but are not limited to.

[0046] It should be noted that, when there is image data to be processed in the first message queue of the target neural network model, the first image data to be processed is obtained from the first message queue through the first target thread, a first processing operation is performed on the first image data to obtain a first processing result, and the first processing result is stored in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; when there is a processing result to be processed in the second message queue, the first processing result to be processed is obtained from the second message queue through the second target thread, and a second processing operation is performed on the first processing result to obtain a second processing result.

[0047] To further illustrate, the optional Figure 2 As shown, it includes a first message queue 202, first image data 204, a second message queue 206, a first processing result 208 and a second processing result 210. The first image data 204 to be processed is obtained from the first message queue 202, a first processing operation is performed on the first image data 204, and the obtained first processing result 208 is stored in the second message queue 206; the first processing result 208 to be processed is obtained in the second message queue 206, and a second processing operation is performed on the first processing result 208 to obtain the second processing result 210 (the dotted line indicates that the first processing result 208 of performing the second processing operation is obtained in the second message queue 206).

[0048] Through the embodiments provided by the present application, when there is image data to be processed in the first message queue of the target neural network model, the first image data to be processed is obtained from the first message queue through the first target thread, a first processing operation is performed on the first image data to obtain a first processing result, and the first processing result is stored in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; when there is a processing result to be processed in the second message queue, the first processing result to be processed is obtained from the second message queue through the second target thread, and a second processing operation is performed on the first processing result to obtain a second processing result, and the data obtained from the message queue is processed separately by multiple threads without interfering with each other, thereby achieving the purpose of speeding up the processing speed of image data, thereby realizing the technical effect of improving the efficiency of image processing based on step-by-step threads.

[0049] As an optional solution, performing a first processing operation on the first image data through a first target thread includes:

[0050] A preprocessing operation is performed on the first image data through the first target thread to obtain a first preprocessing result.

[0051] It should be noted that the first target thread performs a preprocessing operation on the first image data to obtain a first preprocessing result. Optionally, the preprocessing operation may include but is not limited to at least one of the following: color space conversion, scaling, normalization, and mean subtraction operations.

[0052] To further illustrate, the optional Figure 3 As shown, a preprocessing operation is performed on the first image data 304 in the first message queue 302 to obtain a first preprocessing result 306 (the dotted line indicates that the first image data 304 subjected to the preprocessing operation is obtained in the first message queue 302).

[0053] Through the embodiment provided in the present application, a preprocessing operation is performed on the first image data through the first target thread to obtain a first preprocessing result, thereby achieving the purpose of quickly obtaining the preprocessing result and realizing the effect of improving the efficiency of obtaining the preprocessing result.

[0054] As an optional solution, storing the first processing result into the second message queue of the target neural network model through the first target thread includes:

[0055] S1, storing the first preprocessing result into the second message queue through the first target thread; or

[0056] S2, storing the first preprocessing result into a target memory address through the first target thread, and storing the target memory address into a second message queue.

[0057] It should be noted that the first preprocessing result is stored in the second message queue through the first target thread; or the first preprocessing result is stored in the target memory address through the first target thread, and the target memory address is stored in the second message queue. Optionally, the first preprocessing result is stored in the memory space of the target memory address through the first target thread, wherein the memory space may be but is not limited to one of multiple memory address spaces on the heap, and the heap may be but is not limited to a special type of data structure in computer science, which may be but is not limited to an array object of a complete binary tree. Optionally, the target memory address may be but is not limited to being pre-allocated according to the first image data and used to store data related to the first image data (such as the first processing result data, etc.).

[0058] To further illustrate, the optional Figure 4 As shown, the first preprocessing result 402 is stored in the target memory address 404 , and the target memory address 404 is stored in the second message queue 406 , wherein the data corresponding to the first preprocessing result 402 can be searched and called according to the target memory address 404 .

[0059] Through the embodiments provided in the present application, the first preprocessing result is stored in the second message queue through the first target thread; or the first preprocessing result is stored in the target memory address through the first target thread, and the target memory address is stored in the second message queue, thereby achieving the purpose of flexibly storing the first preprocessing result and realizing the effect of improving the storage flexibility of data.

[0060] As an optional solution, the method further includes:

[0061] S1, when there is an image to be processed, obtaining a target image from the image to be processed through a third target thread;

[0062] S2, decoding the target image through the third target thread to obtain target image data;

[0063] S3, storing the target image data into the first message queue through the third target thread.

[0064] It should be noted that, when there is an image to be processed, the target image is obtained from the image to be processed by the third target thread; the target image is decoded by the third target thread to obtain target image data; and the target image data is stored in the first message queue by the third target thread. Optionally, decoding may be, but is not limited to, converting the image data in an original format into image data in another format by compression technology.

[0065] To further illustrate, the optional Figure 5 As shown, a target image 504 is obtained from the image to be processed 502 , the target image 504 is decoded to obtain target image data 506 , and the target image data 506 is stored in a pre-designed first message queue 508 .

[0066] Through the embodiments provided by the present application, when there is an image to be processed, a target image is obtained from the image to be processed through a third target thread; the target image is decoded through the third target thread to obtain target image data; and the target image data is stored in the first message queue through the third target thread, thereby achieving the purpose of pre-decoding the image and realizing the effect of improving the overall image processing efficiency.

[0067] As an optional solution, decoding the target image through a third target thread to obtain target image data includes:

[0068] The image data of the target image is decoded into YUV image data through a third target thread, wherein the target image data includes the YUV image data.

[0069] It should be noted that the image data of the target image is decoded into YUV image data through the third target thread, wherein the target image data includes YUV image data.

[0070] To further illustrate, the optional Figure 6 As shown, the input jpg format image data 602 is decoded into YUV image data 604, and the YUV image data 604 is saved in the target memory address 606 allocated in advance in the heap space. In this stage, as long as there is image data input, this operation will continue, and the target memory address 606 where the decoded image data is stored will be added to the message queue 608 each time.

[0071] Through the embodiment provided by the present application, the image data of the target image is decoded into YUV image data through the third target thread, wherein the target image data includes YUV image data, thereby achieving the purpose of realizing compatible decoding and storage operations through threads and realizing the effect of improving the utilization efficiency of threads.

[0072] As an optional solution, obtaining the first processing result to be processed from the second message queue through the second target thread also includes:

[0073] The second target thread performs an inference processing operation on the first processing result to obtain a target inference processing result.

[0074] It should be noted that the target inference processing result is obtained by performing an inference processing operation on the first processing result through the second target thread. Optionally, the inference processing operation may include but is not limited to at least one of the following: performing convolution operations on the data, pooling processing, using an activation function to change the data from linear to nonlinear, enhancing the expressiveness of the data, full connection, and other operations.

[0075] To further illustrate, the optional Figure 7 As shown, the reasoning processing operation is performed on the first processing result 702 to obtain the target reasoning processing result 704.

[0076] Through the embodiments provided in the present application, the second target thread performs an inference processing operation on the first processing result to obtain a target inference processing result, thereby achieving the purpose of performing an inference operation on the data and realizing the effect of improving the expressiveness of the data.

[0077] As an optional solution, performing the inference processing operation on the first image data through the first target thread to obtain the target inference processing result also includes:

[0078] S1, storing the target reasoning processing result into the third message queue through the second target thread; or

[0079] S2, storing the target reasoning processing result into the target memory address through the second target thread, and storing the target memory address into the third message queue.

[0080] It should be noted that the target reasoning processing result is stored in the third message queue through the second target thread; or the target reasoning processing result is stored in the target memory address through the second target thread, and the target memory address is stored in the third message queue.

[0081] To further illustrate, the optional Figure 8As shown, the target reasoning processing result 802 is stored in the target memory address 404, and the target memory address 404 is stored in the third message queue 804, wherein the data corresponding to the target reasoning processing result 802 can be searched and called according to the target memory address 404. .

[0082] Through the embodiments provided by the present application, the target reasoning processing result is stored in the third message queue through the second target thread; or the target reasoning processing result is stored in the target memory address through the second target thread, and the target memory address is stored in the third message queue, thereby achieving the purpose of storing various types of data related to the first image data at the same target memory address, and realizing the effect of improving the utilization rate of the storage space.

[0083] As an optional solution, obtaining the first processing result to be processed from the second message queue through the second target thread also includes:

[0084] A post-processing operation is performed on the target reasoning processing result through the second target thread to obtain a target post-processing result, wherein the post-processing operation post-processes the target reasoning processing result according to the business scenario.

[0085] It should be noted that the target post-processing result is obtained by performing a post-processing operation on the target reasoning processing result through the second target thread, wherein the post-processing operation post-processes the target reasoning processing result according to the business scenario.

[0086] To further illustrate, the optional Fig. 9 As shown, the target reasoning processing result 902 (or the target memory address 404) is obtained in the third message queue 804, and a post-processing operation is performed to obtain a target post-processing result.

[0087] Through the embodiments provided in the present application, a post-processing operation is performed on the target reasoning processing result through the second target thread to obtain a target post-processing result, wherein the post-processing operation performs post-processing on the target reasoning processing result according to the business scenario, thereby achieving the purpose of obtaining different post-processing results according to different businesses to be achieved, and realizing the effect of flexibility in obtaining post-processing results.

[0088] As an optional solution, before obtaining the first processing result to be processed from the second message queue through the second target thread, the method further includes:

[0089] A status flag of the first processing result is obtained, wherein the status flag is used to indicate that the first processing result has been stored in the second message queue, and the status flag is used to indicate that obtaining the first processing result is allowed.

[0090] It should be noted that the status flag of the first processing result is obtained, wherein the status flag is used to indicate that the first processing result has been stored in the second message queue, and the status flag is used to indicate that the first processing result is allowed to be obtained. Optionally, in the implementation of the image processing method based on step-by-step threads, both the first target thread and the second target thread have mutually exclusive access to each other. For example, if you want to obtain the target data in the message queue through the second target thread, you must be allowed to do so only after the target data is completely stored in the message queue through the first target thread.

[0091] To further illustrate, the optional Fig.10 As shown, when the first processing result 1002 is in a state of being completely stored in the second message queue 1004, the first processing result 1002 is allowed to be obtained; on the contrary, when the first processing result 1002 is in a state of not being completely stored in the second message queue 1004, the first processing result 1002 is prohibited from being obtained.

[0092] Through the embodiment provided by the present application, a status identifier of the first processing result is obtained, wherein the status identifier is used to indicate that the first processing result has been stored in the second message queue, and the status identifier is used to indicate that the first processing result is allowed to be obtained. By setting mutually exclusive access, the purpose of protecting the data in the message queue from being obtained without being fully stored is achieved, thereby achieving the effect of improving the security of the data.

[0093] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0094] According to another aspect of the embodiment of the present invention, a step-by-step thread-based image processing device for implementing the step-by-step thread-based image processing method is also provided. Fig.11 As shown, the device comprises:

[0095] The first acquisition unit 1102 is used for acquiring the first image data to be processed from the first message queue through the first target thread when there is image data to be processed in the first message queue of the target neural network model, performing a first processing operation on the first image data to obtain a first processing result, and storing the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue;

[0096] The second acquisition unit 1104 is used to acquire the first processing result to be processed from the second message queue through the second target thread when there is a processing result to be processed in the second message queue, and perform a second processing operation on the first processing result to obtain a second processing result.

[0097] Optionally, the step-by-step thread-based image processing device can be used, but is not limited to, in scenarios where multi-core hardware products run neural network models. Optionally, the target neural network model can be, but is not limited to, a deep neural network applied in the field of images, such as image recognition, detection, tracking and other fields. The application of the target neural network model can also be, but is not limited to, pre-designing different neural network structures, manually labeling some image data to produce training samples, training the neural network on a computer based on an open source framework or an independently designed training framework using the training data, and continuously adjusting the weight parameters in each layer of the network so that the final loss of the model becomes smaller and smaller. Specifically, for example, 1) designing a deep neural network model and training the network model stage; 2) training in labeled training samples, and continuously adjusting the weight parameter values ​​of each layer in the network so that the gap between the predicted value calculated by the neural network and the true value becomes smaller and smaller; 3) testing the network model stage, using the trained neural network model to pre-process the test data, and the usual pre-processing includes: color conversion, scaling, and then performing inference pre-calculation on the processed data; 4) finally performing post-processing on the inferred data to obtain results such as detection or recognition of targets in the image. Optionally, distributed threads can be, but are not limited to, a thread technology extended from multi-thread technology, wherein multi-threading can be, but are not limited to, a technology for realizing concurrent execution of multiple threads from software or hardware, and threads can be, but are not limited to, the smallest unit that the operating system can perform computational scheduling. Processing operations can be, but are not limited to, various types of operations for processing image data, such as color space conversion processing, scaling processing, normalization processing, mean subtraction processing, and other operations. The message queue can be, but are not limited to, used to store data or data storage addresses, wherein the data storage address is used to find storage space stored in a storage address that matches the data storage address. For example, if the target data is stored in a target memory array on the heap, the target data can be found and called according to the memory address of the target memory array, but are not limited to.

[0098] It should be noted that the first acquisition unit is used to, when there is image data to be processed in the first message queue of the target neural network model, acquire the first image data to be processed from the first message queue through the first target thread, perform a first processing operation on the first image data, obtain a first processing result, and store the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; the second acquisition unit is used to, when there is a processing result to be processed in the second message queue, acquire the first processing result to be processed from the second message queue through the second target thread, and perform a second processing operation on the first processing result to obtain a second processing result.

[0099] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0100] Through the embodiments provided by the present application, when there is image data to be processed in the first message queue of the target neural network model, the first image data to be processed is obtained from the first message queue through the first target thread, a first processing operation is performed on the first image data to obtain a first processing result, and the first processing result is stored in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; when there is a processing result to be processed in the second message queue, the first processing result to be processed is obtained from the second message queue through the second target thread, and a second processing operation is performed on the first processing result to obtain a second processing result, and the data obtained from the message queue is processed separately by multiple threads without interfering with each other, thereby achieving the purpose of speeding up the processing speed of image data, thereby realizing the technical effect of improving the efficiency of image processing based on step-by-step threads.

[0101] As an optional solution, the first obtaining unit 1102 includes:

[0102] The first execution module is used to perform a preprocessing operation on the first image data through a first target thread to obtain a first preprocessing result.

[0103] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0104] As an optional solution, the first execution module includes:

[0105] A first storing submodule is configured to store the first preprocessing result into the second message queue through the first target thread; or

[0106] The second storing submodule is used to store the first preprocessing result into the target memory address through the first target thread, and store the target memory address into the second message queue.

[0107] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0108] As an optional solution, the device also includes:

[0109] A third acquisition unit is used to acquire a target image from the image to be processed through a third target thread when there is an image to be processed;

[0110] A decoding unit, used for decoding the target image through a third target thread to obtain target image data;

[0111] The storing unit is used to store the target image data into the first message queue through the third target thread.

[0112] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0113] As an optional solution, the decoding unit includes:

[0114] The decoding module is used to decode the image data of the target image into YUV image data through a third target thread, wherein the target image data includes the YUV image data.

[0115] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0116] As an optional solution, the second obtaining unit 1104 includes:

[0117] The second execution module is used to perform an inference processing operation on the first processing result through a second target thread to obtain a target inference processing result.

[0118] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0119] As an optional solution, the second execution module further includes:

[0120] A third storing submodule is used to store the target reasoning processing result into a third message queue through the second target thread; or

[0121] The fourth storage submodule is used to store the target reasoning processing result into the target memory address through the second target thread, and store the target memory address into the third message queue.

[0122] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0123] As an optional solution, the second obtaining unit 1104 further includes:

[0124] The third execution module is used to perform a post-processing operation on the target reasoning processing result through the second target thread to obtain a target post-processing result, wherein the post-processing operation post-processes the target reasoning processing result according to a business scenario.

[0125] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0126] As an optional solution, it also includes:

[0127] The fourth acquisition unit is used to obtain the status identifier of the first processing result before obtaining the first processing result to be processed from the second message queue through the second target thread, wherein the status identifier is used to indicate that the first processing result has been stored in the second message queue, and the status identifier is used to indicate that the first processing result is allowed to be obtained.

[0128] For the specific implementation, reference may be made to the example shown in the above-mentioned step-by-step thread-based image processing method, which will not be described in detail in this example.

[0129] According to another aspect of the embodiment of the present invention, an electronic device for implementing the above-mentioned step-by-step thread-based image processing method is also provided. Fig.12 As shown, the electronic device includes a memory 1202 and a processor 1204. The memory 1202 stores a computer program, and the processor 1204 is configured to execute the steps in any of the above method embodiments through the computer program.

[0130] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.

[0131] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0132] S1, when there is image data to be processed in the first message queue of the target neural network model, obtain the first image data to be processed from the first message queue through the first target thread, perform a first processing operation on the first image data, obtain a first processing result, and store the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue;

[0133] S2, when there is a processing result to be processed in the second message queue, obtain the first processing result to be processed from the second message queue through the second target thread, and perform a second processing operation on the first processing result to obtain a second processing result.

[0134] Alternatively, a person skilled in the art may understand that: Fig.12 The structure shown is for illustration only, and the electronic device may also 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 terminal devices. Fig.12 The structure of the electronic device is not limited. Fig.12 More or fewer components (such as network interfaces, etc.) as shown in, or with Fig.12 Different configurations shown.

[0135] Among them, the memory 1202 can be used to store software programs and modules, such as the program instructions / modules corresponding to the step-by-step thread-based image processing method and device in the embodiment of the present invention. The processor 1204 executes various functional applications and data processing by running the software programs and modules stored in the memory 1202, that is, realizing the above-mentioned step-by-step thread-based image processing method. The memory 1202 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 1202 may further include a memory remotely arranged relative to the processor 1204, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 1202 may be specifically, but not limited to, used to store information such as first image data, first processing results, and second processing results. As an example, if Fig.12As shown, the memory 1202 may include but is not limited to the first acquisition unit 1102 and the second acquisition unit 1104 in the step-by-step thread-based image processing device. In addition, it may also include but is not limited to other module units in the step-by-step thread-based image processing device, which will not be repeated in this example.

[0136] Optionally, the transmission device 1206 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one example, the transmission device 1206 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 1206 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0137] In addition, the electronic device further includes: a display 1208 for displaying information such as the first image data, the first processing result and the second processing result; and a connection bus 1210 for connecting various module components in the electronic device.

[0138] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0139] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:

[0140] S1, when there is image data to be processed in the first message queue of the target neural network model, obtain the first image data to be processed from the first message queue through the first target thread, perform a first processing operation on the first image data, obtain a first processing result, and store the first processing result in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue;

[0141] S2, when there is a processing result to be processed in the second message queue, obtain the first processing result to be processed from the second message queue through the second target thread, and perform a second processing operation on the first processing result to obtain a second processing result.

[0142] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing hardware related to the terminal device through a program, and the program may 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 disk or an optical disk, etc.

[0143] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0144] 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 such understanding, the technical solution of the present invention, in essence, 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 can be personal computers, servers or network devices, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention.

[0145] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0146] 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 units is only a logical function division, and 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.

[0147] 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.

[0148] In addition, each functional unit in each embodiment of the present invention 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.

[0149] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A step-by-step thread-based image processing method, characterized in that: include: In the case where there is image data to be processed in the first message queue of the target neural network model, the first image data to be processed is obtained from the first message queue through the first target thread, a first processing operation is performed on the first image data to obtain a first processing result, and the first processing result is stored in the second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; In the case where there is a processing result to be processed in the second message queue, performing an inference processing operation on the first processing result to be processed through the second target thread to obtain a target inference processing result, including: storing the target inference processing result into a target memory address through the second target thread, and storing the target memory address into a third message queue; Performing a post-processing operation on the target reasoning processing result through the second target thread to obtain a target post-processing result, wherein the post-processing operation post-processes the target reasoning processing result according to a business scenario, and the target post-processing result is used to indicate a result of detecting or recognizing the image data; Before performing the inference processing operation on the first processing result to be processed by the second target thread to obtain a target inference processing result, the method further includes: A status flag of the first processing result is obtained, wherein the status flag is used to indicate that the first processing result has been stored in the second message queue, and the status flag is used to indicate that obtaining the first processing result is allowed.

2. The method according to claim 1, characterized in that The performing a first processing operation on the first image data through a first target thread includes: A preprocessing operation is performed on the first image data through the first target thread to obtain a first preprocessing result.

3. The method according to claim 2, characterized in that The storing the first processing result into the second message queue of the target neural network model through the first target thread includes: storing the first preprocessing result into the second message queue through the first target thread; or The first preprocessing result is stored in a target memory address through a first target thread, and the target memory address is stored in the second message queue.

4. The method according to claim 1, characterized in that: The method further comprises: When there is an image to be processed, obtaining a target image from the image to be processed by a third target thread; Decoding the target image through the third target thread to obtain target image data; The target image data is stored in the first message queue through the third target thread.

5. The method according to claim 4, characterized in that The decoding of the target image by the third target thread to obtain target image data includes: The image data of the target image is decoded into YUV image data by the third target thread, wherein the target image data includes the YUV image data.

6. The method according to claim 1, characterized in that The performing the inference processing operation on the first processing result to be processed by the second target thread to obtain a target inference processing result further comprises: The target reasoning processing result is stored in the third message queue through the second target thread.

7. An image processing device based on step-by-step threading, characterized in that: include: A first acquisition unit is used for, when there is image data to be processed in the first message queue of the target neural network model, acquiring the first image data to be processed from the first message queue through the first target thread, performing a first processing operation on the first image data to obtain a first processing result, and storing the first processing result in a second message queue of the target neural network model, wherein the target neural network model is used to process the image data to be processed, and the second message queue is used to record the processing result obtained by performing the first processing operation on the image data in the first message queue; a second acquisition unit, configured to acquire the first processing result to be processed from the second message queue through a second target thread when there is a processing result to be processed in the second message queue, and perform a second processing operation on the first processing result to obtain a second processing result, including: storing the target reasoning processing result into a target memory address through the second target thread, and storing the target memory address into a third message queue; The second acquiring unit includes: A second execution module, configured to perform an inference processing operation on the first processing result through the second target thread to obtain a target inference processing result; The second acquiring unit further includes: A third execution module is used to perform a post-processing operation on the target reasoning processing result through the second target thread to obtain a target post-processing result, wherein the post-processing operation post-processes the target reasoning processing result according to a business scenario, and the target post-processing result is used to indicate a result of detecting or recognizing the image data; The device is also used to obtain a status identifier of the first processing result before performing an inference processing operation on the first processing result to be processed by the second target thread to obtain a target inference processing result, wherein the status identifier is used to indicate that the first processing result has been stored in the second message queue, and the status identifier is used to indicate that obtaining the first processing result is allowed.

8. The device according to claim 7, characterized in that The first acquisition unit includes: The first execution module is used to perform a preprocessing operation on the first image data through the first target thread to obtain a first preprocessing result.

9. The device according to claim 8, characterized in that The first execution module includes: A first storing submodule is configured to store the first preprocessing result into the second message queue through a first target thread; or The second storing submodule is used to store the first preprocessing result into a target memory address through a first target thread, and store the target memory address into the second message queue.

10. The device according to claim 7, characterized in that The device also includes: A third acquisition unit is used to acquire a target image from the image to be processed through a third target thread when there is an image to be processed; A decoding unit, configured to decode the target image through the third target thread to obtain target image data; A storing unit is used to store the target image data into the first message queue through the third target thread.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 6 when executed.

12. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 through the computer program.