Target detection system, method, device, equipment and medium

By using the control module and co-processor in the target detection system to share the computing tasks of the target detection model, the problem in the existing technology that it is difficult to balance accuracy and real-time when deploying target detection models is solved, and more efficient target detection is achieved. Effect.

CN117152582BActive Publication Date: 2024-10-29CHINA GREATWALL TECH GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311039050.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-16
Publication Date
2024-10-29
Estimated Expiration
2043-08-16

AI Technical Summary

Technical Problem

It is difficult to balance accuracy and real-time performance when deploying existing target detection models. The increase in the number of model layers leads to increased calculation time, and simply streamlining the model structure will result in a loss of accuracy.

Method used

The control module and co-processor are used to share the computing tasks of the target detection model. The control module and co-processor are used to perform part of the calculations of the target detection model respectively. Combining the hardware performance advantages of the two to achieve both real-time and accuracy of target detection.

Benefits of technology

By decomposing computing tasks and executing them on the control module and co-processor respectively, the real-time and accuracy of target detection is improved, and the problem of slow execution in model deployment is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117152582B_ABST
    Figure CN117152582B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of machine learning technology, and provides a target detection system, method, device, equipment and medium. The device includes: a control module and a coprocessor, and the control module and the coprocessor are communicatively connected; the control module is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the coprocessor; the coprocessor is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the control module. The present application uses the control module and the coprocessor to respectively perform a part of the operation in the target detection model, so as to solve the problem that the target detection task is executed slowly during the deployment of the target detection model. Specifically, by decomposing the operation tasks in the target detection model and handing them over to the control module and the coprocessor for operation respectively, it is possible to combine the advantages of the two in hardware performance and take into account the real-time and accuracy of target detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of machine learning technology, and in particular, relates to target detection systems, methods, devices, equipment and media. Background Art

[0002] Object detection is one of the core issues in the field of computer vision. Its task is to find all the objects of interest in the image and determine their categories and locations. In recent years, with the rapid development of machine learning technology, object detection has achieved remarkable results and is increasingly used in many fields such as autonomous driving, intelligent transportation, industrial quality inspection, target tracking and face detection. It is understandable that for some fields, the accuracy and real-time performance of object detection tasks are particularly important.

[0003] To improve the accuracy of target detection, a feasible method is to increase the complexity of the target detection model and improve the accuracy of feature extraction of the target detection model. However, as the number of layers of the target detection model increases, the parameter scale increases, and the computational time will increase significantly.

[0004] On the contrary, simply streamlining the model structure can improve the inference speed, but the accuracy will inevitably be lost.

[0005] Therefore, there is an urgent need to provide a method that can balance accuracy and real-time performance when executing target detection tasks. Summary of the invention

[0006] The embodiments of the present application provide a target detection system, method, apparatus, device and medium, which can solve the problem of balancing the accuracy and real-time performance of target detection.

[0007] In a first aspect, an embodiment of the present application provides a target detection system, including a control module and a coprocessor, wherein the control module and the coprocessor are communicatively connected;

[0008] The control module is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the coprocessor to obtain one or more first results, wherein the first result includes a data result for sending to the coprocessor;

[0009] The coprocessor is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the control module to obtain one or more second results, wherein the second result includes a data result for sending to the control module;

[0010] Among them, the target detection model is a machine learning model obtained after the initial model is trained according to samples; among the first result and the second result, there is at least one data result for obtaining the target detection result of the target image to be detected.

[0011] In a possible implementation of the first aspect, the initial model includes a first sampling module, which is used to extract image features, and the first sampling module includes at least two convolution branches of different sizes; the target detection model includes a second sampling module, which is obtained by fusing the convolution branches of the first sampling module.

[0012] In a possible implementation of the first aspect, the control module is also used to send an operation instruction to the coprocessor; the coprocessor is used to execute the operation of the target detection model instruction part according to the operation instruction to obtain the second result; wherein the operation instruction corresponds one-to-one to the instruction part.

[0013] In a possible implementation of the first aspect, the coprocessor includes an instruction memory, and the instruction memory is used to store the operation instruction.

[0014] In a possible implementation of the first aspect, the second result also includes a data result used as an input parameter to perform at least a portion of the operation of the target detection model.

[0015] In a possible implementation of the first aspect, the coprocessor includes a tensor memory; the tensor memory is used to store:

[0016] a first result in tensor form sent by the control module to the coprocessor; and / or,

[0017] A second result in tensor form for performing at least a portion of the operations of the object detection model.

[0018] In a possible implementation of the first aspect, the coprocessor further includes a cocontroller, and the cocontroller can be used to decode the operation instruction in the instruction memory to obtain instruction decoding information.

[0019] In a possible implementation of the first aspect, the coprocessor also includes an operation unit, which is used to call the data in the tensor memory as input data, perform the operation of the target detection model instruction part according to the instruction decoding information, obtain the second result and write it into the tensor memory.

[0020] In a possible implementation of the first aspect, the convolution branch includes a first type of branch, and the first type of branch includes a convolution layer and a normalization layer connected in sequence.

[0021] In a possible implementation of the first aspect, the coprocessor includes a computing unit, wherein the computing unit includes a convolution subunit for performing convolution layer operations in the first type of branches.

[0022] In a possible implementation of the first aspect, the convolution subunit is composed of a preset number of multiplier-adder arrays, and the preset number matches the feature map size of the target detection model.

[0023] In a possible implementation of the first aspect, the coprocessor includes a computing unit, the computing unit includes a post-processing sub-unit, and the post-processing sub-unit can be used to perform operations of a normalization layer in the first type of branches.

[0024] In a possible implementation of the first aspect, the convolution branch includes a second type of branch, where the second type of branch is a directly connected branch, and the directly connected branch is used to map a value of an input end of the directly connected branch to an output end of the directly connected branch.

[0025] In a possible implementation of the first aspect, the coprocessor includes a computing unit, wherein the computing unit includes a direct connection sub-unit for executing direct connection operations in the second type of branches.

[0026] In a possible implementation of the first aspect, the directly connected subunit is composed of a shift register and a pipeline unit; through the shift register, a plurality of the pipeline units can cache neighborhood pixels and obtain a convolution result;

[0027] The pipeline unit is composed of a first number of multipliers and a second number of adders; wherein the first number is equal to the maximum value of the number of single-channel convolution kernel operations of any feature map in the target detection model; and the second number is equal to the number of convolution weights of the largest convolution kernel in the target detection model minus one.

[0028] In a possible implementation manner of the first aspect, the first sampling module includes:

[0029] A first downsampling structure consisting of two first-type branches; and,

[0030] The first feature extraction structure consists of two first-category branches and one second-category branch.

[0031] In a possible implementation of the first aspect, an output end of the first downsampling structure is connected to an activation function layer.

[0032] In a possible implementation of the first aspect, the coprocessor includes a computing unit, the computing unit includes a post-processing subunit, and the post-processing subunit can be used to perform operations on the activation function layer.

[0033] In a possible implementation of the first aspect, the initial network includes N dimensionality reduction layers connected in sequence, where N is an integer greater than 2; the N dimensionality reduction layers include:

[0034] A dimensionality reduction layer consisting of a single first downsampling structure;

[0035] A dimensionality reduction layer consisting of one of the first downsampling structures and two of the first feature extraction structures connected in sequence; and

[0036] A dimensionality reduction layer is formed by sequentially connecting one of the first downsampling structures and three of the first feature extraction structures.

[0037] In a possible implementation manner of the first aspect, the initial network further includes: N dimensionality-raising layers connected in sequence, the N dimensionality-raising layers including:

[0038] A pooling layer consisting of a pooling layer, a CBL layer, and an upsampling layer connected in sequence;

[0039] A fusion dimension-raising layer consisting of a feature fusion layer, a CBL fusion layer, a CBL layer, and an upsampling layer connected in sequence;

[0040] An output layer consisting of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; and,

[0041] The output layer consists of a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence;

[0042] The CBL fusion layer includes a first CBL branch, a second CBL branch and a CBL fusion output structure, the output ends of the first CBL branch and the second CBL branch are connected to the input end of the CBL fusion output structure; the first CBL branch and the second CBL branch are both composed of multiple CBL sub-layers, and the number of CBL sub-layers of the first CBL branch and the second CBL branch is different, and the CBL fusion output structure includes a feature fusion sub-layer and a CBL sub-layer connected in sequence.

[0043] In a possible implementation of the first aspect, for any value of i within the first specified range, the output end of the i-th dimensionality reduction layer is connected to the feature fusion layer in the j-th dimensionality increase layer, where i+j=N+1.

[0044] In a possible implementation of the first aspect, for any value of k within the second specified range, the output end of the CBL layer in the kth dimensionality-increasing layer is connected to the feature fusion layer in the lth dimensionality-increasing layer, where k+l=N+1.

[0045] In a possible implementation of the first aspect, the output layer is used to output the target detection result of a specified size; the output end of the Nth dimensionality reduction layer is connected to the input end of the pooling dimensionality increase layer, the fusion dimensionality increase layer is arranged after the pooling dimensionality increase layer, and the output layer is arranged after the fusion dimensionality increase layer.

[0046] In a possible implementation of the first aspect, the coprocessor further includes a cocontroller, which can be used to: execute training operations of the initial model according to instructions sent by the control module, obtain training results, and transmit them to the control module.

[0047] In a possible implementation manner of the first aspect, the control module can also be used to:

[0048] updating the parameters of the initial model according to the training results to obtain a trained initial model; and,

[0049] The convolution layer operation and the normalization layer operation of the first type of branch in the trained initial model are merged to obtain a merged branch.

[0050] In a possible implementation manner of the first aspect, the control module can also be used to:

[0051] Adjusting the convolution kernels of the merged branches in the first downsampling structure of the trained initial model to the same size in a first preset manner; and / or,

[0052] The merged branch and the second type of branch in the first feature extraction structure of the trained initial model are adjusted to a convolution structure with the same convolution kernel size in a second preset manner.

[0053] In a possible implementation of the first aspect, the computing unit includes a post-processing subunit, and the post-processing subunit includes a spare computing component, and the spare computing component can be used to perform a designated computing task of a non-convolution operation and a non-activation function operation.

[0054] In a possible implementation manner of the first aspect, the post-processing subunit is composed of the following components:

[0055] The first component used to convert an integer to a floating point number;

[0056] The second component for converting a floating point number to an integer;

[0057] a third component for performing floating point multiplication and addition operations; and,

[0058] The fourth component is used to perform activation function layer operations.

[0059] In a possible implementation of the first aspect, the tensor memory includes:

[0060] The storage space matches the input cache portion of the target image to be detected;

[0061] The storage space matches a feature cache portion of a feature map tensor, wherein the feature map tensor is at least a portion of output data of any dimensionality reduction layer or dimensionality increase layer of the object detection model;

[0062] A weight cache portion having a storage space matching the model weight parameter quantity of the target detection model; and,

[0063] The storage space matches the output cache portion of the target detection result of the specified size.

[0064] In a possible implementation of the first aspect, the co-controller can also be used to: store the second result calculated by the operation unit according to the instruction decoding information in a preset manner to the tensor memory according to the calculation result form information in the instruction decoding information, and the preset manner corresponds one-to-one to the calculation result form information.

[0065] In a possible implementation of the first aspect, storing, according to the calculation result form information in the instruction decoding information, the second result calculated by the operation unit according to the instruction decoding information in a preset manner to the tensor memory includes:

[0066] If it is determined that the calculation result form information in the instruction decoding information is a two-dimensional tensor, the second result in the form of a two-dimensional tensor calculated by the operation unit according to the instruction decoding information is stored in the tensor memory in sequence according to the order of channels, and the data of any channel is stored in the tensor memory in row-major order or column-major order.

[0067] In a possible implementation of the first aspect, storing, according to the calculation result form information in the instruction decoding information, the second result calculated by the operation unit according to the instruction decoding information in a preset manner to the tensor memory includes:

[0068] Determining that the calculation result form information in the instruction decoding information is a three-dimensional tensor, storing the second result in the three-dimensional tensor form calculated by the operation unit according to the instruction decoding information into a designated three-dimensional storage block of the tensor memory;

[0069] Among them, the three-dimensional storage block is a plurality of storage blocks preset in the tensor memory, the storage space of any of the three-dimensional storage blocks matches the three-dimensional feature map size of the target detection model, and the storage address of any bit in the three-dimensional storage block corresponds to the channel number, tile number and row and column number in the tile of the second result in the form of a three-dimensional tensor.

[0070] In a possible implementation manner of the first aspect, an image sensor is further included; the image sensor is used to read the target image to be detected or the sample, and transmit it to the control module.

[0071] In a second aspect, an embodiment of the present application provides a target detection method applied to a control module, comprising:

[0072] Acquire the target image to be detected;

[0073] Generate an operation instruction of a first specified structure corresponding to the target detection model, wherein the operation instruction is used to control the coprocessor to perform the operation task of the first specified structure;

[0074] Obtaining a second result, where the second result includes a calculation result of the first specified structure;

[0075] Performing an operation of a second specified structure of the target detection model according to the second result and / or the target image to be detected to obtain a first result;

[0076] Obtaining a target detection result of the target image to be detected according to the first result and / or the second result;

[0077] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0078] In a possible implementation of the second aspect, the first specified structure and the second specified structure constitute the target detection model.

[0079] In a possible implementation manner of the second aspect, after the step of acquiring the target image to be detected, the method includes:

[0080] The target image to be detected is color normalized and sent to the coprocessor.

[0081] In a possible implementation of the second aspect, the target detection model and the initial model both include a dimensionality reduction part, a dimensionality increase part, and a post-processing part connected in sequence;

[0082] The dimension reduction part is used to extract features from the target image to be detected to obtain multiple dimension reduction features; the dimension increase part is used to perform feature fusion on the dimension reduction features to obtain at least one dimension increase feature; the post-processing part is used to perform full connection operation on the dimension increase features and output the target detection result;

[0083] Among them, the dimensionality reduction part of the initial model includes a first sampling module, which includes at least two convolution branches of different sizes; the dimensionality reduction part of the target detection model includes a second sampling module, which is obtained by fusing the convolution branches of the first sampling module.

[0084] In a possible implementation manner of the second aspect, before the step of obtaining the second result, the step further includes:

[0085] generating a training instruction, wherein the training instruction is used to control the coprocessor to perform a sample-based training operation;

[0086] Acquire a training result, and update the parameters of the initial model according to the training result to obtain a trained initial model, wherein the training result is a result obtained by the coprocessor according to the training instruction;

[0087] The convolution layer operation and the normalization layer operation of the convolution branch in the trained initial model are merged to obtain an initial model with a merged branch.

[0088] In a possible implementation of the second aspect, after the step of merging the convolution layer operation and the normalization layer operation of the convolution branch in the trained initial model to obtain the initial model with the merged branch, the method further includes:

[0089] Perform the following steps to obtain the target detection model:

[0090] Adjusting the convolution kernels of the merged branches to the same size in a first preset manner; and / or,

[0091] The merged branch and the directly connected branch are adjusted to a convolution structure having the same convolution kernel size in a second preset manner.

[0092] In a possible implementation of the second aspect, after the step of obtaining the target detection model, the step further includes:

[0093] The model weight parameters of the target detection model are sent to the coprocessor.

[0094] In a possible implementation of the second aspect, the second specified structure includes a fully connected layer and / or a non-maximum suppression layer in a post-processing part of the target detection model.

[0095] In a third aspect, an embodiment of the present application provides a target detection method applied to a coprocessor, comprising:

[0096] Acquire an operation instruction generated by a control module corresponding to a first specified structure of a target detection model;

[0097] Performing an operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result; the second result is used as an input parameter for the control module to perform at least a part of the operation of the second specified structure of the target detection model; and / or is used as an input parameter to obtain the target detection result of the target image to be detected;

[0098] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0099] In a possible implementation of the third aspect, the first specified structure and the second specified structure constitute the target detection model.

[0100] In a possible implementation manner of the third aspect, before the step of acquiring the operation instruction generated by the control module corresponding to the first specified structure of the target detection model, the step further includes:

[0101] A training instruction is obtained, and a sample-based training operation is performed according to the training instruction to obtain a training result.

[0102] In a possible implementation manner of the third aspect, before the step of acquiring the operation instruction corresponding to the first specified structure of the target detection model generated by the control module, the step further includes:

[0103] Obtain model weight parameters of the target detection model, where the model weight parameters are used to perform operations of a first specified structure of the target detection model.

[0104] In a possible implementation manner of the third aspect, the target detection model and the initial model both include a dimensionality reduction part, a dimensionality increase part, and a post-processing part connected in sequence;

[0105] The dimension reduction part is used to extract features from the target image to be detected to obtain multiple dimension reduction features; the dimension increase part is used to perform feature fusion on the dimension reduction features to obtain at least one dimension increase feature; the post-processing part is used to perform full connection operation on the dimension increase features and output the target detection result;

[0106] Among them, the dimensionality reduction part of the initial model includes a first sampling module, which includes at least two convolution branches of different sizes; the dimensionality reduction part of the target detection model includes a second sampling module, which is obtained by fusing the convolution branches of the first sampling module.

[0107] In a possible implementation manner of the third aspect, the first designated structure includes:

[0108] The downsampling layer, feature extraction layer, normalization layer, direct connection branch and activation function layer in the dimension-increasing part of the target detection model; and,

[0109] The pooling layer, CBL layer, upsampling layer, feature fusion layer and activation function layer in the dimension reduction part of the target detection model.

[0110] In a possible implementation of the third aspect, the downsampling layer includes a convolution layer, a normalization layer, and an activation function layer; the feature extraction layer includes a convolution layer, a normalization layer, and a direct connection branch;

[0111] The step of performing the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result includes:

[0112] Determining that the operation instruction is the convolution layer operation, calling the convolution subunit to perform the operation;

[0113] Determining that the operation instruction is a direct branch operation, calling the direct subunit to perform the operation;

[0114] If it is determined that the operation instruction is a normalization layer operation or an activation function layer operation, the post-processing subunit is called to perform the operation.

[0115] In a fourth aspect, an embodiment of the present application provides a target detection control device, including:

[0116] A first acquisition component is used to acquire an image of a target to be detected;

[0117] An instruction component, used to generate an operation instruction of a first specified structure corresponding to the target detection model, wherein the operation instruction is used to control the coprocessor to perform the operation task of the first specified structure;

[0118] A second acquisition component is used to acquire a second result, wherein the second result includes a calculation result of the first specified structure;

[0119] A first operation component is used to perform an operation of a second specified structure of the target detection model according to the second result and / or the target image to be detected to obtain a first result;

[0120] A classification component, configured to obtain a target detection result of the target image to be detected according to the first result and / or the second result;

[0121] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0122] In a fifth aspect, an embodiment of the present application provides another target detection control device, including:

[0123] A third acquisition component is used to acquire an operation instruction corresponding to a first specified structure of the target detection model generated by the control module;

[0124] A second operation component is used to perform the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result; the second result is used as an input parameter for the control module to perform at least a part of the operation of the second specified structure of the target detection model; and / or is used as an input parameter to obtain the target detection result of the target image to be detected;

[0125] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0126] In the sixth aspect, an embodiment of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the target detection method described in any one of the second or third aspects above is implemented.

[0127] In the seventh aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the target detection method described in any one of the second or third aspects above.

[0128] In an eighth aspect, an embodiment of the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the target detection method described in any one of the second or third aspects above.

[0129] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:

[0130] The control module and the coprocessor are used to respectively execute a part of the operations in the target detection model, thereby solving the problem of slow execution of target detection tasks during the deployment of the target detection model.

[0131] Specifically, by decomposing the computational tasks in the target detection model and assigning them to the control module and the coprocessor for computation respectively, the advantages of both in hardware performance can be combined to take into account both the real-time and accuracy of target detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0132] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0133] Figure 1 is a first architecture diagram of a target detection system provided in an embodiment of the present application;

[0134] Figure 2 is a schematic diagram comparing the architectures of the first sampling module and the second sampling module provided in an embodiment of the present application;

[0135] Figure 3 is a first architecture diagram of a coprocessor provided in an embodiment of the present application;

[0136] Figure 4 is a schematic diagram of the architecture of a first downsampling structure provided in an embodiment of the present application;

[0137] Figure 5 is a schematic diagram of the architecture of a first feature extraction structure provided in an embodiment of the present application;

[0138] Figure 6 is a schematic diagram of a target detection network architecture provided by an embodiment of the present application;

[0139] Figure 7 is a schematic diagram of fusion operation provided in an embodiment of the present application;

[0140] Figure 8 It is a schematic diagram of the architecture of the pooling dimension-raising layer and the fusion dimension-raising layer provided in the embodiment of the present application;

[0141] Fig. 9 is a schematic diagram of a second architecture of a coprocessor provided in an embodiment of the present application;

[0142] Fig.10 is a second architecture diagram of the target detection system provided in an embodiment of the present application;

[0143] Fig.11 is a flow chart of a target detection method applied to a control module provided in an embodiment of the present application;

[0144] Fig.12 is a flow chart of a target detection method applied to a coprocessor provided in an embodiment of the present application;

[0145] Fig.13 is a schematic structural diagram of a first target detection device provided in an embodiment of the present application;

[0146] Fig.14is a structural schematic diagram of a second target detection device provided in an embodiment of the present application;

[0147] Fig.15 It is a schematic diagram of the structure of the terminal device provided in an embodiment of the present application.

[0148] Figure numerals: control module 110; coprocessor 120; instruction memory 121; cocontroller 122; operation unit 123; tensor memory 124; input / output module 125; sensor 130; first sampling module 210; first downsampling structure 211; first feature extraction structure 212; second sampling module 220; activation function layer 230; pooling dimension layer 810; fusion dimension layer 820; first acquisition component 1310; instruction component 1320; second acquisition component 1330; first operation component 1340; classification component 1350; third acquisition component 1410; second operation component 1420; terminal device 150; processor 1501; memory 1502; computer program 1503. DETAILED DESCRIPTION

[0149] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0150] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0151] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0152] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0153] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.

[0154] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0155] Object detection is an important task in computer vision, which aims to identify and locate specific objects in images or videos. It plays a key role in many applications, such as autonomous driving, object recognition, video surveillance, and face detection. In the past few decades, the field of object detection has experienced significant development, gradually shifting from traditional methods based on hand-crafted features to methods based on neural networks.

[0156] In other words, using machine learning models, especially deep learning models based on neural networks, is an effective method for target detection.

[0157] For target detection networks, the more layers and the larger the parameter scale, the higher the accuracy. However, for chips, sometimes because their deployment environment is at the edge and the computing power requirements are not high, if a network with a very large number of parameters is deployed, the actual reasoning cannot meet the real-time requirements. Therefore, for neural network structures with huge parameter amounts and the growing AI computing task requirements in edge scenarios, how to achieve a balance between computing power and accuracy has become an urgent problem that needs to be solved.

[0158] A feasible solution is to use a lightweight network to solve the above problems. This solution essentially takes into account the issue of execution efficiency.

[0159] Execution efficiency refers to the unity of the model's computing speed and its prediction accuracy. The standards for evaluating algorithm execution efficiency are divided into the algorithm model's spatial complexity, time complexity, and the algorithm's memory access size.

[0160] When chips are deployed at various edge terminals such as smart security, autonomous driving, smart home, wearable smart devices, etc., although the deployment scenarios are different, target detection tasks are the most common tasks. How to better utilize deep neural network models has become the hottest issue at present.

[0161] For chips deployed in various edge environments, the performance of the target detection network determines the execution efficiency of target detection. However, existing solutions often ignore the compatibility issues between hardware structure (such as chips) and the network.

[0162] Therefore, it is possible to consider establishing a (relatively lightweight) target detection network inside the chip, and then adding a neural coprocessor 120 through an external hardware system to specifically process network parameters to compensate for the problem of decreased accuracy after lightweighting, which can greatly improve the execution efficiency of the network.

[0163] Some embodiments of the present application are aimed at the hardware and software collaborative design of AI chip target detection, and provide a relatively lightweight target detection network (i.e., target detection model). Although the lightweight network will reduce the recognition accuracy of the overall network, the real-time performance will be greatly improved. Then, in order to compensate for the problem of decreased recognition accuracy of the lightweight network, a hardware structure is proposed to add a neural coprocessor 120 to further improve the recognition accuracy of the target detection network.

[0164] It is worth noting that the "lightweight" of the target detection model is relative to the chip that executes the model operation. That is, the target detection model deployed on the edge scene is more "lightweight" (that is, the scale of the model weight parameters is smaller) than the target detection model deployed on the server side. For a specific application scenario, the scale of the model weight parameters of the deployed target detection model should match the hardware computing power in that scenario.

[0165] On this basis, by introducing specific hardware, the computing speed and accuracy / recall rate of the target detection model can be more positively affected.

[0166] Specifically, Figure 1 As shown, an embodiment of the present application provides a target detection system, including a control module 110 and a coprocessor 120, wherein the control module 110 and the coprocessor 120 are communicatively connected;

[0167] The control module 110 is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the coprocessor 120 to obtain one or more first results, wherein the first results include data results for sending to the coprocessor 120;

[0168] The coprocessor 120 is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the control module 110 to obtain one or more second results, wherein the second result includes a data result for sending to the control module 110;

[0169] Among them, the target detection model is a machine learning model obtained after the initial model is trained according to samples; among the first result and the second result, there is at least one data result for obtaining the target detection result of the target image to be detected.

[0170] In this embodiment, the control module 110 can obtain the target image to be detected, and the target image to be detected is the input data of the target detection. For the target detection system provided in this embodiment, the computing tasks of the target detection model (in some optional embodiments, it is a neural network model, which may also be referred to as a target detection network) are implemented on the control module 110 and the coprocessor 120 respectively. Therefore, reference may be made to Figure 1 For example, the target detection model is understood as being partially deployed on the control module 110 and partially deployed on the coprocessor 120 .

[0171] During the actual application of the system provided in this embodiment, the target detection model cannot be explicitly deployed in a physical space like other physical hardware, but is stored in the form of model weight parameters in the memory of the control module 110 and / or the coprocessor 120. Specifically, the storage method of the model weight parameters can be a first deployment method in which all the model weight parameters are stored in both the control module 110 and the coprocessor 120, or a second deployment method in which the model weight parameters of the first part are stored in the control module 110 and the coprocessor 120.

[0172] It is worth mentioning that this embodiment does not explicitly limit more computing units other than the control module 110 and the coprocessor 120, that is, in some optional implementations, more computing units may be included to cooperate in completing all operations of the target detection model.

[0173] For the first deployment mode, the control module 110 and the coprocessor 120 (other computing units are similar to these two) call the corresponding model weight parameters to complete at least part of the operation of the target detection model when performing their respective computing tasks. In this case, it can also be understood that the target detection model is deployed on the control module 110 and the coprocessor 120 at the same time (with Figure 1 The example provided is slightly different. In this case, the complete target detection model is deployed on both the control module 110 and the coprocessor 120, but only a part of it is called when performing operations).

[0174] The second deployment method is a preferred implementation mode of this embodiment. The respectively deployed model weight parameters strictly correspond to the computing tasks that the control module 110 and the coprocessor 120 need to perform. On this basis, the control module 110 and the coprocessor 120 have a faster model weight parameter retrieval speed.

[0175] Furthermore, based on the second deployment method, the specific tasks of the target detection model can be decomposed, and the model weight parameters described in the same category of operations can be stored at a specific address, so that the control module 110 and the coprocessor 120 can directly read the model weight parameters from the specific address when performing specific operation tasks.

[0176] Furthermore, which tasks are specifically processed by the control module 110 and the coprocessor 120 depends on the specific architecture of the target detection model, the hardware configuration of the control module 110 and the hardware configuration of the coprocessor 120, that is, the computing tasks of the target detection model executed by the control module 110 match the hardware configuration of the control module 110, and the computing tasks of the target detection model executed by the coprocessor 120 match the hardware configuration of the coprocessor 120 (other computing units are similar).

[0177] For example, for a target detection network, more convolution operations are required, so the coprocessor 120 can be configured as a graphics processing unit GPU with strong floating-point processing capabilities; for another example, for a target detection network with a higher number of channels / feature map dimensions, the coprocessor 120 can be configured as a tensor processing unit 123 TPU; for another example, for a specific target detection model, the coprocessor 120 can be configured as an application-specific integrated circuit ASIC (Application Specific Integrated Circuit).

[0178] In an optional implementation, more computing units including GPU, TPU, ASIC, FPGA, etc. may be utilized instead of being limited to the configuration of the control module 110 and the coprocessor 120, and the operation of the target detection model may be realized through the cooperation of more computing units.

[0179] As an example but not limitation, the control module 110 may be a micro-controller unit (MCU), and the coprocessor 120 may be a neural co-processor (NCP).

[0180] In the example based on MCU, NCP and target detection network, the division of labor between coprocessor 120 and control module 110 can be configured as follows: during inference, NCP performs intensive CNN backbone workload, while MCU only performs light-load pre-processing (such as color normalization) and post-processing (such as fully connected layers, non-maximum suppression, etc.).

[0181] Exemplarily, after the control module 110, i.e., the MCU, performs preprocessing operations (such as color normalization, noise elimination, etc.) on the target image to be detected, it obtains a first first result, and sends the first first result to the coprocessor 120, i.e., the NCP. The coprocessor 120 performs network operations (such as feature extraction, downsampling, normalization, etc.) to obtain one or more second results, and sends the second result to the MCU. The MCU can perform subsequent operations based on the second result to obtain a second first result and further obtain a target detection result, or obtain the target detection result through one or more of the second results.

[0182] In this example, for the coprocessor 120, the data sent by the control module 110 can be either the first result or the control instruction. Therefore, it can be understood that the above example uses the control module 110MCU as the main control unit and the coprocessor 120NCP as the main computing unit (i.e., the unit mainly used for calculations) to realize target detection.

[0183] In some other optional implementations, the master control and master calculation status of the two can be switched.

[0184] In this embodiment, the initial model can adopt Faster R-CNN, or SSD, YOLO v3 and other target detection models, and the trained model is obtained by training the target detection model with pre-acquired samples. The controller and the coprocessor 120 respectively perform a part of the operation on the target detection model, which can make up for the problem of slow execution efficiency of the target detection task caused by insufficient edge calculation examples when the target network model is deployed at the edge in some scenarios.

[0185] Optionally, after acquiring the target image to be detected, the control module 110 may perform preprocessing on the target image to be detected, such as color normalization, image scaling, etc. Color normalization can eliminate the unclear target outline caused by illumination or shadow during the acquisition process of the target image to be detected, and the influence of small difference from the surrounding environment. Image scaling can convert the acquired target image to be detected into a picture format and size suitable for target detection model operation.

[0186] As a preferred embodiment, the control module 110 performs light load processing in the target detection unit, such as classifying the acquired feature map to obtain the target detection result. By performing light load processing by the control module 110, the coprocessor 120 performs processing with a large amount of data, thereby improving the operation speed.

[0187] Further, for the example of MCU and NCP, the control module 110 and the coprocessor 120 can be connected through the SDIO / SPI interface, and the images and data are transmitted through the SDIO / SPI interface, and the high bandwidth function of the SDIO / SPI interface is used for real-time data transmission. A typical SDIO can provide a bandwidth of up to 500Mbps. For example, about 300FPS can be transmitted for a 256×256×3 image, and 1200FPS can be transmitted for a 128×128×3 image. For the relatively slow SPI, it still reaches 100Mbps, or an equivalent throughput of 60FPS for a 256×256×3 image.

[0188] The beneficial effects of this embodiment are:

[0189] The control module 110 and the coprocessor 120 are used to respectively execute a portion of the operations in the target detection model, thereby solving the problem of slow execution of target detection tasks during the deployment of the target detection model.

[0190] Specifically, by decomposing the computational tasks in the target detection model and assigning them to the control module 110 and the coprocessor 120 for computation respectively, the advantages of both in hardware performance can be combined to take into account both the real-time performance and accuracy of target detection.

[0191] According to the above embodiment, in yet another embodiment:

[0192] The initial model includes a first sampling module 210, which is used to extract image features, and the first sampling module 210 includes at least two convolution branches of different sizes; the target detection model includes a second sampling module 220, which is obtained by fusing the convolution branches of the first sampling module 210.

[0193] This embodiment provides a target detection model that decouples training and reasoning. During the training process, the model structure is a multi-branch structure. When the training is completed and enters the reasoning stage, the overall model structure can be equivalently converted into a single-branch structure through methods such as structural reparameterization for deployment and reasoning.

[0194] Figure 2 is an exemplary branch fusion diagram, Figure 2The first sampling module 210 on the left can be understood as a sampling unit with multiple branches in the initial model (it is worth noting that the non-sampling unit of the initial model can also have multiple branches). Figure 2 The second sampling module 220 on the right can be understood as a sampling unit with fused convolution branches formed after merging specified convolution branches after initial model training. The sampling unit with fused convolution branches constitutes at least a part of the target detection model.

[0195] The above embodiments mentioned that in some edge scenarios, due to factors such as cost and space, it may not be possible to deploy hardware systems with higher computing resources, thereby limiting the operation of heavy models (i.e., target detection models with large amounts of computation and parameters) on the hardware (heavy models will spend more time on these hardware for computational reasoning, resulting in unacceptable time to obtain target detection results).

[0196] However, if a lightweight model is simply deployed (correspondingly, a target detection model with less computation and parameters), the accuracy of the model will inevitably be sacrificed (in exchange for better computing speed). Therefore, this embodiment proposes an improvement on this issue, which decouples the training and reasoning processes of the target detection model. In the training part with lower real-time requirements, more branches are used to achieve better training effects. After the training is completed, these branches are fused to obtain a reasoning model with fewer branches. This fusion process is explained using a vivid but inaccurate metaphor. The fusion process is equivalent to simplifying the calculation process of multiple branches, which effectively reduces the amount of computation in the model reasoning process while obtaining equivalent results (in fact, there is a possibility that the accuracy of the calculation results will be slightly reduced after the fusion of multiple branches, which depends on the specific plan of branch fusion).

[0197] The benefits of this decoupled training approach are:

[0198] It can enhance the model's capabilities as much as possible during the training process. At the same time, since branches are merged during the reasoning process, the overall amount of calculation will be compressed, thereby reducing the time required for reasoning while ensuring the reasoning accuracy and recall rate.

[0199] According to any of the above embodiments, a series of embodiments will be provided below in which the control module 110 serves as a main control unit and the coprocessor 120 serves as a main computing unit.

[0200] An embodiment of the present application provides a target detection system, wherein the control module 110 is further used to send an operation instruction to the coprocessor 120; the coprocessor 120 is used to perform the operation of the target detection model instruction part according to the operation instruction to obtain the second result; wherein the operation instruction corresponds one-to-one to the instruction part.

[0201] Correspondingly, in an optional implementation of this embodiment, the coprocessor 120 includes an instruction memory 121, and the instruction memory 121 is used to store the operation instructions.

[0202] In this embodiment, when executing the target detection task, the control module 110 may generate and send a calculation instruction, and the coprocessor 120 may perform the calculation in the target detection model according to the calculation instruction to obtain the second result. The calculation instruction includes the instruction required by the coprocessor 120 when executing the target detection model.

[0203] In an optional embodiment, the coprocessor 120 does not need to consider the connection of computing tasks, but is controlled by the control module 110. The coprocessor 120 only needs to quickly execute specific computing tasks according to computing instructions, thereby improving the reasoning speed of the model to a certain extent.

[0204] The operation instructions are stored in the instruction memory 121. For a single target detection task, the coprocessor 120 can directly call the instructions in the instruction memory 121 to perform the operation. In an optional embodiment, the operation instructions have execution order information, that is, the control module 110 does not need to generate operation instructions in real time, but can generate multiple operation instructions with execution order at an appropriate time for the coprocessor 120 to call and execute the operation.

[0205] For example, the first operation instruction is used to control the coprocessor 120 to perform a downsampling operation, the second operation instruction is used to control the coprocessor 120 to perform a feature extraction operation, the third operation instruction is used to control the coprocessor 120 to perform another downsampling operation, and the fourth operation instruction is used to control the coprocessor 120 to perform another feature extraction operation.

[0206] The assistant controller 122 may sequentially execute four operation tasks in parallel or serially according to the first to fourth operation instructions to obtain four second results.

[0207] Figure 3 An optional hardware architecture of a coprocessor 120 is shown, which specifically includes an instruction memory 121, a tensor memory 124, a cocontroller 122 and an operation unit 123, wherein the instruction memory 121 interacts with the control module 110 and is used to store operation instructions, the cocontroller 122 can read and decode the operation instructions in the instruction memory 121, and control the operation unit 123 to perform a specified operation according to the parsing result (instruction decoding information), and the operation unit 123 can read the required input data from the tensor memory 124 before performing the operation, and can also store the operation result in the tensor memory 124 after performing the operation.

[0208] The beneficial effects of this command-controlled target detection method are:

[0209] On the one hand, the control module 110 can send a specified number of operation instructions at a specified time, thereby reducing the number of times data is transmitted between the control module 110 and the coprocessor 120. On the other hand, the cocontroller 122 reads the operation instructions in sequence through the independent instruction memory 121, which can reduce the address search time when reading instructions.

[0210] According to any of the above embodiments, a structural embodiment of the initial model branch and the target detection model fusion convolution branch will be provided below, and the specific operation process of the coprocessor 120 and the control module 110 will be explained.

[0211] An embodiment of the present application provides a target detection system, wherein the second result also includes a data result used as an input parameter to perform at least a portion of the operation of the target detection model.

[0212] Exemplarily, the second result may be a calculation result obtained after the convolution branch calculation is completed. The coprocessor 120 may continue to perform part of the operations of the target detection model based on the second result, or send the second result to the control module 110, and the control module 110 performs part of the operations in the target detection model based on the second result.

[0213] For the implementation method in which the control module 110 is used as the main control unit, computing tasks that require higher computing power (for example, convolution operations) can be handed over to the coprocessor 120 to complete, and in the target detection model, a second result may be the calculation basis of another second result. For example, the calculation result of a convolution (which may be an extracted feature map) may be the input parameter of another convolution operation, so some second results can be used as input parameters to execute at least part of the operation of the target detection model; for the calculation task at the end of the target detection model, the second result of the coprocessor 120 (in some cases, it may also be the control module 110) may correspond to a target detection result, and this type of second result (or first result) is used to obtain the data result of the target detection result of the target image to be detected.

[0214] It is worth noting that there may be multiple ways to obtain the target detection results. One optional way is to obtain multiple detection targets through multiple first results and / or second results, and then perform non-maximum suppression on the multiple detection targets to obtain the best detection target as the target detection result; another optional way is to obtain detection targets of different sizes through multiple first results and / or second results, and output all of these detection targets as target detection results; other optional implementation methods may combine the above two methods.

[0215] As an example but not limitation, for a solution that outputs multiple target detection results, the confidence level of each target detection result may also be output simultaneously.

[0216] It is understandable that some of the above embodiments provide solutions for performing complex convolution operations based on the coprocessor 120. In such solutions, the operation efficiency of the coprocessor 120 can be further improved by the following methods, namely:

[0217] The coprocessor 120 includes a tensor memory 124; the tensor memory 124 is used to store:

[0218] A first result in the form of a tensor sent by the control module 110 to the coprocessor 120; and / or,

[0219] A second result in tensor form for performing at least a portion of the operations of the object detection model.

[0220] Similar to the above implementation of the instruction memory 121, the independent tensor memory 124 enables the coprocessor 120 to avoid having to perform relatively complex data addressing and reading tasks when executing specific computing tasks, thereby improving the computing efficiency of the model to a certain extent.

[0221] In an optional implementation, the tensor memory 124 may be a single-port static random access memory (SRAM), which utilizes the characteristics of SRAM's fast reading and storage speeds and the fact that the originally stored information is not destroyed when reading, to store the first result and the second result, thereby improving the reading and writing speeds and ensuring that when the data results in the second result used to execute at least part of the calculations of the target detection model are saved, the stored first result or other data will not be overwritten, so that the coprocessor 120 can store and read the required results at any time when processing data.

[0222] Further, based on the above implementation, since the functions of the instruction memory 121 and the tensor memory 124 (or other sub-units of the coprocessor 120 mentioned or not mentioned in the subsequent embodiments) are specialized, a simple processing unit can be added to the coprocessor 120 to implement the computing function without increasing the hardware cost too much, that is:

[0223] The coprocessor 120 further includes a cocontroller 122 , and the cocontroller 122 can be used to decode the operation instructions in the instruction memory 121 to obtain instruction decoding information.

[0224] Furthermore, a specialized operation unit 123 may be independently provided on the coprocessor 120, namely:

[0225] The coprocessor 120 also includes an operation unit 123, which is used to call the data in the tensor memory 124 as input data, perform the operation of the target detection model instruction part according to the instruction decoding information, obtain the second result and write it into the tensor memory 124.

[0226] Therefore, the three specialized function units, namely the operation unit 123, the instruction memory 121 and the tensor memory 124, only need to realize the functions of operation, reading and writing instructions, and reading and writing tensors. The hardware setting can be as simple and efficient as possible. At the same time, the co-controller 122 only needs to realize the functions of instruction decoding and control operation. The hardware requirements are also simple and efficient.

[0227] Generally speaking, the operation unit 123 is mainly used for the operation of the instruction part of the target detection model. During the operation, the operation to be performed and the data to be processed are determined according to the instruction decoding information, the corresponding data is read from the tensor memory 124, the corresponding data is operated, the calculation result is obtained, and the calculation result is written into the tensor memory 124. The written back result can be used as the input of the next calculation to continue the calculation. For the MCU and NCP solutions, it can also be sent to the control module 110 through the SDIO / SPI interface, and the control module 110 continues to perform another part of the operation of the target detection model.

[0228] When the coprocessor 120 is working, the cocontroller 122 obtains the operation instruction from the instruction memory 121, and decodes the operation instruction to obtain the decoded information instruction, which includes the read instruction, the operation instruction and the write-back instruction. (For the MCU and NCP solutions, after the control module 110 generates the operation instruction, it sends the operation instruction to the instruction memory 121 through the SDIO / SPI interface)

[0229] The operation unit 123 obtains the required data from the tensor memory 124 according to the read instruction, wherein the required data includes the first result and the model weight of the target detection model, and executes the operation instruction with the obtained data as input to obtain the second result, and writes the second result back to the corresponding position in the tensor memory 124 according to the write-back instruction.

[0230] The beneficial effects of the above embodiments are:

[0231] The computing tasks and control execution tasks of the target detection model are decoupled and completed by the co-controller 122 and the control module 110 respectively, and the reading and writing of computing instructions, instruction decoding, reading and writing of computing data, and computing functions in the coprocessor 120 (sent by the control module 110) are further decoupled and executed separately, thereby improving the overall computing efficiency of the target detection model.

[0232] According to any of the above embodiments, the following provides an embodiment of the coordination of model operation and hardware structure from the perspective of the specific structure of the target detection model. In this embodiment:

[0233] The convolution branch includes a first type of branch, which includes a convolution layer and a normalization layer (or a batch normalization layer / BN layer) connected in sequence.

[0234] The coprocessor 120 includes a computing unit 123, and the computing unit 123 includes a convolution subunit for performing convolution layer operations in the first type of branches.

[0235] In an implementation based on MCU and NCP, the convolution subunit may be composed of a preset number of multiplier-adder arrays, the preset number matching the feature map size of the target detection model. By matching the number of multipliers and adders with the feature map size used by the target detection model, the hardware resources of the convolution submodule when operating on the acquired data or tensors are sufficient and non-redundant.

[0236] Further, in an optional implementation, the coprocessor 120 includes an operation unit 123, and the operation unit 123 includes a post-processing subunit, and the post-processing subunit can be used to perform operations of the normalization layer in the first type of branches.

[0237] By separately processing the convolution operation and the normalization operation in the convolution branch, the post-processing unit and the convolution sub-module can process the operations in multiple convolution branches in parallel. When the post-processing sub-unit is processing the normalization operation of the first convolution branch, the convolution sub-unit can execute the convolution operation corresponding to the second convolution branch, thereby realizing multi-line parallel processing and improving data processing efficiency.

[0238] In addition to the first type of branches, in some optional implementations, the convolution branch also includes a second type of branches, where the second type of branches are direct-connected branches, and the direct-connected branches are used to map the value of the input end of the direct-connected branch to the output end of the direct-connected branch.

[0239] Correspondingly, the coprocessor 120 includes an operation unit 123, and the operation unit 123 includes a direct connection sub-unit for executing the direct connection operation in the second type of branches.

[0240] From the perspective of hardware architecture, the direct-connected sub-unit can be set to a pipeline structure to process the direct-connected operations in parallel. Similarly, the above description of other components in the operation unit 123 can also apply similar solutions. In the implementation of the direct-connected sub-unit of the pipeline architecture:

[0241] The directly connected sub-unit is composed of a shift register and a pipeline unit; through the shift register, a plurality of pipeline units can cache neighboring pixels and obtain convolution results;

[0242] The pipeline unit is composed of a first number of multipliers and a second number of adders; wherein the first number is equal to the maximum value of the number of single-channel convolution kernel operations of any feature map in the target detection model; and the second number is equal to the number of convolution weights of the largest convolution kernel in the target detection model minus one.

[0243] Based on the first type of branches and the second type of branches, in a preferred embodiment, the first sampling module 210 includes:

[0244] A first downsampling structure 211 consisting of two first-type branches; and,

[0245] The first feature extraction structure 212 is composed of two first-type branches and one second-type branch.

[0246] The multi-branch structure in this implementation can enhance the feature extraction capability of the model. Although the amount of computation involved in the multi-branch structure is greater, this extra workload is reflected in the training process. As introduced in the previous embodiment, during model inference, these multi-branch structures can be merged through structural reparameterization and other methods to reduce the amount of computation and speed up model inference without losing feature extraction capability (in some schemes, less loss of feature extraction capability).

[0247] Optionally, the multiplier-adder used in the convolution subunit is 8 bits. First, the input feature map (IF) and the kernel (KL) are converted into matrices by operation, and then the matrix multiplication and accumulation operation is performed using an 8-bit MAC array to implement convolution. As an example and not a limitation, if the feature map size output by one of the convolution branches of the target detection model is 40x40, the array of the multiplier-adder can be 20x20 or 10x10.

[0248] Specifically, when setting the direct connection unit, the shift register, multiplier and adder can be constructed into a tree structure, wherein the tree structure includes multiple pipeline units, each pipeline unit includes 9 multipliers and 8 adders, 9 is the maximum value of the single-channel convolution kernel operation number of any feature map in the target detection model, and 8 is the convolution weight number of the largest convolution kernel in the target detection model minus one.

[0249] In the above method, the computing unit 123 of the coprocessor 120 performs convolution operations in the target detection network and convolution activation direct connection operations in the target detection network. Operations with large data volumes are performed by the neural coprocessor 120, thereby reducing the load of the control module 110 in the target detection task.

[0250] See the instruction manual Figure 4 The first downsampling structure 211 adds a post-processing operation after performing a convolution operation on the feature map or the target image data to be detected by setting two first-class convolution branches, downsampling the image or feature map, and reducing the amount of data processing during the target detection process. The convolution kernels of the two convolution branches of the downsampling module are different in size. For example, the first convolution branch is a 3x3 convolution kernel, and the second convolution branch is a 1x1 convolution kernel.

[0251] The first feature extraction structure 212 is mainly used to extract features from an image, and includes two first-type branches and one second-type branch. Figure 5 , wherein the two first-class convolution branches can respectively have convolution kernels of different sizes, and the feature extraction capability of the target detection model (initial network) is increased through the multi-branch structure.

[0252] Optional, such as Figure 4 As shown, the output end of the first downsampling structure 211 is connected to an activation function layer 230. The activation function is used to perform a combined activation function operation on the operation results of the two first-type convolution branches of the first downsampling structure 211.

[0253] Correspondingly, the coprocessor 120 includes a computing unit 123 , and the computing unit 123 includes a post-processing subunit, and the post-processing subunit can be used to perform the operation of the activation function layer 230 .

[0254] Providing the activation function layer 230 after the first sampling module is an important difference between this embodiment and the prior art in the target detection model structure (or in the target detection algorithm / software level). This setting is conducive to improving the efficiency of feature extraction.

[0255] The beneficial effects of this embodiment are:

[0256] The multi-branch structure can enhance the feature extraction capability of the model. Although the multi-branch structure involves a larger amount of computation, this extra workload is reflected in the training process. As described in the previous embodiment, during model inference, these multi-branch structures can be merged through structural reparameterization and other methods to reduce the amount of computation and speed up model inference without losing feature extraction capability (in some schemes, less loss of feature extraction capability).

[0257] Furthermore, in conjunction with the operations of the multi-branch structure and other target detection models, hardware for convolutional layer operations, direct branch operations, and normalization layer operations are respectively set in the operation unit 123, so that appropriate logical hardware can be set for specific types of operation tasks, thereby obtaining better model training and inference speed.

[0258] According to any of the above embodiments, an embodiment of a specific architecture of a target detection model is provided below. In this embodiment:

[0259] The initial network includes N dimensionality reduction layers connected in sequence, where N is an integer greater than 2; the N dimensionality reduction layers include:

[0260] A dimensionality reduction layer consisting of a single first downsampling structure 211;

[0261] A dimensionality reduction layer consisting of one first downsampling structure 211 and two first feature extraction structures 212 connected in sequence; and,

[0262] A dimensionality reduction layer is formed by sequentially connecting one of the first downsampling structures 211 and three of the first feature extraction structures 212.

[0263] The initial network further includes: N dimensionality-raising layers connected in sequence, the N dimensionality-raising layers including:

[0264] A pooling dimension-raising layer 810 consisting of a pooling layer, a CBL layer, and an upsampling layer connected in sequence;

[0265] A fusion dimension-raising layer 820 consisting of a feature fusion layer, a CBL fusion layer, a CBL layer, and an upsampling layer connected in sequence;

[0266] An output layer consisting of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; and,

[0267] The output layer consists of a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence;

[0268] The CBL fusion layer includes a first CBL branch, a second CBL branch and a CBL fusion output structure, the output ends of the first CBL branch and the second CBL branch are connected to the input end of the CBL fusion output structure; the first CBL branch and the second CBL branch are both composed of multiple CBL sub-layers, and the number of CBL sub-layers of the first CBL branch and the second CBL branch is different, and the CBL fusion output structure includes a feature fusion sub-layer and a CBL sub-layer connected in sequence.

[0269] Among them, the role of the CBL layer is to convolve (Conv), normalize (or batch normalization, BN), and activate (for example, LeakyReLU) the input data.

[0270] Further:

[0271] For any value of i within the first specified range, the output end of the i-th dimensionality reduction layer is connected to the feature fusion layer in the j-th dimensionality increase layer, where i+j=N+1.

[0272] For any value of k within the second specified range, the output end of the CBL layer in the kth dimensionality-enhancing layer is connected to the feature fusion layer in the lth dimensionality-enhancing layer, where k+l=N+1.

[0273] The output layer is used to output the target detection result of a specified size; the output end of the Nth dimensionality reduction layer is connected to the input end of the pooling dimensionality increase layer 810, the fusion dimensionality increase layer 820 is arranged after the pooling dimensionality increase layer 810, and the output layer (both output layers) is arranged after the fusion dimensionality increase layer 820.

[0274] Figure 8 Optional structures of the pooling dimension raising layer 810 and the fusion dimension raising layer 820 are shown.

[0275] In general, the backbone network of the target detection model provided in this embodiment is composed of a dimensionality reduction part and a dimensionality increase part. On the basis of the backbone network, additional structures such as a non-maximum suppression layer can be added.

[0276] Among them, the number of dimensionality reduction layers in the dimensionality reduction part can be related to the size of the target image to be detected. For a target image to be detected with a larger size, more dimensionality reduction layers can be set to better extract features. Conversely, for a target image to be detected with a smaller size, fewer dimensionality reduction layers can be set to ensure the effectiveness of the extracted features.

[0277] Correspondingly, this embodiment provides the same number of dimensionality increase layers as dimensionality reduction layers, which can be used to provide feature map outputs of different sizes, thereby obtaining target detection results of different sizes. In other optional embodiments, the number of dimensionality increase layers and dimensionality reduction layers may also be different.

[0278] See also Figure 6 , below, we will take the setting size of the target image to be detected as 640*640*3 (where * represents a multiplication sign, which is used to illustrate the dimensional size of an image or a feature map) as an example to provide a more specific target detection model example.

[0279] For the target image to be detected of 640*640*3, the dimensionality can be reduced in sequence to obtain feature maps of 320*320, 160*160, 80*80, 40*40, 20*20, and 10*10. Figure 6 In the scheme, the number of dimensionality reduction layers is set to 6 (N=6), and the first to sixth dimensionality reduction layers sequentially downsample and extract features of the image to be detected to obtain feature maps of the above sizes respectively.

[0280] It is worth noting that the 10*10 feature map can still be obtained by adding an additional dimension reduction layer to obtain a smaller feature map, but considering the balance between model accuracy and speed, Figure 6 A more preferred solution is shown, which does not constitute a limitation on the protection scope of the present application.

[0281] Further, Figure 6 In the target detection model shown, a dimension increasing part including a dimension increasing layer is provided. It is worth noting that, although the terminology of the dimension increasing layer and the dimension increasing part is limited, the "dimensionality increasing" is relative to the dimension reducing part (used for feature extraction while reducing the dimension). The specific model structure in the dimension increasing part (including the dimension increasing layer) is not limited to the dimension increasing of the feature map, but can also include output, fusion, pooling and other functions.

[0282] Specifically, Figure 6 It is shown that in the dimensionality-upgrading part, the functions and settings of the first fused dimensionality-upgrading layer 820 and the second fused dimensionality-upgrading layer 820 (that is, the fused dimensionality-upgrading layer 820 serves as the second dimensionality-upgrading layer and the third dimensionality-upgrading layer) are more in line with the original meaning of the term "dimensionality-upgrading layer", and the pooled dimensionality-upgrading layer 810 (as well as the first dimensionality-upgrading layer) adds a pooling function on the basis of the original meaning of the term "dimensionality-upgrading layer", and serves as a structure that directly connects the dimensionality-upgrading part with the dimensionality-reducing part.

[0283] After the second dimension-raising layer, the first dimension-raising layer for output (i.e., the fourth dimension-raising layer) is set, which is composed of a CBL fusion layer and a convolutional layer. Its structure is slightly different from the output layer set at the back end of the target detection model (i.e., the output layer composed of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer). Both structures can be used to output feature maps of a specified size. Figure 6 The target detection model shown sets an output layer consisting of a CBL fusion layer and a convolutional layer at the 4th dimensionality-upgrading layer, and sets an output layer consisting of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer at the subsequent 5th and 6th dimensionality-upgrading layers. When the present application scheme is actually implemented, the specific positions and quantities of these two dimensionality-upgrading layers can be set according to actual needs.

[0284] As mentioned above, for the 640*640*3 target image to be detected, Figure 6In the target detection model in , the sixth dimensionality reduction layer outputs a feature map of size 10*10. Then, after the dimensionality increase of the first to third dimensionality increase layers, feature maps of sizes 20*20, 40*40, and 80*80 can be obtained respectively.

[0285] The fourth dimension-enhancing layer can output the feature map of size 80*80 obtained by the third dimension-enhancing layer to obtain an object detection result of size 80*80.

[0286] Generally speaking, the target detection result is a part of the target image to be detected, so the output size of the target detection result is usually smaller than the size of the target image to be detected. Therefore, in a preferred embodiment, the sum of the number of pooling dimensionality increasing layers 810 and the number of fusion dimensionality increasing layers 820 is smaller than the number of dimensionality reducing layers. Otherwise, the output size of the target detection result may be larger than the target image to be detected (unless it is subsequently subjected to another dimensionality reduction).

[0287] Furthermore, the 5th and 6th dimensionality-raising layers can reduce the dimension of the feature map with a size of 80*80 to obtain target detection results with a size of 40*40 and 20*20.

[0288] So far, the dimension-raising part including 6 dimension-raising layers can output 3 target detection results (with sizes of 80, 40, and 20 respectively). However, in some cases, the target to be identified accounts for a small proportion in the target image to be detected, and the output of 20*20 size may still be too large for this target. In this case, an additional dimension-raising layer (output layer) can be set after the 6th dimension-raising layer to obtain a target detection result of 10*10 size.

[0289] That is to say, in an optional embodiment, the number of the dimensionality-increasing layers is different from that of the dimensionality-reducing layers.

[0290] The following will Figure 6 The target detection model shown (ignoring the 7th dimensionality-enhancing layer and considering the first 6 dimensionality-enhancing layers) illustrates the feature fusion method.

[0291] The feature fusion data source of the first dimension-increasing layer is the feature map output by the sixth dimension-reducing layer;

[0292] The feature fusion data source of the second dimension-raising layer is the feature map output by the sixth dimension-reducing layer and the feature map output by the first dimension-raising layer (i+j=6+1=7=N+1);

[0293] The feature fusion data source of the third dimension-raising layer is the feature map output by the fifth dimension-reducing layer and the feature map output by the second dimension-raising layer (i+j=5+2=7=N+1);

[0294] The feature fusion data source of the fourth dimension-raising layer is the feature map output by the fourth dimension-reducing layer and the feature map output by the third dimension-raising layer (i+j=4+3=7=N+1);

[0295] The feature fusion data source of the fifth dimension-raising layer is the feature map output by the third dimension-raising layer and the feature map output by the fourth dimension-raising layer (k+l=3+4=7=N+1);

[0296] The feature fusion data source of the sixth dimension-raising layer is the feature map output by the second dimension-raising layer and the feature map output by the fifth dimension-raising layer (k+l=2+5=7=N+1);

[0297] visible, Figure 6 In the example, the first specified range is 4, 5, and 6; the second specified range is 2 and 3 (or 4 and 5).

[0298] Furthermore, in a preferred implementation of this embodiment, a more specific model structure and related descriptions are provided as follows.

[0299] In this implementation, the main idea of ​​model construction is to decouple training and reasoning. During the training process, the network structure is a multi-branch structure. When the training is completed and enters the reasoning stage, the overall network structure will be equivalently converted to a single-branch structure through structural reparameterization for deployment and reasoning.

[0300] The beneficial effects of this embodiment are:

[0301] A lightweight target detection model with better execution efficiency and adapted to the hardware structure based on the control module 110 and the coprocessor 120 is provided.

[0302] A preferred implementation will be provided below based on the above model architecture. This implementation will be explained from two perspectives: the target detection model structure and its training method.

[0303] First, the initial model structure is introduced.

[0304] The dimensionality reduction part of the initial model is composed of six dimensionality reduction layers, and the constituent units of the dimensionality reduction layer include a first downsampling structure 211 and a first feature extraction structure 212, wherein the first downsampling structure 211 includes two first-category branches connected in parallel, and the parallel connection here means that the input of the first downsampling structure 211 is given to the two first-category branches at the same time, and the outputs of the two first-category branches (that is, the output of the convolution layer after the BN layer calculates) will be respectively summarized to the activation function layer 230, and the output of the activation function layer 230 is the output of the first downsampling structure 211; correspondingly, the first feature extraction structure 212 includes two first-category branches connected in parallel, and at the same time, the first feature extraction structure 212 also has a second-category branch connected in parallel, and the parallel connection here means that the input of the first feature extraction structure 212 is given to the two first-category branches and one second-category branch at the same time, and the outputs of the two first-category branches (that is, the output of the convolution layer after the BN layer calculates) and the outputs of the second-category branches (that is, the directly connected branches) are summarized as the output of the first feature extraction structure 212.

[0305] On this basis, the first dimensionality reduction layer of the initial model is composed of a first downsampling structure 211, the second dimensionality reduction layer is composed of a first downsampling structure 211 and two first feature extraction structures 212 in sequence, the structures of the third, fifth, and sixth dimensionality reduction layers are consistent with the second dimensionality reduction layer, and the fourth dimensionality reduction layer is composed of a first downsampling structure 211 and three first feature extraction structures 212 in sequence.

[0306] That is to say, the dimensionality reduction part of the target detection model provided by this embodiment can be understood as the first downsampling structure 211 downsampling the input feature map six times in succession. Except for the first downsampling structure 211, the first feature extraction structure 212 is added after each downsampling to extract image features at different scales. In the scheme provided by this embodiment, the depths of the first feature extraction structure 212 are 0, 2, 2, 3, 2, and 2, respectively.

[0307] Taking the 640*640(*3) output image as an example, the first dimensionality reduction layer can reduce its dimension to obtain a 320*320 feature map, the second dimensionality reduction layer can continue to reduce the dimension of the feature map to obtain a 160*160 feature map, and so on until the sixth dimensionality reduction layer outputs a 10*10 feature map as the output of the dimensionality reduction part. It is worth noting that the 10*10 feature map is the output obtained by reducing the dimension of the remaining dimensionality reduction layers in sequence, and can be directly used as the input data of the subsequent part of the model (the dimensionality increase part), but this 10*10 feature map is not the only output of the part. The output of each dimensionality reduction layer (in some cases, it can be understood as the "intermediate result" of the feature map) can also be used as the fusion input data of certain specific structures of the dimensionality increase part. This part will be explained in detail in the subsequent introduction to the dimensionality increase part.

[0308] It is worth noting that the above description is based on the initial model before training is completed. The architecture of the target detection model after training is slightly different from the above, which will be explained in detail in the subsequent section on training.

[0309] In the initial model provided in this embodiment, the dimension-increasing part is composed of seven dimension-increasing layers. The component units of the dimension-increasing layer include a pooling layer, a CBL layer, an upsampling layer, a CBL fusion layer and a feature fusion layer.

[0310] It is worth mentioning that the CBL fusion layer can be understood as a fusion layer of multiple CBL calculations, including a first CBL branch and a second CBL branch connected in parallel, and also including a CBL fusion output structure. The parallel connection here means that the input of the CBL fusion layer is given to the first CBL branch and the second CBL branch at the same time, and the outputs of the first CBL branch and the second CBL branch are aggregated as the input and output of the CBL fusion output structure. The output of the CBL fusion output structure is the output of the CBL fusion layer.

[0311] Further, the first CBL branch and the second CBL branch are composed of different numbers of CBL sublayers connected in sequence, for example, the first CBL branch is composed of three CBL sublayers, and the second CBL branch is composed of two CBL sublayers. The CBL fusion output structure includes a feature fusion sublayer and a CBL sublayer connected in sequence.

[0312] From the perspective of operation, the operation of the CBL sublayer and the CBL layer can be the same. Similarly, the operation of the feature fusion sublayer and the feature fusion layer can be the same.

[0313] It can be understood that the CBL fusion layer is equivalent to fusing the features that have undergone different times of CBL operations (ie, the feature fusion sublayer) and outputting them here, which is conducive to extracting features of different depths to obtain better output results.

[0314] On this basis, in the initial model provided by this embodiment, the first dimension-raising layer is a pooling dimension-raising layer 810 composed of a pooling layer, a CBL layer and an upsampling layer connected in sequence; the second and third dimension-raising layers are fusion dimension-raising layers 820 composed of a feature fusion layer, a CBL fusion layer, a CBL layer and an upsampling layer connected in sequence; the fourth dimension-raising layer is an output layer composed of a feature fusion layer, a CBL fusion layer and a convolution layer connected in sequence; the fifth, sixth and seventh dimension-raising layers are output layers composed of a CBL layer, a feature fusion layer, a CBL fusion layer and a convolution layer connected in sequence.

[0315] Unlike the dimensionality reduction part of the initial model, the structure of the above-mentioned dimensionality increase part in this embodiment does not change before and after training. That is, although the training process updates the operation parameters of the dimensionality increase part, the operation architecture of the initial model and the trained target detection model is consistent.

[0316] For the initial model, the 10*10 feature map output by the dimensionality reduction part will be used as the input data of the first dimensionality increase layer, and then the second to seventh dimensionality increase layers will perform data operations in sequence. The output data of the mth dimensionality increase layer is the input and output of the m+1th dimensionality increase layer.

[0317] In particular, in a preferred embodiment of the present invention, starting from the fourth dimensionality-increasing layer (i.e., for all output layers), the output of the convolutional layer is the target detection result output by the layer, and at the same time, the input of the convolutional layer (i.e., the output of the CBL fusion layer) is used as the input of the next dimensionality-increasing layer (or, the output layer).

[0318] Furthermore, in addition to the 10*10 feature map finally output by the dimensionality reduction part, the dimensionality increase part also extracts some intermediate results of the dimensionality reduction part as the basis for feature fusion. The specific extraction scheme is as follows.

[0319] The input data of the feature fusion layer of the second dimension-raising layer includes the output data of the first dimension-raising layer and the output data of the fifth dimension-reducing layer;

[0320] The input data of the feature fusion layer of the third dimension-raising layer includes the output data of the second dimension-raising layer and the output data of the fourth dimension-reducing layer;

[0321] The input data of the feature fusion layer of the fourth dimension-increasing layer includes the output data of the third dimension-increasing layer and the output data of the third dimension-reducing layer;

[0322] The feature fusion layer input data of the fifth dimension-raising layer includes the output data of the fourth dimension-raising layer (here, the output data of the CBL fusion layer of the fourth dimension-raising layer can be used as one of the input data of the feature fusion layer of the fifth dimension-raising layer), and also includes the output data of the CBL layer of the third dimension-raising layer;

[0323] The feature fusion layer input data of the sixth dimension-raising layer includes the output data of the fifth dimension-raising layer (here, the output data of the CBL fusion layer of the fifth dimension-raising layer can be used as one of the input data of the feature fusion layer of the sixth dimension-raising layer), and also includes the output data of the CBL layer of the second dimension-raising layer;

[0324] The feature fusion layer input data of the seventh dimension-raising layer includes the output data of the sixth dimension-raising layer (here, the output data of the CBL fusion layer of the sixth dimension-raising layer can be used as one of the input data of the feature fusion layer of the seventh dimension-raising layer), and also includes the output data of the CBL layer of the first dimension-raising layer;

[0325] In the initial model constructed using the above architecture, the first dimensionality-enhancing layer enlarges the 10*10 feature map to 20*20, the second dimensionality-enhancing layer enlarges the 20*20 feature map to 40*40, and the third dimensionality-enhancing layer enlarges the 40*40 feature map to 80*80.

[0326] Subsequently, the fourth dimension-upgrading layer uses the 80*80 feature map for calculation and outputs an 80*80 target detection result. Similarly, although the subsequent output layer is called a dimension-upgrading layer, the size of the feature map and the target detection result is not actually increased in dimension.

[0327] Furthermore, the fifth, sixth, and seventh dimensionality-enhancing layers use the feature maps of 80*80, 40*40, and 20*20 respectively to perform operations and output target detection results of 40*40, 20*20, and 10*10.

[0328] That is to say, in the solution provided in this embodiment, in the output part of the target detection model (which can be understood as the collection of output layers in the dimensionality increase part), in order to make full use of the multi-scale information of the backbone network, four feature maps are designed to output 80×80, 40×40, 20×20, and 10×10.

[0329] Furthermore, in this implementation, the activation function may use a ReLU function.

[0330] It can be seen that the size of the input feature map of the fifth, sixth, and seventh dimensionality-raising layers is different from the size of the output target detection results. This is also caused by the difference between the architecture of the fifth, sixth, and seventh dimensionality-raising layers and that of the fourth dimensionality-raising layer. In other words, a target detection result with the same size as the input feature map can be obtained by using a structure similar to that of the fourth dimensionality-raising layer, and a target detection result after the input feature map is reduced in dimensionality can also be obtained by using a structure similar to that of the fifth, sixth, and seventh dimensionality-raising layers.

[0331] According to any of the above embodiments, an embodiment of a target detection model training process is provided below. In this embodiment:

[0332] The coprocessor 120 further includes a cocontroller 122 , which can be used to: execute training operations of the initial model according to instructions sent by the control module 110 , obtain training results, and transmit them to the control module 110 .

[0333] The control module 110 can also be used to:

[0334] updating the parameters of the initial model according to the training results to obtain a trained initial model; and,

[0335] The convolution layer operation and the normalization layer operation of the first type of branch in the trained initial model are merged to obtain a merged branch.

[0336] The control module 110 can also be used to:

[0337] Adjusting the convolution kernels of the merged branches in the first downsampling structure 211 of the trained initial model to the same size in a first preset manner; and / or,

[0338] The merged branches and the second type of branches in the first feature extraction structure 212 of the trained initial model are adjusted to convolution structures with the same convolution kernel size in a second preset manner.

[0339] In this embodiment, the training process is still controlled by the control module 110, the coprocessor 120 performs data operations, and the control module 110 receives the operation results to perform parameter back propagation until the training is completed to obtain a target detection model with appropriate model weight parameters.

[0340] The branch merging step described in the above embodiment may also be executed by the control module 110 .

[0341] Therefore, the model weight parameters after training are stored in the control module 110. Before actual inference, the control module 110 can send the model weight parameters to the coprocessor 120 to perform operations in the inference process.

[0342] In this embodiment, the execution logic of the training process is similar to the reasoning process, so unless otherwise specified, the implementation of the calculation control, data reading and writing and other functions in the training process can refer to the description of the reasoning part in the above embodiment.

[0343] The training process also includes a branch fusion step. That is, although the parameters in the initial model have been updated through the training process, its model structure is still the multi-branch structure in the initial model. At this time, it is necessary to fuse the first-category branches and / or second-category branches after the parameter updates, and then obtain equivalent fused branches, thereby reducing the computing power required for object detection model inference.

[0344] Still based on the initial model structure provided in the previous embodiment as an example, the fusion process is described as follows.

[0345] According to the linear additive property of the convolution operation, the calculation of any first feature extraction structure 212 can be expressed as Formula 1:

[0346] Out(x)=F(x)+G(x)+x

[0347] Similarly, the calculation of any first downsampling structure 211 can be expressed as Formula 2:

[0348] Out(x)=F(x)+G(x)

[0349] Where: F(x) represents 3×3 convolution; G(x) represents 1×1 convolution, x is the input, and Out(x) is the output.

[0350] During inference, the convolutional layer is fused with the BN layer, where the convolutional layer can be expressed as Equation 3:

[0351] Conv(x)=W(x)+b

[0352] The formula of the BN layer can be expressed as Equation 4:

[0353]

[0354] Where: W represents weight, b represents bias, and x represents input; var and mean represent standard deviation and mean respectively, which are obtained by statistics in the training process, γ and β are obtained in training and learning, Conv represents the output of convolutional layer, BN represents the output of BN layer, and x represents input.

[0355] Substituting the convolutional layer result Equation 3 into Equation 4, we can get Equation 5:

[0356]

[0357] Further, let Then equation 5 can be transformed into equation 6:

[0358] BN(Conv(x))=W fused +B fused

[0359] That is to say, after fusing the convolution layer and the BN layer, we can get 3×3 convolution, 1×1 convolution branch, Identity branch (i.e., direct connection branch) and 3 bias vectors.

[0360] refer to Figure 7 , Figure 7 The left side shows the branch structure during training, the middle side shows the branch equivalent structure after branch fusion (or structural reparameterization) after training, and the right side shows the actual branch structure during reasoning.

[0361] for Figure 7 As for , due to the adoption of the model architecture in the previous embodiment, during training ( Figure 7 The branch structure on the left is composed of a 1×1 convolution branch, a 3×3 convolution branch, and an Identity branch.

[0362] After training is completed, the model structure is re-parameterized and integrated when deploying inference. Specifically:

[0363] For the 1×1 branch, if the input and output feature maps are of the same size, the convolution stride is 1, and the 1×1 convolution kernel performs a convolution operation on the input image to obtain an output feature map of the same size; one prerequisite for fusion is that the feature maps obtained by each convolution kernel have the same size, so if you want to change the convolution kernel size from 1×1 to 3×3, you can fill a circle of pixels with a weight of 1 on the 1×1 convolution kernel to convert it into a 3×3 convolution kernel;

[0364] Similarly, the Identity branch also needs to be constructed as an output feature map with the same output size as the 3×3 convolution kernel before fusion can be performed. Therefore, in order to ensure that the original weights remain unchanged before and after passing through the Identity branch, a 3×3 convolution kernel with weights of 1 and 0 can be selected for channel-by-channel convolution. The weight of the current channel convolution kernel is set to 1, and the weights of other channels are set to 0. After the convolution operation, the results of each channel are added together to finally obtain the fused weight.

[0365] Furthermore, the three constructed branches can be fused through structural reparameterization to form 3×3 independent reasoning branches, which not only reduces the amount of calculation but also reduces unnecessary video memory usage during reasoning.

[0366] It can be understood that the first down-sampling structure 211 is converted into the second down-sampling structure after the above fusion, and correspondingly, the first feature extraction structure 212 is converted into the second feature extraction structure after the above fusion.

[0367] Figure 7 In the illustrated implementation, structural reparameterization fusion is used to decouple the network structure during training and the network structure during inference, forming two different structures: a multi-branch structure during training and a single-branch structure during inference, while the single-branch network retains the ability of the multi-branch network to extract features.

[0368] In terms of memory usage, a multi-branch network (i.e., at least a part of the target detection model) needs to temporarily store the calculation results of each branch, and the memory usage will be larger than that of a single-branch network. Conversely, the fused inference model can achieve similar effects to a multi-branch structure with fewer computing resource requirements.

[0369] The beneficial effects of this embodiment are:

[0370] A training control logic similar to the reasoning process is provided, so that the execution code when the target detection model is running in the hardware including the coprocessor 120 and the control module 110 and the execution code when the initial model is trained in the hardware including the coprocessor 120 and the control module 110 have a high overlap, reducing the additional overhead at the execution code level.

[0371] According to any of the above embodiments, an embodiment including a specific functional implementation of a post-processing subunit is provided below. In this embodiment:

[0372] The operation unit 123 includes a post-processing subunit, and the post-processing subunit includes a spare operation component, and the spare operation component can be used to perform a designated operation task of a non-convolution operation and a non-activation function operation.

[0373] The post-processing subunit is composed of the following components:

[0374] The first component used to convert an integer to a floating point number;

[0375] The second component for converting a floating point number to an integer;

[0376] a third component for performing floating point multiplication and addition operations; and,

[0377] A fourth component for performing activation function layer 230 operations.

[0378] Different from the direct-connection subunit and the convolution subunit, the post-processing subunit in this embodiment undertakes more functions, including normalization (i.e., batch normalization layer / BN layer) operations, activation function layer 230 operations, and other specified operations.

[0379] In this embodiment, the post-processing subunit serves as an execution unit for the following operations:

[0380] Operation of normalization layer;

[0381] Operation of activation function layer 230;

[0382] A specified operation task that is neither a convolution operation nor an activation function operation.

[0383] That is to say, the post-processing sub-unit undertakes some specified computing tasks in the coprocessor 120. These specified computing tasks can be understood as computing tasks for which no dedicated specialized computing unit 123 (for example, a convolution unit) is set. Therefore, its computing capability is more comprehensive than other specialized units. The first to fourth components provided in this embodiment can perform conversions between integers and floating-point numbers and multiplication and addition operations of floating-point numbers, and are a more universal computing structure.

[0384] The fourth component can be understood as a hardware component dedicated to activation function operations.

[0385] An implementation including specific hardware components will be provided below.

[0386] For the lightweight target detection network deployed at the edge, this embodiment provides a neural co-processor 120 (neural co-processor, NCP, NCP can be understood as a preferred implementation of the coprocessor 120 in the above embodiment) specifically for processing the internal storage information of the deep neural network. The NCP can be interconnected with an MCU equipped with a CPU chip (i.e., a preferred implementation of the control module 110 in the above embodiment). The entire working system stores all functions and weights on the chip and completely eliminates the delay and power consumption in accessing off-chip memory.

[0387] Specifically, NCP and MCU are used together as AI chips, and the overall hardware system architecture is as follows.

[0388] The separate NCP neural coprocessor 120 is integrated with the single-chip microcomputer MCU on a compact circuit board to jointly process the target detection task.

[0389] The MCU may be provided with a Flash memory, a CPU, an I / O interface, and a RAM memory. In an optional embodiment, the MCU is further provided with a sensor 130 interface for receiving a sensor 130 signal as an input image;

[0390] The MCU communicates with the I / O interface of the NCP through its I / O interface. This channel is used to transmit model parameters, image information or feature maps.

[0391] Before inference, the MCU sends the model weights and instructions to the NCP, which has enough on-chip SRAM to cache all this data. During inference, the NCP performs intensive CNN backbone workloads, while the MCU only performs light-load pre-processing (color normalization) and post-processing (fully connected layers, non-maximum suppression, etc.).

[0392] Considering the requirements of real-time communication, we use the SDIO / SPI interface to interconnect the NCP and MCU. Since this interface is mainly used to frequently transmit input images and output results, the bandwidth of SDIO and SPI is sufficient for real-time data transmission. For example, SDIO can provide up to 500Mbps bandwidth, which can transmit about 300FPS for 256×256×3 images and 1200FPS for 128×128×3 images. For the relatively slower SPI, it still reaches 100Mbps, or an equivalent throughput of 60FPS for 256×256×3 images.

[0393] According to any of the above embodiments, in yet another embodiment:

[0394] The tensor memory 124 includes:

[0395] The storage space matches the input cache portion of the target image to be detected;

[0396] The storage space matches a feature cache portion of a feature map tensor, wherein the feature map tensor is at least a portion of output data of any dimensionality reduction layer or dimensionality increase layer of the object detection model;

[0397] A weight cache portion having a storage space matching the model weight parameter quantity of the target detection model; and,

[0398] The storage space matches the output cache portion of the target detection result of the specified size.

[0399] The co-controller 122 can also be used to: store the second result calculated by the operation unit 123 according to the instruction decoding information in a preset manner to the tensor memory 124 according to the calculation result form information in the instruction decoding information, and the preset manner corresponds one-to-one to the calculation result form information.

[0400] According to the calculation result form information in the instruction decoding information, storing the second result calculated by the operation unit 123 according to the instruction decoding information in a preset manner to the tensor memory 124 includes:

[0401] If it is determined that the calculation result form information in the instruction decoding information is a two-dimensional tensor, the second result in the form of a two-dimensional tensor calculated by the operation unit 123 according to the instruction decoding information is stored in the tensor memory 124 in sequence according to the order of channels, and the data of any channel is stored in the tensor memory 124 in row-major order or column-major order.

[0402] According to the calculation result form information in the instruction decoding information, storing the second result calculated by the operation unit 123 according to the instruction decoding information in a preset manner to the tensor memory 124 includes:

[0403] Determining that the calculation result form information in the instruction decoding information is a three-dimensional tensor, storing the second result in the three-dimensional tensor form calculated by the operation unit 123 according to the instruction decoding information into a designated three-dimensional storage block of the tensor memory 124;

[0404] Among them, the three-dimensional storage block is a plurality of storage blocks preset in the tensor memory 124, the storage space of any of the three-dimensional storage blocks matches the three-dimensional feature map size of the target detection model, and the storage address of any bit in the three-dimensional storage block corresponds to the channel number, tile number and row and column number in the tile of the second result in the form of a three-dimensional tensor.

[0405] That is to say, this embodiment provides a specific architecture and storage / computation mode of the coprocessor 120. Based on the AI ​​chip based on NCP and MCU in the previous embodiment, this embodiment can be implemented in the following preferred manner:

[0406] like Fig. 9 As shown, NCP consists of five main components: tensor memory 124 (TM), instruction memory 121 (IM), input / output module 125 (I / O), operation unit 123 (or neural operation unit 123NOU) and cocontroller 122 (or system controller SC). When NCP is working, SC first decodes an instruction obtained from IM and notifies NOU to start calculation using the decoded signal. The calculation process requires multiple cycles, during which NOU reads operands from TM and automatically writes back the results. Once the write-back process is completed, SC will continue to process the next instruction until it encounters an end or suspension instruction. When NOU is idle, TM can be accessed through I / O. We will fully describe each component in the following sections.

[0407] First, the neural computing unit 123 is introduced.

[0408] NOU contains three sub-modules, called NOU-conv (convolution sub-unit), NOU-Idt (direct connection sub-unit) and NOU-post (post-processing sub-unit), which are used to support the corresponding neural operations of conv, identity and bn respectively.

[0409] NOU-conv processes the 3×3 convolution and 1×1 convolution in the backbone network of the target detection model. It first converts the input feature map (IF) and kernel (KL) into matrices using the im2col operation (i.e., expanding the input feature map horizontally into 1 column and the convolution kernel vertically into 1 column), and then uses T oc ×T hw The 8-bit MAC array performs matrix multiply-accumulate operations to implement convolution.

[0410] Specifically, T oc Represents the number of slices along the channel dimension, for example T oc =16 means that the input feature map is divided into 16 slices along the channel dimension, and each slice has a height and width. hw The meaning is the height and width of each slice. The slicing operation is an operation performed after the feature map is obtained after the first downsampling structure 211 or the first feature extraction structure 212. It is an intermediate step of the target detection model, and it is not the final feature map like 80×80×255. The specific value can be set as needed.

[0411] In this embodiment, the 8-bit MAC array refers to a matrix composed of multiple 8-bit multipliers and adders. Experiments show that in this embodiment, using 8-bit hardware can ensure that the current computing efficiency and computing accuracy reach a balance, 4-bit will reduce the computing accuracy, and 16-bit will reduce the computing efficiency.

[0412] NOU-Idt uses shift registers, multipliers, and adder trees in the classic convolution processing pipeline to perform Identity operations. It arranges 9 multipliers and 8 adders in each processing pipeline to process Identity. With the help of shift registers, each pipeline can cache neighborhood pixels and produce convolution results in the output channel of each cycle. In order to speed up the convolution calculation, we arrange the total T of the 2D convolution processing pipeline in the NOU-Idt module. oc , to achieve N oc Dimensional parallel computing.

[0413] Among them, the number of multipliers and adders matches the target detection model example provided in the above embodiment. The second downsampling structure (or the first downsampling structure 211) is converted to the second feature extraction structure (or the first feature extraction structure 212), or the second feature extraction structure (or the first feature extraction structure 212) is converted to the second downsampling structure (or the first downsampling structure 211) a total of 9 times. In this case, an independent convolution kernel is required to operate on each channel of the input feature map, so 9 multipliers are set.

[0414] In this embodiment, the number of adders is set to 8 because point-by-point convolution operations need to be performed and point-by-point addition operations are performed on the intermediate feature maps and the weights of different channels, so 8 adders are required.

[0415] Total T oc Refers to the total number of processing pipelines in the NOU-IDt module, which can also be understood as the number of parallel processing units. oc Not relevant.

[0416] N oc It is expressed as the dimension of parallel computing in NOU-IDt, which can be understood as the number of processing units performing calculations simultaneously.

[0417] NOU-post implements BN, ReLU and element-wise addition operations (the "element-wise addition operation" here actually refers to the addition of elements one by one, which can be addition or other element-wise operations, depending on the application requirements). It uses T ocThe post-processing units apply single-precision floating-point calculations. Each post-processing unit contains an interg2float module (the first component for converting integers to single-precision floating-point numbers), a floating-pointMAC (the third component for performing floating-point multiplication and addition operations), a ReLU module (the fourth component for implementing the rectified linear unit ReLU activation function), and a float2integer module (the second component for converting floating-point numbers to integers).

[0418] The input of the post-processing unit comes from NOU-conv, NOU-Idt or TM selected by the multiplexer. Therefore, the results calculated by conv3×3, conv1×1 or Identity can be sent directly to NOU-post, which allows BN, ReLU to be fused with conv and Identity, greatly reducing the number of memory accesses.

[0419] Furthermore, the tensor memory 124TM will be introduced below.

[0420] TM is a single-port SRAM consisting of 6 banks with a width of T tm ×8 bits, such as Figure 4 As shown. Due to the compactness of the overall network hardware structure, NCP only requires 992KB of on-chip SRAM. BankI (192KB) is responsible for caching the input 640×640×3 color image. Bank0 and Bank1 of 128KB are used to cache feature maps, while Bank2 and Bank3 of 256KB are used to store model weights. BankO of 32KB is used to store calculation results such as feature vectors, heat maps, and junction boxes. The small capacity and simple structure of TM make our NCP occupy a small area.

[0421] Regarding tensor layout, in order to improve memory access efficiency and processing parallelism, we specially designed pixel-major layout and interleaved layout.

[0422] For the pixel-major layout, all pixels of the first channel are mapped to the TM sequentially in row-major order. Then, the next channel is arranged in the same pattern until all channels in the tensor are stored. The pixel-major layout is convenient for operations that need to obtain consecutive column data in one memory access, but it is inefficient for those operations that need to access consecutive channel data in one cycle. In this case, the move instruction is used to convert the tensor to an interleaved layout. In this layout, the entire tensor is divided into N c / / T tmTiles are arranged in TM order, while each tile is arranged in channel-major order. With these two tensor layouts, NCP can efficiently utilize TM bandwidth and greatly reduce memory access latency.

[0423] Furthermore, Fig.10 The architecture of the target detection system including a sensor 130 for inputting an image is shown. Fig.10 As shown, the target detection system further includes an image sensor 130 ; the image sensor 130 is used to read the target image to be detected or the sample, and transmit it to the control module 110 .

[0424] Corresponding to the above-mentioned system embodiments, a series of method embodiments will be provided below from the perspective of execution methods (in some cases, these methods can be algorithmically formed into specific program codes to be executed in predetermined hardware, such as AI chips).

[0425] This embodiment provides a target detection method, such as Fig.11 As shown, it is applied to the control module 110, including:

[0426] Step 1102, obtaining a target image to be detected;

[0427] Step 1104, generating a computing instruction of a first specified structure corresponding to the target detection model, wherein the computing instruction is used to control the coprocessor 120 to perform a computing task of the first specified structure;

[0428] Step 1106, obtaining a second result, wherein the second result includes a calculation result of the first specified structure;

[0429] Step 1108, performing an operation of a second specified structure of the target detection model according to the second result and / or the target image to be detected to obtain a first result;

[0430] Step 1110, obtaining a target detection result of the target image to be detected according to the first result and / or the second result;

[0431] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0432] Similar to the above system embodiment, in this embodiment, the control module 110 can obtain the target image to be detected, and the target image to be detected is the input data of the target detection. For the target detection system provided by this embodiment, the calculation task of the target detection model (in some optional embodiments, it is a neural network model, which can also be called a target detection network) is implemented on the control module 110 and the coprocessor 120 respectively. Therefore, it can be referred to as Figure 1For example, the target detection model is understood as being partially deployed on the control module 110 and partially deployed on the coprocessor 120 .

[0433] At the same time, the first specified structure and the second specified structure can be understood as different divisions of labor of the target detection model in the control module 110 and the coprocessor 120. During actual execution, the specific tasks of the target detection model can be decomposed, and the model weight parameters described in the same category of operations can be stored at a specific address, so that the control module 110 and the coprocessor 120 can directly read the model weight parameters from the specific address when performing specific operation tasks.

[0434] Furthermore, which tasks are specifically processed by the control module 110 and the coprocessor 120 depends on the specific architecture of the target detection model, the hardware configuration of the control module 110 and the hardware configuration of the coprocessor 120, that is, the computing tasks of the target detection model executed by the control module 110 match the hardware configuration of the control module 110, and the computing tasks of the target detection model executed by the coprocessor 120 match the hardware configuration of the coprocessor 120.

[0435] It is worth noting that, in the present embodiment, the set of the first specified structure and the second specified structure constitutes at least a part of the target detection model, but does not necessarily constitute a complete target detection model. In actual use, in addition to the control module 110 and the coprocessor 120, there may also be other computing units (for calculating the third specified structure of the target detection model).

[0436] However, in an optional embodiment, the first specified structure and the second specified structure constitute the target detection model.

[0437] After the step of obtaining the target image to be detected, the following steps are included:

[0438] The target image to be detected is color normalized and sent to the coprocessor 120 .

[0439] As an example but not limitation, the control module 110 may be a micro-controller unit (MCU), and the coprocessor 120 may be a neural co-processor (NCP).

[0440] In the example based on MCU, NCP and target detection network, the division of labor between coprocessor 120 and control module 110 can be configured as follows: during inference, NCP performs intensive CNN backbone workload, while MCU only performs light-load pre-processing (such as color normalization) and post-processing (such as fully connected layers, non-maximum suppression, etc.).

[0441] According to the above embodiment, in yet another embodiment:

[0442] The target detection model and the initial model both include a dimensionality reduction part, a dimensionality increase part and a post-processing part connected in sequence;

[0443] The dimension reduction part is used to extract features from the target image to be detected to obtain multiple dimension reduction features; the dimension increase part is used to perform feature fusion on the dimension reduction features to obtain at least one dimension increase feature; the post-processing part is used to perform full connection operation on the dimension increase features and output the target detection result;

[0444] Among them, the dimensionality reduction part of the initial model includes a first sampling module 210, and the first sampling module 210 includes at least two convolution branches of different sizes; the dimensionality reduction part of the target detection model includes a second sampling module 220, and the second sampling module 220 is obtained by fusing the convolution branches of the first sampling module 210.

[0445] The training process of the target detection model in this embodiment will be described below.

[0446] Before the step of obtaining the second result, the method further includes:

[0447] Generate a training instruction, wherein the training instruction is used to control the coprocessor 120 to perform a sample-based training operation;

[0448] Acquire a training result, and update the parameters of the initial model according to the training result to obtain a trained initial model, wherein the training result is a result obtained by the coprocessor 120 according to the training instruction;

[0449] The convolution layer operation and the normalization layer operation of the convolution branch in the trained initial model are merged to obtain an initial model with a merged branch.

[0450] After the step of merging the convolution layer operation and the normalization layer operation of the convolution branch in the trained initial model to obtain the initial model with the merged branch, the method further includes:

[0451] Perform the following steps to obtain the target detection model:

[0452] Adjusting the convolution kernels of the merged branches to the same size in a first preset manner; and / or,

[0453] The merged branch and the directly connected branch are adjusted to a convolution structure having the same convolution kernel size in a second preset manner.

[0454] After the step of obtaining the target detection model, the method further includes:

[0455] The model weight parameters of the target detection model are sent to the coprocessor 120 .

[0456] The second specified structure includes a fully connected layer and / or a non-maximum suppression layer in a post-processing portion of the target detection model.

[0457] Corresponding to the above method embodiment applied to the control module 110, the present application also provides a target detection method, such as Fig.12 As shown, it is applied to the coprocessor 120, including:

[0458] Step 1202, obtaining a calculation instruction corresponding to a first specified structure of the target detection model generated by the control module 110;

[0459] Step 1204, performing the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result; the second result is used as an input parameter for the control module 110 to perform at least a part of the operation of the second specified structure of the target detection model; and / or is used as an input parameter to obtain the target detection result of the target image to be detected;

[0460] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0461] In an optional implementation, the first specified structure and the second specified structure constitute the target detection model.

[0462] Before the step of acquiring the operation instruction corresponding to the first specified structure of the target detection model generated by the control module 110, the method further includes:

[0463] A training instruction is obtained, and a sample-based training operation is performed according to the training instruction to obtain a training result.

[0464] Before the step of acquiring the operation instruction corresponding to the first specified structure of the target detection model generated by the control module 110, the method further includes:

[0465] Obtain model weight parameters of the target detection model, where the model weight parameters are used to perform operations of a first specified structure of the target detection model.

[0466] The target detection model and the initial model both include a dimensionality reduction part, a dimensionality increase part and a post-processing part connected in sequence;

[0467] The dimension reduction part is used to extract features from the target image to be detected to obtain multiple dimension reduction features; the dimension increase part is used to perform feature fusion on the dimension reduction features to obtain at least one dimension increase feature; the post-processing part is used to perform full connection operation on the dimension increase features and output the target detection result;

[0468] Among them, the dimensionality reduction part of the initial model includes a first sampling module 210, and the first sampling module 210 includes at least two convolution branches of different sizes; the dimensionality reduction part of the target detection model includes a second sampling module 220, and the second sampling module 220 is obtained by fusing the convolution branches of the first sampling module 210.

[0469] The first specified structure includes:

[0470] The downsampling layer, feature extraction layer, normalization layer, direct connection branch and activation function layer 230 in the dimension-increasing part of the target detection model; and,

[0471] The pooling layer, CBL layer, upsampling layer, feature fusion layer and activation function layer 230 in the dimension reduction part of the target detection model.

[0472] The downsampling layer includes a convolution layer, a normalization layer and an activation function layer 230; the feature extraction layer includes a convolution layer, a normalization layer and a direct connection branch;

[0473] The step of performing the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result includes:

[0474] Determining that the operation instruction is the convolution layer operation, calling the convolution subunit to perform the operation;

[0475] Determining that the operation instruction is a direct branch operation, calling the direct subunit to perform the operation;

[0476] If it is determined that the operation instruction is a normalization layer operation or an activation function layer 230 operation, the post-processing subunit is called to perform the operation.

[0477] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0478] Corresponding to the target detection method described in the above embodiment, Fig.13 and Fig.14 The structural block diagrams of two target detection devices provided in the embodiments of the present application are respectively shown. For the convenience of explanation, only the parts related to the embodiments of the present application are shown.

[0479] Reference Fig.13 , the first device comprises:

[0480] A first acquisition component 1310 is used to acquire an image of a target to be detected;

[0481] An instruction component 1320, configured to generate an operation instruction of a first specified structure corresponding to the target detection model, wherein the operation instruction is used to control the coprocessor 120 to perform an operation task of the first specified structure;

[0482] A second acquisition component 1330 is used to acquire a second result, where the second result includes a calculation result of the first specified structure;

[0483] A first operation component 1340 is used to perform an operation of a second specified structure of the target detection model according to the second result and / or the target image to be detected to obtain a first result;

[0484] A classification component 1350 is used to obtain a target detection result of the target image to be detected according to the first result and / or the second result;

[0485] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0486] Reference Fig.14 , the second device comprises:

[0487] The third acquisition component 1410 is used to acquire the operation instruction corresponding to the first specified structure of the target detection model generated by the control module 110;

[0488] The second operation component 1420 is used to perform the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result; the second result is used as an input parameter for the control module 110 to perform at least a part of the operation of the second specified structure of the target detection model; and / or is used as an input parameter to obtain the target detection result of the target image to be detected;

[0489] The target detection model is a machine learning model obtained after the initial model is trained based on samples.

[0490] It is worth mentioning that Fig.13 and Fig.14 The device shown can be understood as a virtual module embodiment of the present application corresponding to the method embodiment of the present application, so the restrictions on the method embodiment can also be added as some optional virtual modules in the present application. Fig.13 and Fig.14 The device shown.

[0491] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0492] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0493] The present application also provides a terminal device, such as Fig.15 As shown, the terminal device 150 includes: at least one processor 1501, a memory 1502, and a computer program 1503 stored in the memory and executable on the at least one processor, and the processor implements the steps in any of the above-mentioned method embodiments when executing the computer program.

[0494] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0495] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the mobile terminal can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0496] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the camera / terminal device, recording medium, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

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

[0498] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0499] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0500] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0501] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A target detection system, characterized in that: It includes a control module and a coprocessor, wherein the control module and the coprocessor are communicatively connected; The control module is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the coprocessor to obtain one or more first results, wherein the first result includes a data result for sending to the coprocessor; The coprocessor is used to perform at least a part of the operation of the target detection model according to the target image to be detected and / or according to the data sent by the control module to obtain one or more second results, wherein the second result includes a data result for sending to the control module; The target detection model is a machine learning model obtained after the initial model is trained according to samples; and at least one of the first result and the second result is a data result for obtaining the target detection result of the target image to be detected; The initial model includes a first sampling module, the first sampling module is used to extract image features, and the first sampling module includes at least two convolution branches of different sizes; the target detection model includes a second sampling module, and the second sampling module is obtained by fusing the convolution branches of the first sampling module; The control module is further used to send a calculation instruction to the coprocessor; the coprocessor is used to perform the calculation of the target detection model instruction part according to the calculation instruction to obtain the second result; wherein the calculation instruction corresponds to the instruction part one by one; The coprocessor includes a cocontroller and an operation unit, wherein the cocontroller can be used to decode the operation instruction in the instruction memory to obtain instruction decoding information; the operation unit is used to call the data in the tensor memory as input data, perform the operation of the target detection model instruction part according to the instruction decoding information, obtain the second result and write it into the tensor memory; The first sampling module comprises: A first downsampling structure consisting of two first-type branches; and, A first feature extraction structure consisting of two first-category branches and one second-category branch; The initial network includes N dimensionality reduction layers connected in sequence, where N is an integer greater than 2; the N dimensionality reduction layers include: A dimensionality reduction layer consisting of a single first downsampling structure; A dimensionality reduction layer consisting of one of the first downsampling structures and two of the first feature extraction structures connected in sequence; and A dimensionality reduction layer consisting of one of the first downsampling structures and three of the first feature extraction structures connected in sequence; The initial network further includes: N dimensionality-raising layers connected in sequence, the N dimensionality-raising layers including: A pooling layer consisting of a pooling layer, a CBL layer, and an upsampling layer connected in sequence; A fusion dimension-raising layer consisting of a feature fusion layer, a CBL fusion layer, a CBL layer, and an upsampling layer connected in sequence; An output layer consisting of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; and, The output layer consists of a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; The CBL fusion layer includes a first CBL branch, a second CBL branch, and a CBL fusion output structure, and the output ends of the first CBL branch and the second CBL branch are connected to the input end of the CBL fusion output structure; the first CBL branch and the second CBL branch are both composed of a plurality of CBL sub-layers, and the first CBL branch and the second CBL branch have different numbers of CBL sub-layers, and the CBL fusion output structure includes a feature fusion sub-layer and a CBL sub-layer connected in sequence; The auxiliary controller can be used to: perform training operations of the initial model according to the instructions sent by the control module, obtain training results and transmit them to the control module; The control module can also be used to: updating the parameters of the initial model according to the training results to obtain a trained initial model; and, The convolution layer operation and the normalization layer operation of the first type of branch in the trained initial model are merged to obtain a merged branch.

2. The target detection system according to claim 1, characterized in that: The coprocessor comprises an instruction memory, and the instruction memory is used to store the operation instruction.

3. The target detection system according to claim 1 or 2, characterized in that: The second result also includes a data result used as an input parameter to perform at least a portion of the operation of the target detection model.

4. The target detection system according to claim 3, characterized in that: The coprocessor comprises a tensor memory; the tensor memory is used to store: a first result in tensor form sent by the control module to the coprocessor; and / or, A second result in tensor form for performing at least a portion of the operations of the object detection model.

5. The target detection system according to any one of claims 1, 2 or 4, characterized in that: The convolution branches include a first type of branches, which include a convolution layer and a normalization layer connected in sequence.

6. The target detection system according to claim 5, characterized in that: The coprocessor comprises a computing unit, wherein the computing unit comprises a convolution subunit for performing convolution layer operations in the first type of branches.

7. The target detection system according to claim 6, characterized in that: The convolution subunit is composed of a preset number of multiplier-adder arrays, and the preset number matches the feature map size of the target detection model.

8. The target detection system according to claim 5, characterized in that: The coprocessor comprises an operation unit, wherein the operation unit comprises a post-processing sub-unit, and the post-processing sub-unit can be used to perform the operation of the normalization layer in the first type of branches.

9. The target detection system according to claim 5, characterized in that: The convolution branch includes a second type of branch, where the second type of branch is a directly connected branch, and the directly connected branch is used to map the value of the input end of the directly connected branch to the output end of the directly connected branch.

10. The target detection system according to claim 9, characterized in that: The coprocessor comprises an operation unit, and the operation unit comprises a direct-connection sub-unit for performing direct-connection operations in the second-type branches.

11. The target detection system according to claim 10, characterized in that: The directly connected sub-unit is composed of a shift register and a pipeline unit; through the shift register, a plurality of pipeline units can cache neighboring pixels and obtain convolution results; The pipeline unit is composed of a first number of multipliers and a second number of adders; wherein the first number is equal to the maximum value of the number of single-channel convolution kernel operations of any feature map in the target detection model; and the second number is equal to the number of convolution weights of the largest convolution kernel in the target detection model minus one.

12. The target detection system according to claim 1, characterized in that: The output end of the first downsampling structure is connected to an activation function layer.

13. The target detection system according to claim 12, characterized in that: The coprocessor includes a computing unit, which includes a post-processing sub-unit, and the post-processing sub-unit can be used to perform operations on the activation function layer.

14. The target detection system according to claim 1, wherein: For any value of i within the first specified range, the output end of the i-th dimensionality reduction layer is connected to the feature fusion layer in the j-th dimensionality increase layer, where i+j=N+1.

15. The target detection system according to claim 1, characterized in that: For any value of k within the second specified range, the output end of the CBL layer in the kth dimensionality-enhancing layer is connected to the feature fusion layer in the lth dimensionality-enhancing layer, where k+l=N+1.

16. The target detection system according to claim 1, 14 or 15, characterized in that: The output layer is used to output the target detection result of a specified size; the output end of the Nth dimensionality reduction layer is connected to the input end of the pooling dimensionality increase layer, the fusion dimensionality increase layer is arranged after the pooling dimensionality increase layer, and the output layer is arranged after the fusion dimensionality increase layer.

17. The target detection system according to claim 1, wherein: The control module can also be used to: Adjusting the convolution kernels of the merged branches in the first downsampling structure of the trained initial model to the same size in a first preset manner; and / or, The merged branch and the second type of branch in the first feature extraction structure of the trained initial model are adjusted to a convolution structure with the same convolution kernel size in a second preset manner.

18. The target detection system according to any one of claims 7 to 15, characterized in that: The operation unit includes a post-processing subunit, and the post-processing subunit includes a spare operation component, and the spare operation component can be used to perform a designated operation task of a non-convolution operation and a non-activation function operation.

19. The target detection system according to claim 8 or 13, characterized in that: The post-processing subunit is composed of the following components: The first component used to convert an integer to a floating point number; The second component for converting a floating point number to an integer; a third component for performing floating point multiplication and addition operations; and The fourth component is used to perform activation function layer operations.

20. The target detection system according to any one of claims 6 to 15, characterized in that: The tensor memory comprises: The storage space matches the input cache portion of the target image to be detected; The storage space matches a feature cache portion of a feature map tensor, wherein the feature map tensor is at least a portion of output data of any dimensionality reduction layer or dimensionality increase layer of the object detection model; A weight cache portion having a storage space matching the model weight parameter quantity of the target detection model; and, The storage space matches the output cache portion of the target detection result of the specified size.

21. The target detection system according to any one of claims 7 to 15, characterized in that: The co-controller can also be used to: store the second result calculated by the operation unit according to the instruction decoding information in a preset manner to the tensor memory according to the calculation result form information in the instruction decoding information, and the preset manner corresponds one-to-one to the calculation result form information.

22. The target detection system according to claim 21, characterized in that: According to the calculation result form information in the instruction decoding information, storing the second result calculated by the operation unit according to the instruction decoding information in a preset manner to the tensor memory includes: If it is determined that the calculation result form information in the instruction decoding information is a two-dimensional tensor, the second result in the form of a two-dimensional tensor calculated by the operation unit according to the instruction decoding information is stored in the tensor memory in sequence according to the order of channels, and the data of any channel is stored in the tensor memory in row-major order or column-major order.

23. The target detection system according to claim 21, characterized in that: According to the calculation result form information in the instruction decoding information, storing the second result calculated by the operation unit according to the instruction decoding information in a preset manner to the tensor memory includes: Determining that the calculation result form information in the instruction decoding information is a three-dimensional tensor, storing the second result in the three-dimensional tensor form calculated by the operation unit according to the instruction decoding information into a designated three-dimensional storage block of the tensor memory; Among them, the three-dimensional storage block is a plurality of storage blocks preset in the tensor memory, the storage space of any of the three-dimensional storage blocks matches the three-dimensional feature map size of the target detection model, and the storage address of any bit in the three-dimensional storage block corresponds to the channel number, tile number and row and column number in the tile of the second result in the form of a three-dimensional tensor.

24. The target detection system according to any one of claims 6 to 15, characterized in that: It also includes an image sensor; the image sensor is used to read the target image to be detected or the sample, and transmit it to the control module.

25. A target detection method, characterized in that: Applicable to control modules, including: Acquire the target image to be detected; Generate an operation instruction of a first specified structure corresponding to the target detection model, wherein the operation instruction is used to control the coprocessor to perform the operation task of the first specified structure; Obtaining a second result, where the second result includes a calculation result of the first specified structure; Performing an operation of a second specified structure of the target detection model according to the second result and / or the target image to be detected to obtain a first result; Obtaining a target detection result of the target image to be detected according to the first result and / or the second result; Wherein, the target detection model is a machine learning model obtained after the initial model is trained according to samples; The dimension reduction part of the initial model includes a first sampling module, which includes at least two convolution branches of different sizes; the dimension reduction part of the target detection model includes a second sampling module, which is obtained by fusing the convolution branches of the first sampling module; Before the step of obtaining the second result, the method further includes: generating a training instruction, wherein the training instruction is used to control the coprocessor to perform a sample-based training operation; Acquire a training result, and update the parameters of the initial model according to the training result to obtain a trained initial model, wherein the training result is a result obtained by the coprocessor according to the training instruction; The convolution layer operation and the normalization layer operation of the convolution branch in the trained initial model are merged to obtain an initial model with a merged branch; The initial network includes N dimensionality reduction layers connected in sequence, where N is an integer greater than 2; the N dimensionality reduction layers include: A dimensionality reduction layer consisting of a single first downsampling structure; A dimensionality reduction layer consisting of one of the first downsampling structures and two first feature extraction structures connected in sequence; and A dimensionality reduction layer consisting of one of the first downsampling structures and three of the first feature extraction structures connected in sequence; The initial network further includes: N dimensionality-raising layers connected in sequence, the N dimensionality-raising layers including: A pooling layer consisting of a pooling layer, a CBL layer, and an upsampling layer connected in sequence; A fusion dimension-raising layer consisting of a feature fusion layer, a CBL fusion layer, a CBL layer, and an upsampling layer connected in sequence; An output layer consisting of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; and, The output layer consists of a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; The CBL fusion layer includes a first CBL branch, a second CBL branch and a CBL fusion output structure, the output ends of the first CBL branch and the second CBL branch are connected to the input end of the CBL fusion output structure; the first CBL branch and the second CBL branch are both composed of multiple CBL sub-layers, and the number of CBL sub-layers of the first CBL branch and the second CBL branch is different, and the CBL fusion output structure includes a feature fusion sub-layer and a CBL sub-layer connected in sequence.

26. The target detection method according to claim 25, characterized in that: The first specified structure and the second specified structure constitute the target detection model.

27. The target detection method according to claim 25 or 26, characterized in that: After the step of obtaining the target image to be detected, the following steps are included: The target image to be detected is color normalized and sent to the coprocessor.

28. The target detection method according to claim 25 or 26, characterized in that: The target detection model and the initial model both include a dimensionality reduction part, a dimensionality increase part and a post-processing part connected in sequence; The dimensionality reduction part is used to extract features from the target image to be detected to obtain multiple dimensionality reduction features; the dimensionality increase part is used to perform feature fusion on the dimensionality reduction features to obtain at least one dimensionality increase feature; the post-processing part is used to perform full connection operations on the dimensionality increase features and output the target detection result.

29. The target detection method according to claim 25, characterized in that: After the step of merging the convolution layer operation and the normalization layer operation of the convolution branch in the trained initial model to obtain the initial model with the merged branch, the method further includes: Perform the following steps to obtain the target detection model: Adjusting the convolution kernels of the merged branches to the same size in a first preset manner; and / or, The merged branch and the directly connected branch are adjusted to a convolution structure having the same convolution kernel size in a second preset manner.

30. The target detection method according to claim 29, characterized in that: After the step of obtaining the target detection model, the method further includes: The model weight parameters of the target detection model are sent to the coprocessor.

31. The target detection method according to claim 28, characterized in that: The second specified structure includes a fully connected layer and / or a non-maximum suppression layer in a post-processing portion of the target detection model.

32. A target detection method, characterized in that: Applicable to coprocessors, including: Acquire an operation instruction generated by a control module corresponding to a first specified structure of a target detection model; Performing an operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result; the second result is used as an input parameter for the control module to perform at least a part of the operation of the second specified structure of the target detection model; and / or is used as an input parameter to obtain a target detection result of a target image to be detected; The target detection model is a machine learning model obtained after the initial model is trained according to samples; Before the step of acquiring the operation instruction corresponding to the first specified structure of the target detection model generated by the control module, the method further includes: Obtaining a training instruction, and performing a sample-based training operation according to the training instruction to obtain a training result; The dimension reduction part of the initial model includes a first sampling module, which includes at least two convolution branches of different sizes; the dimension reduction part of the target detection model includes a second sampling module, which is obtained by fusing the convolution branches of the first sampling module; The initial network includes N dimensionality reduction layers connected in sequence, where N is an integer greater than 2; the N dimensionality reduction layers include: A dimensionality reduction layer consisting of a single first downsampling structure; A dimensionality reduction layer consisting of one of the first downsampling structures and two first feature extraction structures connected in sequence; and A dimensionality reduction layer consisting of one of the first downsampling structures and three of the first feature extraction structures connected in sequence; The initial network further includes: N dimensionality-raising layers connected in sequence, the N dimensionality-raising layers including: A pooling layer consisting of a pooling layer, a CBL layer, and an upsampling layer connected in sequence; A fusion dimension-raising layer consisting of a feature fusion layer, a CBL fusion layer, a CBL layer, and an upsampling layer connected in sequence; An output layer consisting of a CBL layer, a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; and, The output layer consists of a feature fusion layer, a CBL fusion layer, and a convolutional layer connected in sequence; The CBL fusion layer includes a first CBL branch, a second CBL branch and a CBL fusion output structure, the output ends of the first CBL branch and the second CBL branch are connected to the input end of the CBL fusion output structure; the first CBL branch and the second CBL branch are both composed of multiple CBL sub-layers, and the number of CBL sub-layers of the first CBL branch and the second CBL branch is different, and the CBL fusion output structure includes a feature fusion sub-layer and a CBL sub-layer connected in sequence.

33. The target detection method according to claim 32, characterized in that: The first specified structure and the second specified structure constitute the target detection model.

34. The target detection method according to claim 32 or 33, characterized in that: Before the step of acquiring the operation instruction corresponding to the first specified structure of the target detection model generated by the control module, the method further includes: Obtain model weight parameters of the target detection model, where the model weight parameters are used to perform operations of a first specified structure of the target detection model.

35. The target detection method according to claim 32 or 33, characterized in that: The target detection model and the initial model both include a dimensionality reduction part, a dimensionality increase part and a post-processing part connected in sequence; The dimensionality reduction part is used to extract features from the target image to be detected to obtain multiple dimensionality reduction features; the dimensionality increase part is used to perform feature fusion on the dimensionality reduction features to obtain at least one dimensionality increase feature; the post-processing part is used to perform full connection operations on the dimensionality increase features and output the target detection result.

36. The target detection method according to claim 35, characterized in that: The first specified structure includes: The downsampling layer, feature extraction layer, normalization layer, direct connection branch and activation function layer in the dimension-increasing part of the target detection model; and, The pooling layer, CBL layer, upsampling layer, feature fusion layer and activation function layer in the dimension reduction part of the target detection model.

37. The target detection method according to claim 36, characterized in that: The downsampling layer includes a convolution layer, a normalization layer and an activation function layer; the feature extraction layer includes a convolution layer, a normalization layer and a direct connection branch; The step of performing the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result includes: Determining that the operation instruction is a convolution layer operation, calling the convolution subunit to perform the operation; Determining that the operation instruction is a direct branch operation, calling the direct subunit to perform the operation; If it is determined that the operation instruction is a normalization layer operation or an activation function layer operation, the post-processing subunit is called to perform the operation.

38. A target detection control device, characterized in that: Used to implement the target detection method as claimed in claim 25, comprising: A first acquisition component is used to acquire an image of a target to be detected; An instruction component, used to generate an operation instruction of a first specified structure corresponding to the target detection model, wherein the operation instruction is used to control the coprocessor to perform the operation task of the first specified structure; A second acquisition component is used to acquire a second result, wherein the second result includes a calculation result of the first specified structure; A first operation component is used to perform an operation of a second specified structure of the target detection model according to the second result and / or the target image to be detected to obtain a first result; A classification component, configured to obtain a target detection result of the target image to be detected according to the first result and / or the second result; The target detection model is a machine learning model obtained after the initial model is trained based on samples.

39. A target detection co-processing device, characterized in that: Used to implement the target detection method as claimed in claim 32, comprising: A third acquisition component is used to acquire an operation instruction corresponding to a first specified structure of the target detection model generated by the control module; A second operation component is used to perform the operation of the first specified structure of the target detection model according to the operation instruction to obtain a second result; the second result is used as an input parameter for the control module to perform at least a part of the operation of the second specified structure of the target detection model; and / or is used as an input parameter to obtain the target detection result of the target image to be detected; The target detection model is a machine learning model obtained after the initial model is trained based on samples.

40. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 25 to 31 or the method according to any one of claims 32 to 37 is implemented.

41. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 25 to 31 or the method according to any one of claims 32 to 37 is implemented.

Citation Information

Patent Citations

  • Task processing method, electronic equipment, storage medium and computer program product

    CN115098245A

  • Target rapid detection system based on FPGA

    CN115330683A