Image processing method and related device thereof
The image is encoded and processed through the neural network model, and the target detection result is directly output, which solves the problems of high image processing cost and low efficiency in the existing technology, and achieves efficient target detection.
Patent Information
- Application Number
- PCT/CN2024/078888
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-28
- Filing Date
- 2024-02-28
- Publication Date
- 2024-09-06
AI Technical Summary
Due to the need to process images and text in target detection, the existing technology results in a large amount of calculation, low efficiency, and high image processing costs.
Through an image processing method, a neural network model is used to encode and process images, and the location and category information of the object are directly output, avoiding dependence on text and reducing the amount of information processed.
It effectively reduces the cost and calculation amount of image processing, improves efficiency, and achieves efficient completion of target detection.
Smart Images

Figure CN2024078888_06092024_PF_FP
Abstract
Description
Image processing method and related device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on February 28, 2023, with application number 202310230254.1 and invention name “An image processing method and related equipment”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of artificial intelligence (AI) technology, and in particular to an image processing method and related equipment. Background Art
[0003] For visual tasks such as target detection, the main task is to use a neural network model to process an image to find all objects of interest in the image and determine the categories and locations of these objects. This is one of the core issues in the field of computer vision.
[0004] In related art, when object detection is required for an image, the image and multiple texts in the image (these texts are used to describe the categories of multiple objects in the image) can be input into a neural network model. The model then encodes the image to obtain an encoding result for the image, and encodes the texts to obtain encoding results for the texts. The model then processes the encoding results of the image and the encoding results of the texts to obtain and output the final processing result of the image. The final processing result of the image can then be used to determine the location and category of multiple objects in the image.
[0005] In this process, the image text is often manually specified or extracted using additional techniques, resulting in high image processing costs. Furthermore, neural network models need to process both images and text, requiring a large amount of information to process, resulting in high computational complexity and low efficiency.
[0006] Summary of the Invention
[0007] The embodiments of the present application provide an image processing method and related devices, which can effectively reduce the cost of image processing and reduce the computational complexity of image processing, thereby improving the efficiency of image processing.
[0008] A first aspect of an embodiment of the present application provides an image processing method, which is implemented by a first model and includes:
[0009] When object detection is required for an image, the image is first acquired. It should be noted that the image typically contains multiple objects. Once the image is acquired, it can be fed into a first model, which then processes the image based on object detection, thereby determining the locations and categories of multiple objects in the image.
[0010] After receiving the image, the first model may encode the image, thereby obtaining an encoding result of the image.
[0011] After obtaining the encoding result of the image, the first model can process the encoding result of the image to obtain a first processed result of the image. The first processed result of the image typically includes the position information of M objects in the image. Therefore, after the first processed result of the image is output by the first model, the first processed result of the image can be used to determine the positions of the M objects in the image. It should be noted that the M objects can be understood as either M objects in the image or M detection boxes in the image.
[0012] After obtaining the first processing result of the image, the first model can process the image encoding result and the first processing result to obtain the second processing result of the image. The second processing result of the image generally includes the category information of the M objects in the image. Then, after the second processing result of the image is output by the first model, the second processing result of the image can be used to determine the category of the M objects in the image. In this way, the positions and categories of the M objects in the image are successfully obtained, and object detection for the image is completed.
[0013] As can be seen from the above method, when object detection is required for an image, the image can be input into the first model. The first model then encodes the image to obtain an encoding result. Next, the first model processes the encoding result to obtain a first processing result. The first model then processes the encoding result and the first processing result to obtain a second processing result. After obtaining the first and second processing results output by the first model, the first processing result can be used to determine the locations of M objects in the image, and the second processing result can be used to determine the categories of the M objects in the image. Thus, object detection for the image is complete. In this process, the first model only receives the image as input, without requiring any text related to the image. This effectively reduces image processing costs. Furthermore, the first model only needs to perform a series of processing on the image to complete object detection. This requires less information to be processed, thus reducing the computational complexity of image processing and improving image processing efficiency.
[0014] In one possible implementation, encoding an image to obtain an encoding result of the image includes encoding the image to obtain first features of M objects in the image, and using the first features of the M objects as the encoding result of the image. In the aforementioned implementation, after receiving the image, the first model may encode the image to obtain first features of the M objects in the image (the first features of the M objects may also be referred to as initial region features of the M objects). The first model may then use the first features of the M objects as the encoding result of the image.
[0015] In one possible implementation, processing the encoding results to obtain a first image processing result includes: performing multi-layer perceptron-based processing on the first features of M objects to obtain second features of the M objects, and using the second features of the M objects as the first image processing result. In the aforementioned implementation, after obtaining the first features of the M objects, the first model may perform a series of multi-layer perceptron-based processing on the first features of the M objects to obtain second features of the M objects (the second features of the M objects may also be referred to as position information of the M objects). The first model may then use the second features of the M objects as the first image processing result and output it externally.
[0016] In one possible implementation, the first processing result includes the coordinates of the boundary points of the M objects in the image, or the first processing result includes the sizes of the M objects and the coordinates of the center points of the M objects in the image. In the aforementioned implementation, for any one of the M objects, the second feature of the object is the position information of the object, and the position information of the object can be presented in a variety of ways: (1) The position information of the object can be the coordinates of the boundary points of the object in the image. For example, when the object is a detection frame, the coordinates of the boundary points of the detection frame can refer to the coordinates of the four vertices of the detection frame. (2) The position information of the object can be the size of the object and the coordinates of the center point of the object in the image. For example, when the object is a detection frame, the size of the detection frame can refer to the height and width of the detection frame.
[0017] In one possible implementation, processing the encoding result and the first processing result to obtain a second processing result of the image includes: performing deformable convolution on the second features of M objects to obtain the third features of the M objects; fusing the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects; processing the fourth features of the M objects to obtain the fifth features of the M objects, and the fifth features of the M objects are used as the second processing result of the image. The processing of the fourth features includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection. In the aforementioned implementation, after obtaining the second features of the M objects, the first model can perform deformable convolution on the second features of the M objects to obtain the third features of the M objects (the third features of the M objects can also be referred to as features of the position information of the M objects). After obtaining the first features of the M objects and the third features of the M objects, the first model can fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects (the fourth features of the M objects can also be referred to as new regional features of the M objects). After obtaining the fourth features of the M objects, the first model can perform a series of processing on the fourth features of the M objects (for example, processing based on the self-attention mechanism, processing based on the interactive attention mechanism, and full connection, etc.), thereby obtaining the fifth features of the M objects. Then, the first model can use the fifth features of the M objects as the second processing result of the image and output it externally. It should be noted that for any object in the M objects, the fifth feature of the object is also the category information of the object, including the probability of the object belonging to each category.
[0018] A second aspect of an embodiment of the present application provides a model training method, which includes: acquiring an image; inputting the image into a first model to be trained to obtain a first processing result of the image and a second processing result of the image, wherein the first model to be trained is used to: encode the image to obtain an encoding result of the image; process the encoding result to obtain a first processing result of the image, and the first processing result is used to determine the positions of M objects in the image, M≥1; process the encoding result and the first processing result to obtain a second processing result of the image, and the second processing result is used to determine the categories of the M objects; based on the first processing result and the second processing result, obtain a target loss; and train the first model to be trained based on the target loss to obtain a first model.
[0019] The first model trained using the above method has specific image processing capabilities (object detection capabilities). Specifically, when object detection is required for an image, the image can be input into the first model. The first model can then first encode the image, thereby obtaining an encoding result. Next, the first model can process the encoding result to obtain a first processing result. The first model can then process the encoding result and the first processing result to obtain a second processing result. After obtaining the first and second processing results output by the first model, the first processing result can be used to determine the locations of M objects in the image, and the second processing result can be used to determine the categories of the M objects in the image. Thus, object detection for the image is completed. In the above process, the first model only receives the image as input, without requiring any text related to the image. This effectively reduces the cost of image processing. Furthermore, the first model only needs to perform a series of processing on the image to complete object detection. This requires less information to be processed, thus reducing the computational complexity of image processing and improving image processing efficiency.
[0020] In one possible implementation, the first model to be trained is used to encode an image to obtain first features of M objects in the image, and the first features of the M objects are used as encoding results of the image.
[0021] In one possible implementation, the first model to be trained is used to process the first features of M objects based on a multi-layer perceptron to obtain the second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
[0022] In a possible implementation, the first processing result includes coordinates of boundary points of the M objects in the image, or the first processing result includes sizes of the M objects and coordinates of center points of the M objects in the image.
[0023] In one possible implementation, the first model to be trained is used to: perform deformable convolution on the second features of M objects to obtain the third features of the M objects; fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects; process the fourth features of the M objects to obtain the fifth features of the M objects, and the fifth features of the M objects serve as the second processing result of the image. The processing of the fourth feature includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
[0024] In one possible implementation, the method further includes: obtaining N texts, where the N texts are used to describe N different categories, M≥N≥1; encoding the N texts through a second model to be trained to obtain features of the N texts; matching the features of the N texts and fourth features of M objects through a third model to be trained to obtain a matching degree between the N texts and the M objects, and the matching degree between the N texts and the M objects is used as a third processing result of the image; obtaining a target loss based on the first processing result and the second processing result includes: obtaining a target loss based on the first processing result, the second processing result, and the third processing result.
[0025] In one possible implementation, the method further includes: aggregating the matching degrees between N texts and M objects to obtain the matching degrees between N texts and images, and the matching degrees between the N texts and images serve as a fourth processing result of the image; obtaining the target loss based on the first processing result and the second processing result includes: obtaining the target loss based on the first processing result, the second processing result, and the fourth processing result.
[0026] In one possible implementation, the method further includes: training the second model to be trained and the third model to be trained based on the target loss to obtain the second model and the third model.
[0027] A third aspect of an embodiment of the present application provides an image processing device, which includes a first model and comprises: an acquisition module for acquiring an image; an encoding module for encoding the image to obtain an encoding result of the image; a first processing module for processing the encoding result to obtain a first processing result of the image, the first processing result being used to determine the positions of M objects in the image, M≥1; a second processing module for processing the encoding result and the first processing result to obtain a second processing result of the image, the second processing result being used to determine the categories of the M objects.
[0028] As can be seen from the above device, when object detection is required for an image, the image can be input into the first model. The first model then encodes the image to obtain an encoding result. Next, the first model processes the encoding result to obtain a first processing result. The first model then processes the encoding result and the first processing result to obtain a second processing result. After obtaining the first and second processing results output by the first model, the first processing result can be used to determine the locations of M objects in the image, and the second processing result can be used to determine the categories of the M objects in the image. Thus, object detection for the image is complete. In the above process, the first model only receives the image as input, without requiring any text related to the image. This effectively reduces image processing costs. Furthermore, the first model only needs to perform a series of processing on the image to complete object detection. This requires less information to be processed, thus reducing the computational complexity of image processing and improving image processing efficiency.
[0029] In a possible implementation, the encoding module is configured to encode an image to obtain first features of M objects in the image, and the first features of the M objects serve as encoding results of the image.
[0030] In one possible implementation, the first processing module is configured to perform multi-layer perceptron-based processing on the first features of the M objects to obtain the second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
[0031] In a possible implementation, the first processing result includes coordinates of boundary points of the M objects in the image, or the first processing result includes sizes of the M objects and coordinates of center points of the M objects in the image.
[0032] In one possible implementation, the second processing module is used to perform deformable convolution on the second features of M objects to obtain the third features of the M objects; fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects; process the fourth features of the M objects to obtain the fifth features of the M objects, and the fifth features of the M objects serve as the second processing results of the image. The processing of the fourth feature includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
[0033] The fourth aspect of an embodiment of the present application provides a model training device, which includes: a first acquisition module for acquiring an image; a first processing module for inputting the image into a first model to be trained to obtain a first processing result of the image and a second processing result of the image, wherein the first model to be trained is used to: encode the image to obtain an encoding result of the image; process the encoding result to obtain a first processing result of the image, and the first processing result is used to determine the positions of M objects in the image, M≥1; process the encoding result and the first processing result to obtain a second processing result of the image, and the second processing result is used to determine the categories of the M objects; a second acquisition module is used to obtain a target loss based on the first processing result and the second processing result; and a first training module is used to train the first model to be trained based on the target loss to obtain a first model.
[0034] The first model trained in the embodiment of the present application has specific image processing capabilities (target detection capabilities). Specifically, when target detection is required for an image, the image can be input into the first model. Then, the first model can first encode the image to obtain an encoding result of the image. Next, the first model can process the encoding result of the image to obtain a first processing result of the image. Then, the first model can process the encoding result of the image and the first processing result of the image to obtain a second processing result of the image. After obtaining the first processing result and the second processing result output by the first model, the first processing result can be used to determine the positions of M objects in the image, and the second processing result can be used to determine the categories of M objects in the image. At this point, target detection for the image is completed. In the above process, the input of the first model is only the image, and no text related to the image needs to be prepared, which can effectively reduce the cost of image processing. Moreover, the first model only needs to perform a series of processing on the image to complete target detection for the image. Less information needs to be processed, so the computational complexity of image processing can be reduced, thereby improving the efficiency of image processing.
[0035] In one possible implementation, the first model to be trained is used to encode an image to obtain first features of M objects in the image, and the first features of the M objects are used as encoding results of the image.
[0036] In one possible implementation, the first model to be trained is used to process the first features of M objects based on a multi-layer perceptron to obtain the second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
[0037] In a possible implementation, the first processing result includes coordinates of boundary points of the M objects in the image, or the first processing result includes sizes of the M objects and coordinates of center points of the M objects in the image.
[0038] In one possible implementation, the first model to be trained is used to: perform deformable convolution on the second features of M objects to obtain the third features of the M objects; fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects; process the fourth features of the M objects to obtain the fifth features of the M objects, and the fifth features of the M objects serve as the second processing result of the image. The processing of the fourth feature includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
[0039] In one possible implementation, the device also includes: a third acquisition module, used to acquire N texts, where the N texts are used to describe N different categories, M≥N≥1; a second processing module, used to encode the N texts through a second model to be trained to obtain features of the N texts; a third processing module, used to match the features of the N texts and the fourth features of M objects through a third model to be trained to obtain a matching degree between the N texts and the M objects, and the matching degree between the N texts and the M objects is used as a third processing result of the image; a second acquisition module, used to obtain a target loss based on the first processing result, the second processing result, and the third processing result.
[0040] In one possible implementation, the device also includes: a fourth processing module, used to aggregate the matching degrees between N texts and M objects to obtain the matching degrees between N texts and images, and the matching degrees between N texts and images serve as the fourth processing result of the image; and a second acquisition module, used to obtain the target loss based on the first processing result, the second processing result, and the fourth processing result.
[0041] In one possible implementation, the device further includes: a second training module, configured to train the second model to be trained and the third model to be trained based on the target loss to obtain the second model and the third model.
[0042] A fifth aspect of an embodiment of the present application provides an image processing device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the image processing device executes the method described in the first aspect or any possible implementation method of the first aspect.
[0043] A sixth aspect of an embodiment of the present application provides a model training device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the model training device executes the method described in the second aspect or any possible implementation method of the second aspect.
[0044] A seventh aspect of an embodiment of the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0045] An eighth aspect of an embodiment of the present application provides a chip system, which includes a processor for calling a computer program or computer instructions stored in a memory so that the processor executes a method as described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0046] In a possible implementation, the processor is coupled to the memory through an interface.
[0047] In one possible implementation, the chip system further includes a memory in which computer programs or computer instructions are stored.
[0048] A ninth aspect of an embodiment of the present application provides a computer storage medium storing a computer program, which, when executed by a computer, enables the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0049] A tenth aspect of an embodiment of the present application provides a computer program product, which stores instructions that, when executed by a computer, enable the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0050] In an embodiment of the present application, when target detection is required for an image, the image can be input into the first model. The first model can then first encode the image to obtain an encoding result for the image. Next, the first model can process the encoding result for the image to obtain a first processing result for the image. The first model can then process the encoding result and the first processing result for the image to obtain a second processing result for the image. After obtaining the first processing result and the second processing result output by the first model, the first processing result can be used to determine the locations of M objects in the image, and the second processing result can be used to determine the categories of the M objects in the image. At this point, target detection for the image is completed. In the aforementioned process, the input to the first model is only the image, and no text related to the image needs to be prepared. This effectively reduces the cost of image processing. Furthermore, the first model only needs to perform a series of processing on the image to complete target detection for the image. Less information needs to be processed, thereby reducing the computational complexity of image processing and improving image processing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 is a schematic diagram of the structure of the artificial intelligence main framework;
[0052] FIG2a is a schematic structural diagram of an image processing system provided in an embodiment of the present application;
[0053] FIG2 b is another schematic diagram of the structure of the image processing system provided in an embodiment of the present application;
[0054] FIG2c is a schematic diagram of an image processing device according to an embodiment of the present application;
[0055] FIG3 is a schematic diagram of the architecture of the system 100 provided in an embodiment of the present application;
[0056] FIG4 is a structural diagram of a first model provided in an embodiment of the present application;
[0057] FIG5 is a flow chart of an image processing method provided in an embodiment of the present application;
[0058] FIG6 is another structural diagram of the first model provided in an embodiment of the present application;
[0059] FIG7 is another structural diagram of the first model provided in an embodiment of the present application;
[0060] FIG8 is a schematic diagram of a structure of a joint training framework provided in an embodiment of the present application;
[0061] FIG9 is a schematic diagram of a model training method provided in an embodiment of the present application;
[0062] FIG10 is another structural diagram of the joint training framework provided in an embodiment of the present application;
[0063] FIG11 is a schematic diagram of the structure of an image processing device provided in an embodiment of the present application;
[0064] FIG12 is a schematic structural diagram of a model training device provided in an embodiment of the present application;
[0065] FIG13 is a schematic structural diagram of an execution device provided in an embodiment of the present application;
[0066] FIG14 is a schematic diagram of the structure of a training device provided in an embodiment of the present application;
[0067] FIG15 is a schematic structural diagram of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] The embodiments of the present application provide an image processing method and related devices, which can effectively reduce the cost of image processing and reduce the computational complexity of image processing, thereby improving the efficiency of image processing.
[0069] 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 sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0070] With the rapid development of computer technology, neural network models within AI are increasingly being used to complete various visual tasks. Object detection, a type of visual task, primarily involves using neural network models to process an image to identify all objects of interest and determine their categories and locations. This is one of the core problems in computer vision.
[0071] In related art, when it is necessary to perform target detection on an image, the image and multiple texts of the image can be obtained first. These texts are used to describe the categories of multiple objects in the image. For example, suppose there is an image that shows a person lying on the grass, and the grass is planted with flowers, grass and trees, and there are butterflies on the flowers. Therefore, the multiple texts of the image are "person", "land", "flowers", "grass", "trees" and "butterfly". Then, the image and the multiple texts of the image are input into the neural network model. Then, the model encodes the image to obtain the encoding result of the image, and encodes the texts to obtain the encoding results of the texts. Then, the model can process the encoding results of the image and the encoding results of the texts to obtain and output the final processing result of the image. Then, the final processing result of the image can be used to determine the position and category of multiple objects in the image.
[0072] In this process, the image text is often manually specified or extracted using additional techniques, resulting in high image processing costs. Furthermore, neural network models need to process both images and text, requiring a large amount of information to process, resulting in high computational complexity and low efficiency.
[0073] In order to solve the above problems, an embodiment of the present application provides an image processing method, which can be implemented in combination with artificial intelligence (AI) technology. AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by perceiving the environment, acquiring knowledge and using knowledge. In other words, artificial intelligence technology is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Using artificial intelligence for data processing is a common application of artificial intelligence.
[0074] First, we will describe the overall workflow of an AI system. See Figure 1, which illustrates a schematic diagram of the AI framework. This framework will be explained from two perspectives: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects the entire process from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. Throughout this process, data undergoes a condensed journey from "data-information-knowledge-wisdom." The "IT value chain," spanning the underlying infrastructure of human intelligence, information (provided and processed by technology), and the system's industrial ecosystem, reflects the value that AI brings to the information technology industry.
[0075] (1) Infrastructure
[0076] Infrastructure provides computing power for AI systems, enabling communication with the outside world and supporting this through a foundational platform. External communication occurs through sensors; computing power is provided by intelligent chips (CPUs, NPUs, GPUs, ASICs, FPGAs, and other hardware accelerators). The foundational platform includes a distributed computing framework and network-related platform guarantees and support, including cloud storage and computing, and interconnected networks. For example, sensors communicate with the outside world to acquire data, which is then fed into the intelligent chips within the distributed computing system provided by the foundational platform for computation.
[0077] (2) Data
[0078] Data above the infrastructure layer represents data sources for AI. This data includes graphics, images, voice, and text, as well as IoT data from traditional devices. This includes business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0079] (3) Data processing
[0080] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
[0081] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0082] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0083] Decision-making refers to the process of making decisions after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
[0084] (4) General ability
[0085] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0086] (5) Smart products and industry applications
[0087] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0088] Next, several application scenarios of this application are introduced.
[0089] Figure 2a is a schematic diagram of the structure of an image processing system provided in an embodiment of the present application. The image processing system includes a user device and a data processing device. The user device includes an intelligent terminal such as a mobile phone, a personal computer, or an information processing center. The user device is the initiator of image processing and is the initiator of image processing requests, typically initiated by a user through the user device.
[0090] The aforementioned data processing device can be a device or server with data processing capabilities, such as a cloud server, network server, application server, or management server. The data processing device receives text processing requests from smart terminals via an interactive interface and then performs text processing using memory for data storage and a data processing processor, including machine learning, deep learning, search, reasoning, and decision-making. The memory in the data processing device is a general term that includes local storage and a database for storing historical data. The database can be located on the data processing device or on other network servers.
[0091] In the image processing system shown in Figure 2a, a user device can receive user instructions. For example, the user device can obtain an image input / selected by the user and then initiate a request to a data processing device, causing the data processing device to execute an image processing application on the image obtained by the user device, thereby obtaining a corresponding processing result for the image. For example, the user device can obtain an image input by the user and then initiate an image processing request to the data processing device, causing the data processing device to perform object detection processing on the image, thereby obtaining a processing result for the image. The image processing result can be used to determine the location and category of multiple objects in the image.
[0092] In FIG. 2 a , the data processing device may execute the image processing method according to the embodiment of the present application.
[0093] Figure 2b is another structural schematic diagram of the image processing system provided in an embodiment of the present application. In Figure 2b, the user device directly serves as a data processing device. The user device can directly obtain input from the user and directly process it by the hardware of the user device itself. The specific process is similar to that of Figure 2a. Please refer to the above description and will not be repeated here.
[0094] In the image processing system shown in FIG2b , the user device may receive user instructions. For example, the user device may obtain an image input by the user and then perform target detection processing on the image to obtain a processing result of the image. The processing result of the image may be used to determine the positions and categories of multiple objects in the image.
[0095] In FIG2 b , the user equipment itself can execute the image processing method of the embodiment of the present application.
[0096] FIG2c is a schematic diagram of an image processing related device provided in an embodiment of the present application.
[0097] The user device in the above Figures 2a and 2b can specifically be the local device 301 or the local device 302 in Figure 2c, and the data processing device in Figure 2a can specifically be the execution device 210 in Figure 2c, wherein the data storage system 250 can store the data to be processed of the execution device 210, and the data storage system 250 can be integrated on the execution device 210, or it can be set on the cloud or other network servers.
[0098] The processors in Figures 2a and 2b can perform data training / machine learning / deep learning through a neural network model or other models (for example, a model based on a support vector machine), and use the model finally trained or learned from the data to perform image processing applications on the image, thereby obtaining corresponding processing results.
[0099] Figure 3 is a schematic diagram of the system 100 architecture provided in an embodiment of the present application. In Figure 3, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with an external device. The user can input data to the I / O interface 112 through the client device 140. The input data can include: various tasks to be scheduled, callable resources and other parameters in the embodiment of the present application.
[0100] When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculations and other related processing (such as implementing the functions of the neural network in this application), the execution device 110 can call the data, code, etc. in the data storage system 150 for the corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing in the data storage system 150.
[0101] Finally, the I / O interface 112 returns the processing result to the client device 140 so as to provide it to the user.
[0102] It is worth noting that the training device 120 can generate corresponding target models / rules based on different training data for different goals or tasks. The corresponding target models / rules can be used to achieve the above goals or complete the above tasks, thereby providing the user with the desired results. The training data can be stored in the database 130 and come from training samples collected by the data collection device 160.
[0103] In the scenario shown in FIG3 , the user can manually input data, which can be performed through the interface provided by I / O interface 112. Alternatively, client device 140 can automatically send input data to I / O interface 112. If user authorization is required for client device 140 to automatically send input data, the user can set the corresponding permissions in client device 140. The user can view the output of execution device 110 on client device 140, which can be presented in a display, sound, action, or other specific form. Client device 140 can also serve as a data acquisition terminal, collecting input data and output results from I / O interface 112 as new sample data and storing them in database 130. Of course, collection can also be performed without client device 140, with I / O interface 112 directly storing the input data and output results from I / O interface 112 as new sample data in database 130.
[0104] It is worth noting that FIG3 is only a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in FIG3, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 can also be placed in the execution device 110. As shown in FIG3, a neural network can be trained according to the training device 120.
[0105] The present application also provides a chip including a neural network processor (NPU). The chip can be provided in the execution device 110 shown in FIG3 to complete the computational work of the computation module 111. The chip can also be provided in the training device 120 shown in FIG3 to complete the training work of the training device 120 and output the target model / rule.
[0106] The neural network processor (NPU) is a coprocessor mounted on the host central processing unit (CPU), which assigns tasks to it. The core of the NPU is the arithmetic circuit, which is controlled by a controller to extract data from memory (weight memory or input memory) and perform calculations.
[0107] In some implementations, the arithmetic circuit includes multiple processing engines (PEs). In some implementations, the arithmetic circuit is a two-dimensional systolic array. The arithmetic circuit can also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit is a general-purpose matrix processor.
[0108] For example, consider an input matrix A, a weight matrix B, and an output matrix C. The computational circuit retrieves the corresponding data for matrix B from the weight memory and caches it on each PE within the computational circuit. The computational circuit then performs a matrix operation on the matrix A data from the input memory and matrix B, storing the partial or final matrix results in the accumulator.
[0109] The vector computation unit can further process the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector computation unit can be used for network calculations in non-convolutional / non-FC layers in neural networks, such as pooling, batch normalization, and local response normalization.
[0110] In some implementations, the vector computation unit can store the processed output vectors in a unified buffer. For example, the vector computation unit can apply a nonlinear function to the output of the computation circuit, such as a vector of accumulated values, to generate activation values. In some implementations, the vector computation unit generates normalized values, merged values, or both. In some implementations, the processed output vectors can be used as activation inputs to the computation circuit, such as for use in subsequent layers in a neural network.
[0111] The unified memory is used to store input data and output data.
[0112] The weight data is directly transferred from the external memory to the input memory and / or unified memory through the direct memory access controller (DMAC), the weight data in the external memory is stored in the weight memory, and the data in the unified memory is stored in the external memory.
[0113] The bus interface unit (BIU) is used to implement interaction between the main CPU, DMAC and instruction fetch memory through the bus.
[0114] An instruction fetch buffer connected to the controller, used to store instructions used by the controller;
[0115] The controller is used to call the instructions cached in the memory to control the working process of the computing accelerator.
[0116] Generally, unified memory, input memory, weight memory and instruction fetch memory are all on-chip memories, and external memory is memory outside the NPU, which can be double data rate synchronous dynamic random access memory (DDR SDRAM), high bandwidth memory (HBM) or other readable and writable memory.
[0117] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.
[0118] (1) Neural Network
[0119] A neural network can be composed of neural units. A neural unit can refer to an operation unit with xs and intercept 1 as input. The output of the operation unit can be:
[0120] Where s = 1, 2, ... n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer. The activation function can be a sigmoid function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.
[0121] The operation of each layer in a neural network can be described by the mathematical expression y = a(Wx + b). From a physical perspective, the operation of each layer in a neural network can be understood as transforming the input space (a set of input vectors) into the output space (i.e., from the row space to the column space of a matrix) through five operations. These operations include: 1. Dimensionality increase / decrease; 2. Scaling / reduction; 3. Rotation; 4. Translation; and 5. "Bending." Operations 1, 2, and 3 are performed by Wx, 4 by +b, and 5 by a(). The word "space" is used here because the objects being classified are not individual things, but rather a class of things, and space refers to the collection of all individuals within that class. W is the weight vector, each value in which represents the weight of a neuron in that layer of the neural network. This vector W determines the spatial transformation from input space to output space described above. That is, the weights W of each layer control how the space is transformed. The goal of training a neural network is to ultimately obtain the weight matrix for all layers of the trained neural network (a weight matrix formed by the vectors W of many layers). Therefore, the training process of a neural network is essentially about learning how to control spatial transformations, and more specifically, about learning the weight matrix.
[0122] Because we want the output of the neural network to be as close as possible to the value we really want to predict, we can compare the current network's predicted value with the desired target value, and then update the weight vector of each layer of the neural network based on the difference between the two (of course, there is usually an initialization process before the first update, which is to pre-configure the parameters for each layer in the neural network). For example, if the network's predicted value is too high, the weight vector is adjusted to make it predict a lower value, and this adjustment is continued until the neural network can predict the desired target value. Therefore, it is necessary to pre-define "how to compare the difference between the predicted value and the target value." This is the loss function or objective function, which is an important equation used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the neural network becomes a process of minimizing this loss as much as possible.
[0123] (2) Backpropagation algorithm
[0124] Neural networks can use the back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during training, reducing the reconstruction error loss of the neural network model. Specifically, the forward propagation of the input signal to the output generates error loss. This error loss information is then backpropagated to update the parameters in the initial neural network model, thereby converging the error loss. The BP algorithm is a backward propagation movement dominated by error loss, aiming to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0125] The method provided in this application is described below from the training side of the neural network and the application side of the neural network.
[0126] The model training method provided in the embodiment of the present application involves the processing of data sequences, and can be specifically applied to methods such as data training, machine learning, and deep learning. The training data (for example, the image and N texts in the model training method provided in the embodiment of the present application, etc.) is symbolized and formalized for intelligent information modeling, extraction, preprocessing, and training, and finally a trained neural network is obtained (for example, the first model, the second model, and the third model in the model training method provided in the embodiment of the present application, etc.); and the summary generation method provided in the embodiment of the present application can use the above-mentioned trained neural network to input the input data (for example, the image in the image processing method provided in the embodiment of the present application) into the trained neural network to obtain output data (for example, the first processing result of the image and the second processing result of the image in the image processing method provided in the embodiment of the present application, etc.). It should be noted that the model training method and summary generation method provided in the embodiment of the present application are inventions based on the same concept, and can also be understood as two parts in a system, or two stages of an overall process: such as the model training stage and the model application stage.
[0127] The image processing method provided in the embodiment of the present application can be implemented through the first model. FIG4 is a structural diagram of the first model provided in the embodiment of the present application. As shown in FIG4, the first model includes: an image encoder module, a multilayer perceptron (MLP) module, a deformable module, a fusion (cls) module, and a dense captioning module. In order to understand the workflow of the first model, the workflow of the first model is introduced below in conjunction with FIG5. FIG5 is a flow diagram of the image processing method provided in the embodiment of the present application. As shown in FIG5, the method includes:
[0128] 501. Acquire an image.
[0129] In this embodiment, when object detection is required for an image, the image may be first acquired. It should be noted that the image typically contains multiple objects. After acquiring the image, the image may be input into a first model (a trained neural network model) to cause the first model to perform object detection-based processing on the image, thereby determining the locations and categories of multiple objects in the image.
[0130] 502. Encode the image to obtain an encoding result of the image.
[0131] After receiving the image, the first model may encode the image, thereby obtaining an encoding result of the image.
[0132] Specifically, the first model can obtain the encoding result of the image in the following manner:
[0133] After receiving the image, the image encoder module of the first model can encode the image to obtain the first features of M objects in the image (M is a positive integer greater than or equal to 1, and the first features of the M objects can also be called the initial region features of the M objects). Then, the image encoder module can use the first features of the M objects as the encoding result of the image. It should be noted that for any two objects among the M objects, the two objects can be objects belonging to the same category or objects belonging to different categories, and one of the M objects occupies an area in the image. In this way, these M objects can be understood as M objects in the image or as M detection boxes in the image.
[0134] For example, as shown in FIG6 (FIG6 is another structural diagram of the first model provided in an embodiment of the present application), the first model can be referred to as an image processing model. After an image is input into the image processing model, the image encoder module in the image processing model can process the image to obtain the initial region feature f P′ , where f P′ Including the initial features of the first detection box in the image, the initial features of the second detection box, ..., the initial features of the Mth detection box.
[0135] 503. Process the encoding result to obtain a first processing result of the image. The first processing result is used to determine positions of M objects in the image, where M≥1.
[0136] After obtaining the encoding result of the image, the first model can process the encoding result of the image to obtain a first processing result of the image. The first processing result of the image usually includes the position information of M objects in the image. Then, after the first processing result of the image is output by the first model, the first processing result of the image can be used to determine the positions of the M objects in the image.
[0137] Specifically, the first model can obtain the first processing result of the image in the following manner:
[0138] After obtaining the first features of the M objects, the image encoder module can send the first features of the M objects to the multi-layer perceptron module. Then, the multi-layer perceptron module can perform a series of processing (for example, convolution, full connection, normalization, and channel aggregation, etc.) on the first features of the M objects to obtain the second features of the M objects (the second features of the M objects can also be called the position information of the M objects). Then, the multi-layer perceptron module can use the second features of the M objects as the first processing result of the image and output it to the outside. It should be noted that for any one of the M objects, the second feature of the object is also the position information of the object. The position information of the object can be presented in a variety of ways: (1) The position information of the object can be the coordinates of the boundary points of the object in the image. For example, when the object is a detection frame, the coordinates of the boundary points of the detection frame can refer to the coordinates of the four vertices of the detection frame. Therefore, based on the coordinates of the four vertices of the detection frame, the specific position of the detection frame in the image can be directly determined. (2) The position information of the object may be the size of the object and the coordinates of the center point of the object in the image. For example, when the object is a detection frame, the size of the detection frame may refer to the height and width of the detection frame. Therefore, the specific position of the detection frame in the image can be directly determined based on the width, height and coordinates of the center point of the detection frame.
[0139] As in the above example, the image encoder module obtains f P′ After that, f P′ Provided to the MLP module, the MLP module can P′ The MLP module then outputs the offset.
[0140] 504. Process the encoding result and the first processing result to obtain a second processing result of the image. The second processing result is used to determine the categories of the M objects.
[0141] After obtaining the first processing result of the image, the first model can process the image encoding result and the first processing result to obtain the second processing result of the image. The second processing result of the image generally includes the category information of the M objects in the image. Then, after the second processing result of the image is output by the first model, the second processing result of the image can be used to determine the category of the M objects in the image. In this way, the positions and categories of the M objects in the image are successfully obtained, and object detection for the image is completed.
[0142] Specifically, the first model can obtain the second processing result of the image in the following manner:
[0143] (1) After obtaining the second features of the M objects, the multilayer perceptron module may also send the second features of the M objects to the deformable module. Then, the deformable module may perform deformable convolution on the second features of the M objects to obtain the third features of the M objects (the third features of the M objects may also be referred to as the features of the position information of the M objects).
[0144] As in the above example, after obtaining the offset, the MLP module can also provide the offset to the deformable module, which can process the offset to obtain the feature f of the position information. offset , where f offset It includes the features of the position information of the first detection frame in the image, the features of the position information of the second detection frame, ..., the features of the position information of the Mth detection frame.
[0145] (2) After obtaining the first features of the M objects, the image encoding module may also send the first features of the M objects to the fusion module. After obtaining the third features of the M objects, the deformable module may send the third features of the M objects to the fusion module. Then, the fusion module may fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects (the fourth features of the M objects may also be referred to as new region features of the M objects).
[0146] As in the above example, the initial regional feature f is obtained P′ After that, the image encoder module can convert f P′ Provided to the cls module. Get the feature f of the position information offset After that, the deformable module can be f offset Provided to the cls module. The cls module can f P′ and f offset Fusion is performed to obtain the new regional feature f P , where f PIncluding the new features of the first detection box in the image, the new features of the second detection box,..., the new features of the Mth detection box.
[0147] (3) After obtaining the fourth features of the M objects, the fusion module can send the fourth features of the M objects to the dense generation module. Then, the dense generation module can perform a series of processing on the fourth features of the M objects (for example, processing based on the self-attention mechanism, processing based on the interactive attention mechanism, and full connection, etc.), thereby obtaining the fifth features of the M objects. Then, the dense generation module can use the fifth features of the M objects as the second processing result of the image and output it to the outside. It should be noted that for any one of the M objects, the fifth feature of the object is also the category information of the object, including the probability that the object belongs to each category, so the specific category of the object can be determined based on these probabilities.
[0148] Still as in the above example, as shown in FIG7 (FIG7 is another structural diagram of the first model provided in the embodiment of the present application), the new regional feature f is obtained. P After that, the cls module can be f P Sent to the dense captioning module, which is for f P Specifically, in the first round, the module can sequentially process the preset category BOS based on the self-attention mechanism, the cross-modal attention mechanism, and the full connection (feed forward). In the process of the cross-modal attention mechanism, f is added. P The new region features of the first detection box in Therefore, the probability of the first detection box belonging to each category can be obtained, and then the category with the highest probability is determined as the category y1 of the first detection box. In the second round, the module can process BOS and y1 based on the self-attention mechanism, the interactive attention mechanism and the full connection in turn. In the interactive attention mechanism, f is added P The new region features of the second detection box in Therefore, we can get the probability that the second detection frame belongs to each category, and then determine the category with the highest probability as the category y2 of the second detection frame. And so on, until we get the category y of the Mth detection frame. M .
[0149] In addition, the first model provided in the embodiment of the present application (i.e., DetCLIPv2 in Table 1) can be compared with the models provided in some related technologies (i.e., the remaining models except DetCLIPv2 in Table 1). The comparison results are shown in Table 1:
[0150] Table 1
[0151] It should be noted that in Table 1, the zero-shot performance on the LVIS subset, Apr / APc / APf represent the values of rare classes, common classes, and frequent classes, respectively. DH and F in GLIP represent the more complex dynamic detection head and multimodal information deep fusion module.
[0152] Table 1 shows the performance of various models on the LVIS. The first model provided by the present embodiment, DetCLIPv2, significantly improves performance compared to related art models. For example, DetCLIPv2 significantly outperforms GLIP, with DetCLIP v2-T outperforming GLIP-T by 14.4% and even improving on rare classes by 15.2%. Furthermore, DetCLIPv2 is more lightweight than GLIP due to the lack of a dynamic head (DH) and cross-modal fusion (F).
[0153] At the same time, compared with GLIP-T, the DetCLIPv2-T provided in the embodiment of the present application has a 16-fold and 19-fold improvement in training time and test speed, respectively, as shown in Table 2:
[0154] Table 2
[0155] Furthermore, the first model provided in the embodiment of the present application (i.e., DetCLIPv2 in Table 3) can be compared with the models provided in another related art (i.e., the remaining models except DetCLIPv2 in Table 3). The comparison results are shown in Table 3:
[0156] Table 3
[0157] It should be noted that the first model provided in this embodiment, DetCLIPv2, primarily adds a dense generation module compared to related art models. Table 3 explores the impact of adding a dense generation module on open-set detection performance. Table 3 shows the evaluation on the LVIS minival validation set. * indicates that the same training set (O365, VG) was used for training to ensure fair comparison.
[0158] Table 2 shows the performance improvement of zero-shot target detection on LVIS by the dense generation module. The backbone network Swin-T is mainly used here to train DetCLIPv2-T on the detection data Objects365 and VG data. Since DetCLIP does not report the performance of training on O365 and VG, DetCLIP and DetCLIPv2 are trained on the same two datasets under the same settings for fair comparison (models with *). Comparing the last two rows, it can be seen that by adding an additional dense generation module, the DetCLIPv2-T* provided in the embodiment of the present application outperforms DetCLIP-T(C)* on the same data scale and backbone network. Specifically, on the LVIS dataset, the dense generation module improves the open set detection performance mAP by 2.3%, of which the improvements on rare / common / frequency classes are 2.1%, 2.2% and 2.5% respectively.
[0159] Furthermore, the first model provided in the embodiment of the present application (i.e., DetCLIPv2 in Table 4) can be compared with the models provided in another part of the related art (i.e., the remaining models except DetCLIPv2 in Table 4). The comparison results are shown in Table 4:
[0160] Table 4
[0161] Table 4 shows that DetCLIPv2-T* significantly outperforms TDC by nearly 3.5% in target detection performance (mAP) on VG. One important reason for this is that the model provided in the embodiment of the present application has excellent detection performance, which contributes to the positioning capability of the target detection task.
[0162] In an embodiment of the present application, when target detection is required for an image, the image can be input into the first model. The first model can then first encode the image to obtain an encoding result for the image. Next, the first model can process the encoding result for the image to obtain a first processing result for the image. The first model can then process the encoding result and the first processing result for the image to obtain a second processing result for the image. After obtaining the first processing result and the second processing result output by the first model, the first processing result can be used to determine the locations of M objects in the image, and the second processing result can be used to determine the categories of the M objects in the image. At this point, target detection for the image is completed. In the aforementioned process, the input to the first model is only the image, and no text related to the image needs to be prepared. This effectively reduces the cost of image processing. Furthermore, the first model only needs to perform a series of processing on the image to complete target detection for the image. Less information needs to be processed, thereby reducing the computational complexity of image processing and improving image processing efficiency.
[0163] Furthermore, the first model provided in the embodiment of the present application has a dense generation module. Due to the existence of this module, the performance of the first model in image processing can be effectively improved, that is, the first model can accurately complete the target detection task for the image, thereby providing users with better quality services.
[0164] The above is a detailed description of the image processing method provided by the embodiment of the present application. The model training method provided by the embodiment of the present application will be introduced below. Figure 8 is a structural diagram of the joint training framework provided by the embodiment of the present application. As shown in Figure 8, the framework includes: a first model to be trained, a second model to be trained, and a third model to be trained. The internal structure of the first model to be trained can refer to Figure 4. The second model to be trained is a text encoder module, and the third model to be trained is a matching module. In order to understand the workflow of the framework, the process is introduced below in conjunction with Figure 9. Figure 9 is a schematic diagram of the model training method provided by the embodiment of the present application. As shown in Figure 9, the method includes:
[0165] 901. Acquire an image.
[0166] In this embodiment, when it is necessary to train the first model to be trained, the second model to be trained, and the third model to be trained, a batch of training data can be obtained first. It is worth noting that the training data can be obtained from three data sets, the first data set is a detection data set (detection dataset), the second data set is a visual positioning data set (grounding dataset), and the third data set is an image-text pair dataset (image-text pair datasetr). Among them, a detection data refers to an image, which carries multiple detection frames and multiple texts, one detection frame corresponds to a text (word or phrase), and the text carried by a detection frame is used to describe the category of the detection frame (the object in it). A visual positioning data refers to an image and multiple parallel sentences (each sentence can be divided into multiple texts, that is, divided into multiple words or phrases), the image carries multiple detection frames, one detection frame corresponds to a text in this article, and the text corresponding to a detection frame is used to describe the category of the detection frame (the object in it). An image-text pair data refers to an image and a passage (this text can also be divided into multiple texts, that is, divided into multiple words or phrases), and this passage is used to describe the content in the image.
[0167] Before collecting a batch of training data from a detection dataset, visual positioning dataset, or image-text pair dataset, the raw data in the detection dataset, visual positioning dataset, or image-text pair dataset can be preprocessed, and then the preprocessed data can be collected as training data. The preprocessing process and the collection process include:
[0168] (1) For any detection data in the detection dataset, the data is an image. Assume that the image carries M detection frames (that is, M objects) and M texts. These M texts are used to describe the categories of these M detection frames. Since some of the M detection frames belong to the same category, that is, some of the M texts are the same, we can first extract these M texts from the image and merge them to obtain K different texts. These K texts are used to describe K different categories, where K is less than M.
[0169] Next, you can select an additional Q texts, which are used to describe an additional Q different categories. Then, the K texts obtained after merging and the additional Q texts can form the N texts corresponding to the image (N = K + Q, N is much smaller than M). These N texts are used to describe N different categories, of which K categories are categories that have appeared in the image (also called positive categories), and the other Q categories are categories that have not appeared in the image (also called negative categories). In this way, the image and the N texts corresponding to the image can be collected as a training data.
[0170] (2) For any visual positioning data in the visual positioning dataset, the data is an image and multiple sentences. Assume that the image carries M detection frames. M texts can be extracted from these multiple sentences. These M texts are used to describe the categories of these M detection frames. Since some of the M detection frames belong to the same category, that is, some of the M texts are the same, these M texts can be merged to obtain K different texts. These K texts are used to describe K different categories, where K is less than M.
[0171] Next, you can select an additional Q texts, which are used to describe an additional Q different categories. Then, the K texts obtained after merging and the additional Q texts can form a new N text corresponding to the image. These N texts are used to describe N different categories, where K categories appear in the image and the other Q categories do not appear in the image. In this way, the image and the N texts corresponding to the image can be collected as training data.
[0172] (3) For any image-text pair data in the image-text pair data set, the data is an image and a paragraph. Assuming that the image does not carry a detection frame, K different texts can be extracted from the paragraph. These K texts are used to describe K different categories (positive categories), where K is a positive integer greater than or equal to 1.
[0173] Next, you can select an additional Q texts, which are used to describe an additional Q different categories (negative categories). Then, the K texts obtained after merging and the additional Q texts can form a new N text corresponding to the image. These N texts are used to describe N different categories, where K categories appear in the image and the other Q categories do not appear in the image. In this way, the image and the N texts corresponding to the image can be collected as training data.
[0174] Then, by repeating the above process continuously, a batch of training data can be successfully collected. This batch of training data either comes from the detection dataset, or comes from the visual positioning dataset, or comes from the image-text pair dataset.
[0175] 902. Input the image into a first model to be trained to obtain a first processing result of the image and a second processing result of the image, wherein the first model to be trained is used to: encode the image to obtain an encoding result of the image; process the encoding result to obtain a first processing result of the image, and the first processing result is used to determine the positions of M objects in the image, M≥1; process the encoding result and the first processing result to obtain a second processing result of the image, and the second processing result is used to determine the categories of the M objects.
[0176] After obtaining a batch of training data, for any training data in this batch, the training data can be input into the joint training framework, which can perform the following operations:
[0177] (1) The image in the training data is input into the first model to be trained. The first model to be trained may first encode the image to obtain an encoding result of the image. Then, the first model to be trained may process the encoding result of the image to obtain a first processing result of the image. The first processing result of the image is used to determine the positions of M detection frames in the image, where M≥1. Then, the first model to be trained may process the encoding result of the image and the first processing result of the image to obtain a second processing result of the image. The second processing result of the image is used to determine the categories of the M detection frames.
[0178] In one possible implementation, the first model to be trained is used to encode the image to obtain first features of M detection frames in the image, and the first features of the M detection frames serve as encoding results of the image.
[0179] In one possible implementation, the first model to be trained is used to process the first features of the M detection frames based on a multi-layer perceptron to obtain the second features of the M detection frames, and the second features of the M detection frames serve as the first processing results of the image.
[0180] In one possible implementation, the first processing result includes the coordinates of the boundary points of the M detection frames in the image, or the first processing result includes the sizes of the M detection frames and the coordinates of the center points of the M detection frames in the image.
[0181] In one possible implementation, the first model to be trained is used to: perform deformable convolution on the second features of M detection frames to obtain third features of the M detection frames; fuse the first features of the M detection frames and the third features of the M detection frames to obtain fourth features of the M detection frames; process the fourth features of the M detection frames to obtain fifth features of the M detection frames, and the fifth features of the M detection frames serve as the second processing result of the image. The processing of the fourth feature includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
[0182] It should be noted that, regarding the process of the first model to be trained obtaining the first processing result of the image and the second processing result of the image, please refer to the relevant description parts of steps 502 to 504 in the embodiment shown in Figure 5, which will not be repeated here.
[0183] (2) The N texts corresponding to the images in the training data can also be input into the second model to be trained, so that the second model to be trained can encode the N texts to obtain the features of the N texts (which can also be called the encoding results of the N texts).
[0184] For example, as shown in Figure 10 (Figure 10 is another structural diagram of the joint training framework provided in an embodiment of the present application, and Figure 10 is drawn based on Figures 6 and 7), for an image and N texts corresponding to the image, the image can be input into the image encoder module, and the N texts can be input into the text encoder module at the same time.
[0185] Then, the image encoder module, MLP module, deformable module and cls module can jointly process the image to obtain the new regional feature f P (The process can be referred to the example in Figure 6 and will not be described here.) At the same time, the text encoder module can also encode N texts to obtain the text feature f T , where f T Including the features of the first text corresponding to the image, the features of the second text, ... the features of the Nth text.
[0186] (3) After obtaining the fourth features of the M detection frames, the first model to be trained can also send the fourth features of the M detection frames to the third model to be trained. After obtaining the features of the N texts, the second model to be trained can also send the features of the N texts to the third model to be trained. Then, the third model to be trained can match the features of the N texts and the fourth features of the M detection frames to obtain the matching degree between the N texts and the M detection frames (for any one of the M detection frames, the matching degree between the detection frame and the N texts is the probability that the detection frame belongs to N categories). Then, the third model to be trained can use the matching degree between the N texts and the M detection frames as the third processing result of the image and output it to the outside.
[0187] If the training data comes from detection data or visual positioning data, no processing is performed.
[0188] If the training data comes from image-text pair data, the matching degrees between N texts and M detection boxes can be aggregated to obtain the matching degrees between the N texts and the image. Then, the matching degrees between the N texts and the image can be used as the fourth processing result of the image.
[0189] As in the above example, the cls module gets f P After that, f P Sent to the matching module, the text encoder module gets f T After that, f T Sent to the matching module.
[0190] Then, if the image and N texts come from detection data / grounding data, the matching module can P and f T Processing is performed to obtain the matching matrix S = f P Trabspose(f T ), S contains the matching degree between the first detection box and the first text, the matching degree between the first detection box and the second text, ..., the matching degree between the second detection box and the first text, ..., the matching degree between the Mth detection box and the Nth text.
[0191] If the image and N texts are derived from image-text pair data, after the matching matrix S is obtained, the matrix can be processed using the following formula:
[0192] In the above formula, is the feature of the j-th text (j=1,...N), is the new feature of the k-th detection box (k=1,...M), is the matching degree between the jth text and the kth detection box, m j is the number of the detection box that best matches the jth text. Then, based on formula (2), in the matching matrix S, the detection boxes that best match the N texts and the corresponding N matching degrees can be selected.
[0193] Then, the N matching degrees can be processed by the following formula:
[0194] In the above formula, is the new feature that best matches the j-th text, is the matching degree between the i-th image (the image) and the i-th article (the article corresponding to the image, and part of the N texts corresponding to the image come from the article) (in Figure 10, Expressed as The i-th image and the i-th paragraph constitute the i-th image-text pair data (i=1,...,G). When training the framework, since this batch of training data contains G image-text data, another matching matrix s can be obtained T , where s T Including the matching degree between the first image and the first paragraph of the article, the matching degree between the first image and the second paragraph of the article, ..., the matching degree between the second image and the first paragraph of the article, ..., the matching degree between the Gth image and the Gth paragraph of the article.
[0195] 903. Obtain a target loss based on the first processing result and the second processing result.
[0196] If the training data comes from detection data or visual positioning data, the first processing result of the image in the training data, the second processing result of the image, and the third processing result of the image are calculated using a preset loss function to obtain the target loss.
[0197] If the training data comes from image-text pair data, the first processing result of the image in the training data, the second processing result of the image, and the fourth processing result of the image are calculated using a preset loss function to obtain a target loss.
[0198] As in the above example, after the MLP module obtains and outputs the position information offset, it obtains the position information of the first detection frame in the image, the position information of the second detection frame, ..., the position information of the Mth detection frame. The offset can be calculated using the preset loss function to obtain the common center loss L CEN and the bounding box regression loss L REG .
[0199] The dense generation module obtains and outputs the category y1 of the first detection box, the category y2 of the second detection box, ..., the category y of the Mth detection box M After that, the category generation loss L can be calculated by the following preset loss function CAP :
[0200] L CAP =-log p(y t |Φ c (y τ<t , f P ) (4)
[0201] In the above formula, for any detection box, y t is the tth word in the category of the detection box, y τ<t The first to the t-1th word in the category of the detection box.
[0202] If the image comes from detection data / grounding data, since the true matching matrix S' of the image is known, that is, the true matching degree between the first detection box and the first text, the true matching degree between the first detection box and the second text, ..., the true matching degree between the second detection box and the first text, ..., the true matching degree between the Mth detection box and the Nth text is known, after the matching module obtains and outputs S, the preset loss function can be used to calculate S and S' to obtain the matching loss L ALIGN Then, the target loss L = L ALIGN +αL CEN +βL REG +γL CAP , where the α, β, and γ weights are hyperparameters.
[0203] If the image comes from image-text pair data, the matching loss L can be calculated using the following preset loss function: CTS :
[0204] Then, the target loss L = L CTS +αL CEN +βL REG +γL GAP .
[0205] 904. Train the first to-be-trained model based on the target loss to obtain a first model.
[0206] After obtaining the target loss, the parameters of the first model to be trained, the model parameters of the second model to be trained, and the model parameters of the third model to be trained can be updated based on the target loss to obtain the updated first model to be trained, the updated second model to be trained, and the updated third model to be trained, and the next batch of training data is obtained (i.e., step 901 is re-executed), and the updated first model to be trained, the updated second model to be trained, and the updated third model to be trained are continued to be trained based on the next batch of training data (i.e., steps 902 to 904 are re-executed) until the model training conditions are met (for example, the target loss reaches convergence, etc.), and the first model, second model, and third model shown in Figure 4 can be obtained.
[0207] It should be noted that the input of the first model during target detection is only an image, while the input of the model composed of the remaining modules in the first model except the dense generation module, the second model and the third model during target detection is an image and the text corresponding to the image.
[0208] The first model trained in the embodiment of the present application has specific image processing capabilities (target detection capabilities). Specifically, when target detection is required for an image, the image can be input into the first model. Then, the first model can first encode the image to obtain an encoding result of the image. Next, the first model can process the encoding result of the image to obtain a first processing result of the image. Then, the first model can process the encoding result of the image and the first processing result of the image to obtain a second processing result of the image. After obtaining the first processing result and the second processing result output by the first model, the first processing result can be used to determine the positions of M objects in the image, and the second processing result can be used to determine the categories of M objects in the image. At this point, target detection for the image is completed. In the above process, the input of the first model is only the image, and no text related to the image needs to be prepared, which can effectively reduce the cost of image processing. Moreover, the first model only needs to perform a series of processing on the image to complete target detection for the image. Less information needs to be processed, so the computational complexity of image processing can be reduced, thereby improving the efficiency of image processing.
[0209] Furthermore, the first model provided in the embodiment of the present application is trained based on a joint training framework, and its training data can be either detection data / grounding data with manually annotated boxes or image-text pair data without manually annotated boxes. The latter can use fine-grained image-text alignment to not only complete the matching between the detection box and the text, but also complete the matching between the image and the article, and can complete the model training with high quality. Therefore, the models finally trained (the first model, the second model, and the third model) all have excellent performance.
[0210] The above is a detailed description of the image processing method and model training method provided in the embodiment of the present application. The image device and model training device provided in the embodiment of the present application will be introduced below. Figure 11 is a structural schematic diagram of the image processing device provided in the embodiment of the present application. As shown in Figure 11, the first model is included. The device includes:
[0211] An acquisition module 1101 is used to acquire an image;
[0212] The encoding module 1102 is used to encode the image and obtain an encoding result of the image;
[0213] A first processing module 1103 is configured to process the encoding result to obtain a first processing result of the image, where the first processing result is used to determine positions of M objects in the image, where M≥1;
[0214] The second processing module 1104 is configured to process the encoding result and the first processing result to obtain a second processing result of the image, and the second processing result is used to determine the categories of the M objects.
[0215] In an embodiment of the present application, when target detection is required for an image, the image can be input into the first model. The first model can then first encode the image to obtain an encoding result for the image. Next, the first model can process the encoding result for the image to obtain a first processing result for the image. The first model can then process the encoding result and the first processing result for the image to obtain a second processing result for the image. After obtaining the first processing result and the second processing result output by the first model, the first processing result can be used to determine the locations of M objects in the image, and the second processing result can be used to determine the categories of the M objects in the image. At this point, target detection for the image is completed. In the aforementioned process, the input to the first model is only the image, and no text related to the image needs to be prepared. This effectively reduces the cost of image processing. Furthermore, the first model only needs to perform a series of processing on the image to complete target detection for the image. Less information needs to be processed, thereby reducing the computational complexity of image processing and improving image processing efficiency.
[0216] In a possible implementation, the encoding module 1102 is configured to encode an image to obtain first features of M objects in the image, and the first features of the M objects serve as encoding results of the image.
[0217] In one possible implementation, the first processing module 1103 is configured to perform multi-layer perceptron-based processing on the first features of the M objects to obtain the second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
[0218] In a possible implementation, the first processing result includes coordinates of boundary points of the M objects in the image, or the first processing result includes sizes of the M objects and coordinates of center points of the M objects in the image.
[0219] In one possible implementation, the second processing module 1104 is used to perform deformable convolution on the second features of M objects to obtain the third features of the M objects; fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects; process the fourth features of the M objects to obtain the fifth features of the M objects, and the fifth features of the M objects serve as the second processing results of the image. The processing of the fourth feature includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
[0220] FIG12 is a schematic diagram of a structure of a model training device provided in an embodiment of the present application. As shown in FIG12 , the device includes:
[0221] A first acquisition module 1201 is used to acquire an image;
[0222] A first processing module 1202 is configured to input an image into a first model to be trained to obtain a first processing result of the image and a second processing result of the image, wherein the first model to be trained is configured to: encode the image to obtain an encoding result of the image; process the encoding result to obtain a first processing result of the image, the first processing result being used to determine positions of M objects in the image, where M ≥ 1; and process the encoding result and the first processing result to obtain a second processing result of the image, the second processing result being used to determine categories of the M objects;
[0223] A second acquisition module 1203 is configured to acquire a target loss based on the first processing result and the second processing result;
[0224] The first training module 1204 is used to train the first to-be-trained model based on the target loss to obtain a first model.
[0225] The first model trained in the embodiment of the present application has specific image processing capabilities (target detection capabilities). Specifically, when target detection is required for an image, the image can be input into the first model. Then, the first model can first encode the image to obtain an encoding result of the image. Next, the first model can process the encoding result of the image to obtain a first processing result of the image. Then, the first model can process the encoding result of the image and the first processing result of the image to obtain a second processing result of the image. After obtaining the first processing result and the second processing result output by the first model, the first processing result can be used to determine the positions of M objects in the image, and the second processing result can be used to determine the categories of M objects in the image. At this point, target detection for the image is completed. In the above process, the input of the first model is only the image, and no text related to the image needs to be prepared, which can effectively reduce the cost of image processing. Moreover, the first model only needs to perform a series of processing on the image to complete target detection for the image. Less information needs to be processed, so the computational complexity of image processing can be reduced, thereby improving the efficiency of image processing.
[0226] In one possible implementation, the first model to be trained is used to encode an image to obtain first features of M objects in the image, and the first features of the M objects are used as encoding results of the image.
[0227] In one possible implementation, the first model to be trained is used to process the first features of M objects based on a multi-layer perceptron to obtain the second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
[0228] In a possible implementation, the first processing result includes coordinates of boundary points of the M objects in the image, or the first processing result includes sizes of the M objects and coordinates of center points of the M objects in the image.
[0229] In one possible implementation, the first model to be trained is used to: perform deformable convolution on the second features of M objects to obtain the third features of the M objects; fuse the first features of the M objects and the third features of the M objects to obtain the fourth features of the M objects; process the fourth features of the M objects to obtain the fifth features of the M objects, and the fifth features of the M objects serve as the second processing result of the image. The processing of the fourth feature includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
[0230] In one possible implementation, the device also includes: a third acquisition module, used to acquire N texts, where the N texts are used to describe N different categories, M≥N≥1; a second processing module, used to encode the N texts through a second model to be trained to obtain features of the N texts; a third processing module, used to match the features of the N texts and the fourth features of the M objects through a third model to be trained to obtain a matching degree between the N texts and the M objects, and the matching degree between the N texts and the M objects is used as a third processing result of the image; a second acquisition module 1203, used to obtain a target loss based on the first processing result, the second processing result, and the third processing result.
[0231] In one possible implementation, the device also includes: a fourth processing module, used to aggregate the matching degrees between N texts and M objects to obtain the matching degrees between N texts and images, and the matching degrees between N texts and images serve as the fourth processing result of the image; a second acquisition module 1203, used to obtain the target loss based on the first processing result, the second processing result and the fourth processing result.
[0232] In one possible implementation, the device further includes: a second training module, configured to train the second model to be trained and the third model to be trained based on the target loss to obtain the second model and the third model.
[0233] It should be noted that the information interaction, execution process, etc. between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the embodiment of the present application, and no further details will be given here.
[0234] The embodiment of the present application also relates to an execution device, and Figure 13 is a structural diagram of the execution device provided by the embodiment of the present application. As shown in Figure 13, the execution device 1300 can be specifically manifested as a mobile phone, a tablet, a laptop computer, an intelligent wearable device, a server, etc., which are not limited here. Among them, the image processing device described in the embodiment corresponding to Figure 11 can be deployed on the execution device 1300 to implement the image processing function in the embodiment corresponding to Figure 5. Specifically, the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303 and a memory 1304 (wherein the number of processors 1303 in the execution device 1300 can be one or more, and Figure 13 takes one processor as an example), wherein the processor 1303 may include an application processor 13031 and a communication processor 13032. In some embodiments of the present application, the receiver 1301, the transmitter 1302, the processor 1303 and the memory 1304 can be connected via a bus or other means.
[0235] Memory 1304 may include read-only memory and random access memory, and provides instructions and data to processor 1303. A portion of memory 1304 may also include non-volatile random access memory (NVRAM). Memory 1304 stores processor and operation instructions, executable modules, or data structures, or subsets or extensions thereof. Operation instructions may include various operation instructions for implementing various operations.
[0236] Processor 1303 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all bus systems are referred to as a bus system in the figure.
[0237] The methods disclosed in the above embodiments of the present application can be applied to or implemented by processor 1303. Processor 1303 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in processor 1303. The above processor 1303 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1303 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 1304, and processor 1303 reads the information in memory 1304 and, in conjunction with its hardware, completes the steps of the above method.
[0238] Receiver 1301 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 1302 can be used to output digital or character information through the first interface. Transmitter 1302 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 1302 can also include a display device such as a display screen.
[0239] In an embodiment of the present application, in one case, the processor 1303 is used to obtain the image processing result through the first model in the embodiment corresponding to Figure 5.
[0240] The present application also relates to a training device. FIG14 is a schematic diagram of the structure of the training device provided by the present application. As shown in FIG14 , the training device 1400 is implemented by one or more servers. The training device 1400 may vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1414 (e.g., one or more processors) and memory 1432, and one or more storage media 1430 (e.g., one or more mass storage devices) storing application programs 1442 or data 1444. The memory 1432 and storage medium 1430 may be temporary storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown), each module may include a series of instruction operations in the training device. Furthermore, the CPU 1414 may be configured to communicate with the storage medium 1430 to execute the series of instruction operations in the storage medium 1430 on the training device 1400.
[0241] The training device 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458; or, one or more operating systems 1441, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0242] Specifically, the training device can execute the model training method in the embodiment corresponding to Figure 10.
[0243] An embodiment of the present application also relates to a computer storage medium, which stores a program for signal processing. When the computer storage medium is run on a computer, it enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
[0244] An embodiment of the present application also relates to a computer program product, which stores instructions that, when executed by a computer, enable the computer to execute the steps executed by the aforementioned execution device, or enable the computer to execute the steps executed by the aforementioned training device.
[0245] The execution device, training device or terminal device provided in the embodiments of the present application can specifically be a chip, and the chip includes: a processing unit and a communication unit, the processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, a pin or a circuit, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0246] Specifically, see Figure 15 , which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip may be a neural network processor (NPU) 1500. NPU 1500 is mounted on a host CPU (host CPU) as a coprocessor, with tasks assigned by the host CPU. The core of the NPU is arithmetic circuit 1503, which is controlled by controller 1504 to extract matrix data from memory and perform multiplication operations.
[0247] In some implementations, arithmetic circuit 1503 includes multiple processing units (PEs). In some implementations, arithmetic circuit 1503 is a two-dimensional systolic array. Arithmetic circuit 1503 can also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, arithmetic circuit 1503 is a general-purpose matrix processor.
[0248] For example, assume there are input matrix A, weight matrix B, and output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from weight memory 1502 and caches it on each PE in the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from input memory 1501 and performs a matrix operation on matrix B. The partial or final matrix result is stored in accumulator 1508.
[0249] Unified memory 1506 is used to store input and output data. Weight data is directly transferred to weight memory 1502 through the Direct Memory Access Controller (DMAC) 1505. Input data is also transferred to unified memory 1506 through the DMAC.
[0250] BIU stands for Bus Interface Unit, i.e., bus interface unit 1513 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1509 .
[0251] The bus interface unit 1513 (BIU) is used for the instruction fetch memory 1509 to obtain instructions from the external memory, and is also used for the storage unit access controller 1505 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0252] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1506 or transfer weight data to the weight memory 1502 or transfer input data to the input memory 1501.
[0253] The vector calculation unit 1507 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1503, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of the predicted label plane.
[0254] In some implementations, the vector calculation unit 1507 can store the processed output vector to the unified memory 1506. For example, the vector calculation unit 1507 can apply a linear function or a nonlinear function to the output of the operation circuit 1503, such as linear interpolation of the predicted label plane extracted by the convolution layer, or another example is a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1507 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1503, for example, for use in subsequent layers in a neural network.
[0255] An instruction fetch buffer 1509 connected to the controller 1504 is used to store instructions used by the controller 1504;
[0256] Unified memory 1506, input memory 1501, weight memory 1502, and instruction fetch memory 1509 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0257] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
[0258] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0259] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by special hardware including application-specific integrated circuits, special CPUs, special memories, special components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits or special circuits, etc. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0260] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0261] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. An image processing method, characterized in that: The method is implemented by a first model, and the method comprises: Get the image; Encoding the image to obtain an encoding result of the image; Processing the encoding result to obtain a first processing result of the image, where the first processing result is used to determine positions of M objects in the image, where M≥1; The encoding result and the first processing result are processed to obtain a second processing result of the image, where the second processing result is used to determine categories of the M objects.
2. The method according to claim 1, characterized in that: The step of encoding the image to obtain an encoding result of the image comprises: The image is encoded to obtain first features of M objects in the image, and the first features of the M objects are used as encoding results of the image.
3. The method according to claim 1 or 2, characterized in that: The processing of the encoding result to obtain a first processing result of the image includes: The first features of the M objects are processed based on a multilayer perceptron to obtain second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
4. The method according to any one of claims 1 to 3, characterized in that: The first processing result includes the coordinates of the boundary points of the M objects in the image, or the first processing result includes the sizes of the M objects and the coordinates of the center points of the M objects in the image.
5. The method according to any one of claims 1 to 4, characterized in that: The processing of the encoding result and the first processing result to obtain a second processing result of the image includes: Performing deformable convolution on the second features of the M objects to obtain third features of the M objects; fusing the first features of the M objects and the third features of the M objects to obtain fourth features of the M objects; The fourth features of the M objects are processed to obtain fifth features of the M objects, and the fifth features of the M objects are used as the second processing result of the image. The processing of the fourth features includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
6. A model training method, characterized in that: The method comprises: Get the image; Input the image into a first model to be trained to obtain a first processing result of the image and a second processing result of the image, wherein the first model to be trained is used to: encode the image to obtain an encoding result of the image; process the encoding result to obtain a first processing result of the image, the first processing result is used to determine the positions of M objects in the image, M≥1; process the encoding result and the first processing result to obtain a second processing result of the image, the second processing result is used to determine the categories of the M objects; Obtaining a target loss based on the first processing result and the second processing result; The first to-be-trained model is trained based on the target loss to obtain a first model.
7. The method according to claim 6, characterized in that The first model to be trained is used to encode the image to obtain first features of M objects in the image, and the first features of the M objects are used as encoding results of the image.
8. The method according to claim 6 or 7, characterized in that: The first model to be trained is used to process the first features of the M objects based on a multi-layer perceptron to obtain second features of the M objects, and the second features of the M objects are used as the first processing results of the image.
9. The method according to any one of claims 6 to 8, characterized in that: The first processing result includes the coordinates of the boundary points of the M objects in the image, or the first processing result includes the sizes of the M objects and the coordinates of the center points of the M objects in the image.
10. The method according to any one of claims 6 to 9, characterized in that: The first model to be trained is used to: Performing deformable convolution on the second features of the M objects to obtain third features of the M objects; fusing the first features of the M objects and the third features of the M objects to obtain fourth features of the M objects; The fourth features of the M objects are processed to obtain fifth features of the M objects, and the fifth features of the M objects are used as the second processing result of the image. The processing of the fourth features includes at least one of the following: processing based on a self-attention mechanism, processing based on an interactive attention mechanism, and full connection.
11. The method according to any one of claims 6 to 10, characterized in that: The method further comprises: Obtain N texts, where the N texts are used to describe N different categories, M≥N≥1; Encoding N texts by using a second model to be trained to obtain features of the N texts; Matching the features of the N texts and the fourth features of the M objects by using a third model to be trained to obtain a matching degree between the N texts and the M objects, and using the matching degree between the N texts and the M objects as a third processing result of the image; The acquiring the target loss based on the first processing result and the second processing result includes: A target loss is obtained based on the first processing result, the second processing result, and the third processing result.
12. The method according to claim 11, characterized in that The method further comprises: Aggregating the matching degrees between the N texts and the M objects to obtain the matching degrees between the N texts and the image, and using the matching degrees between the N texts and the image as the fourth processing result of the image; The acquiring the target loss based on the first processing result and the second processing result includes: A target loss is obtained based on the first processing result, the second processing result, and the fourth processing result.
13. The method according to claim 11 or 12, characterized in that: The method further comprises: The second model to be trained and the third model to be trained are trained based on the target loss to obtain a second model and a third model.
14. An image processing device, characterized in that: The device comprises a first model, the device comprising: An acquisition module, used for acquiring images; An encoding module, used for encoding the image to obtain an encoding result of the image; A first processing module, used for processing the encoding result to obtain a first processing result of the image, wherein the first processing result is used to determine the positions of M objects in the image, where M≥1; The second processing module is used to process the encoding result and the first processing result to obtain a second processing result of the image, and the second processing result is used to determine the categories of the M objects.
15. A model training device, characterized in that: The device comprises: A first acquisition module, used for acquiring an image; A first processing module is used to input the image into a first model to be trained to obtain a first processing result of the image and a second processing result of the image, wherein the first model to be trained is used to: encode the image to obtain an encoding result of the image; process the encoding result to obtain a first processing result of the image, the first processing result is used to determine the positions of M objects in the image, M≥1; process the encoding result and the first processing result to obtain a second processing result of the image, the second processing result is used to determine the categories of the M objects; A second acquisition module, configured to acquire a target loss based on the first processing result and the second processing result; The first training module is used to train the first model to be trained based on the target loss to obtain a first model.
16. An image processing device, characterized in that: The device includes a memory and a processor; the memory stores codes, and the processor is configured to execute the codes. When the codes are executed, the image processing device performs the method according to any one of claims 1 to 13.
17. A computer storage medium, characterized in that The computer storage medium stores one or more instructions, which, when executed by one or more computers, enable the one or more computers to implement the method of any one of claims 1 to 13.
18. A computer program product, characterized in that The computer program product stores instructions, which, when executed by a computer, enable the computer to implement the method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Image processing method and related equipment thereof
CN116343004A
Video group behavior recognition method based on cascade Transformer
CN113673489A
Neural network, target detection method, neural network training method and related products
CN113807361A
Image detection method and device, electronic equipment and storage medium
CN114663670A
Cognitive network, method for training cognitive network, and object recognition method and apparatus
WO2022217434A1
Cited By
Image processing method and related device thereof
EP4664420A4
