Target detection and identification method and multi-task network model construction and training method

By combining object detection and image quality evaluation in the multi-task network model, cropping and identifying only when the target image quality meets the conditions, the problem of model training time and resource occupation in the prior art is solved, and the transmission cost is reduced and monitoring is improved. The effect of system efficiency.

CN118887380APending Publication Date: 2024-11-01SHENZHEN BAICHUAN SECURITY TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410848576.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-26
Publication Date
2024-11-01

AI Technical Summary

Technical Problem

When combining target image quality evaluation with target detection and target recognition tasks, the prior art increases the model training time, camera memory and bandwidth load, and cannot save the number of cloud server calls and target image transmission costs.

Method used

Design a multi-task network model, including feature extraction module, multi-scale feature fusion module and detection head module. The detection head module includes detection regression branch, category prediction branch and quality evaluation branch, and object detection and category detection by extracting video images frame by frame Prediction and image quality evaluation, crop and identify only when the target image quality meets preset conditions.

Benefits of technology

It reduces the number of calls to the target recognition model, reduces the cost of target image data transmission between the camera and the cloud, reduces bandwidth load and memory usage, and improves the efficiency and reliability of the monitoring system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118887380A_ABST
    Figure CN118887380A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image processing, and discloses a target detection and identification method and a multi-task network model construction and training method. The target detection and identification method comprises the following steps: extracting video images frame by frame from a video collected by a camera device; inputting the video images into the multi-task network model one by one to obtain a prediction feature map; performing post-processing on the prediction feature map to obtain a target detection result; judging whether the target category confidence is greater than a preset confidence; if yes, judging whether the target image quality score is greater than a preset score; if yes, cutting a target image from the video image according to the four-dimensional target detection frame; and inputting the target image into a target recognition model corresponding to the target category to obtain a target name. Through the above mode, the calling frequency of the identification model is reduced, the transmission cost of the target image data in the mode of camera end detection and cloud server identification is reduced, and meanwhile, the model training duration, the camera end memory and the bandwidth load are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of image processing technology, and specifically to a target detection and recognition method, a method for constructing and training a multi-task network model, an electronic device, and a computer-readable storage medium. Background Art

[0002] Intelligent video surveillance is an important aspect in the field of computer vision. Its main task is to extract targets of interest from video images of dynamic scenes using technologies such as target detection and target recognition.

[0003] At present, deep learning has become the main technical route for target image quality assessment, target detection and target recognition tasks. In video surveillance scenarios, high-quality images not only help to identify targets more accurately, but also significantly reduce the misidentification rate, thereby improving the reliability and efficiency of the monitoring system. Therefore, combining target image quality assessment with target detection and target recognition tasks has become an important trend in the development of current video surveillance technology.

[0004] In the process of combining target image quality assessment with target detection and target recognition tasks, the first technical solution based on deep learning is to design target detection, target image quality assessment and target recognition as independent task algorithms, and the second technical solution is to design target detection as an independent task algorithm, and design target image quality assessment and target recognition as single-model multi-task algorithms. Among them, the model accuracy of the first solution is high, which can significantly reduce the misrecognition rate, but because an independent image quality assessment model is required, the model training time, camera end memory and bandwidth load are increased, which is not suitable for scenes with limited camera end resources and high real-time requirements. The second solution integrates the target image quality assessment into the target recognition algorithm and becomes an independent functional branch of the target recognition model, which reduces the memory usage of the camera end of the model and is more friendly to scenes with limited camera end resources. However, it cannot reduce the number of calls to the cloud server target recognition model. For the target detection mode on the camera end and the target recognition mode on the cloud server, it cannot save the cost of the camera end transmitting the target image to the cloud server. Summary of the invention

[0005] In view of the above problems, the embodiments of the present application provide a target detection and recognition method, a method for constructing and training a multi-task network model, an electronic device and a computer-readable storage medium, which reduce the number of times the recognition model is called, and reduce the transmission cost of target image data in the modes of target detection on the camera end and target recognition on the cloud server. At the same time, it also solves the problems of long model training time, heavy memory occupation and bandwidth load on the camera end in the prior art.

[0006] According to one aspect of an embodiment of the present application, a target detection and recognition method is provided, the method comprising: extracting video images frame by frame from a video captured by a camera device; inputting the video images one by one into a multi-task network model to obtain a predicted feature map, wherein the multi-task network model comprises a feature extraction module, a multi-scale feature fusion module and a detection head module, the detection head module comprises multiple scale branches, each scale branch comprises a detection regression branch, a category prediction branch and a quality assessment branch, the last convolution layer of the quality assessment branch is connected in parallel with the last convolution layer of the detection regression branch, the quality assessment branch and the detection regression branch share the remaining convolution layers, the predicted feature map contains a target detection box, a target category confidence and a target image quality score of multiple candidate boxes, and the target detection The detection frame is output by the detection regression branch, the target category confidence is output by the category prediction branch, and the target image quality score is output by the quality assessment branch; the predicted feature map is post-processed to obtain the target detection result, which includes the four-dimensional target detection frame, the target category confidence and the target image quality score; it is determined whether the target category confidence of the target detection result is greater than the preset confidence; if the target category confidence of the target detection result is greater than the preset confidence, it is determined whether the target image quality score of the target detection result is greater than the preset score; if the target image quality score of the target detection result is greater than the preset score, the target image is cropped from the video image according to the four-dimensional target detection frame; the target image is input into the target recognition model to identify the target name of the target image.

[0007] In an optional manner, post-processing the predicted feature map to obtain the target detection result includes: performing non-maximum suppression processing on the predicted feature map to filter out the target detection result from multiple candidate frames; decoding the target detection frame of the target detection result to obtain a four-dimensional target detection frame.

[0008] In an optional manner, video images are input into a multi-task network model one by one to obtain predicted feature maps, including: inputting video images into a feature extraction module one by one, extracting features of the video images through the feature extraction module, and obtaining feature maps of the video images at different scales; inputting feature maps at different scales into a multi-scale feature fusion module, and performing feature fusion on feature maps at different scales through the multi-scale feature fusion module to obtain fused feature maps of the video images at different scales; inputting fused feature maps at different scales into a detection head module; performing target detection prediction on the fused feature maps through a detection regression branch to obtain target detection frames of multiple candidate frames; performing target category prediction on the fused feature maps through a category prediction branch to obtain target category confidences of multiple candidate frames; and performing quality assessment prediction on the fused feature maps through a quality assessment branch to obtain target image quality scores of multiple candidate frames.

[0009] According to another aspect of an embodiment of the present application, a method for constructing and training a multi-task network model for target detection and recognition is provided, the method comprising: constructing a multi-task network model, the multi-task network model comprising a feature extraction module, a multi-scale feature fusion module and a detection head module, the detection head module comprising multiple scale branches, each scale branch comprising a detection regression branch, a category prediction branch and a quality assessment branch, the last convolutional layer of the quality assessment branch is connected in parallel with the last convolutional layer of the detection regression branch, and the quality assessment branch and the detection regression branch share the remaining convolutional layers; constructing a loss function calculation module; randomly extracting multiple training images from a training image set to form a batch image, wherein the training image set comprises multiple training images annotated with labels, the labels comprising a target label box, a category label and a quality label score; inputting the training images in the batch image into the multi-task network model one by one to obtain a predicted feature map, wherein In the method, the target detection box, target category confidence and target image quality score of multiple candidate boxes are predicted in the feature map, the detection regression branch outputs the target detection box, the category prediction branch outputs the target category confidence, and the quality assessment branch outputs the target image quality score; the target detection box, target category confidence, target image quality score of the multiple candidate boxes and the target label box, category label, and quality label score of the training image in the batch image are input into the loss function calculation module to obtain the model loss of the multi-task network model; the back propagation algorithm is used to calculate the gradient of the model loss for each parameter of the multi-task network model, and the parameters of the multi-task network model are updated according to the gradient; it is determined whether the multi-task network model converges; if the multi-task network model converges, the weights of the multi-task network model are saved; if the multi-task network model does not converge, the step of randomly extracting multiple training images from the training image set to form a batch image is executed.

[0010] In an optional manner, the total number of images in a batch is N, where N ≥ 1; the model loss L of the multi-task network model is sum For: L sum =λ cls L cls +λ box L box +λ dfl L dfl +λ iqa L iqa , where L cls represents the category loss of the multi-task network model, L box represents the bounding box regression loss of the multi-task network model, L dfl represents the category distribution loss of the multi-task network model, L iqa represents the image quality assessment loss of the multi-task network model, λ cls , box , dfl and λ iqaRespectively represent L cls , L box , L dfl and L iqa The weight of the image quality assessment loss L of the multi-task network model iqa for: Among them, IQA gt Represents the quality label score of the training image, IQA pred It represents the target image quality score of the training image. IoU represents the ratio of the intersection area to the union area of ​​the target label box and the target detection box of the training image. Flag represents the flag bit of whether the training image has a quality label score. If the training image has a quality label score, flag is 1. If the training image does not have a quality label score, flag is 0.

[0011] In an optional manner, the method also includes: constructing a data enhancement module, the data enhancement module uses at least one of a plurality of data enhancement methods to perform data enhancement on the image, the plurality of data enhancement methods including a color transformation method, a scale transformation method, an up-down flip transformation method, a left-right flip transformation method, a rotation transformation method, and a target copy-paste transformation method; inputting the training images in the batch images one by one into the multi-task network model to obtain a predicted feature map, including: inputting the training images in the batch images one by one into the data enhancement module to obtain a data enhanced image; and inputting the data enhanced image into the multi-task network model to obtain a predicted feature map.

[0012] In an optional manner, the method further includes: verifying the multi-task network model, and the verification method of the multi-task network model includes the following steps: loading the weights of the multi-task network model saved in the current training round; inputting the verification image in the verification image set into the multi-task network model to obtain the target detection frame, target category confidence, and target image quality score of the verification image, wherein the verification image set includes multiple verification images annotated with labels, and the labels include target label frames, category labels, and quality label scores; according to the target detection frame, target category confidence, and target image quality score of the verification image and the target label frame, category label, and quality label score of the training image, The method comprises the steps of calculating the model index of the current training round of the multi-task network model; judging whether the model index of the current training round is greater than the preset index; if the model index of the current training round is greater than the preset index, taking the weight of the multi-task network model of the current training round as the optimal network weight, and using the model index of the current training round to update the preset index, and executing the step of randomly extracting multiple training images from the training image set to form a batch image until the maximum training round is reached; if the model index of the current training round is less than or equal to the preset index, executing the step of randomly extracting multiple training images from the training image set to form a batch image until the maximum training round is reached.

[0013] In an optional manner, the method also includes: testing the multi-task network model, and the testing method of the multi-task network model includes the following steps: loading the saved weights of the multi-task network model; inputting the test image into the multi-task network model to obtain the target detection result of the test image, the target detection result including a four-dimensional target detection box, a target category confidence and a target image quality score; judging whether the target category confidence of the target detection result is greater than a preset confidence; if the target category confidence of the target detection result is greater than the preset confidence, outputting the four-dimensional target detection box, the target category corresponding to the highest target category confidence and the target image quality score; if the target category confidence of the target detection result is less than or equal to the preset confidence, inputting the test image into the multi-task network model to obtain the target detection result of the test image.

[0014] In an optional manner, the method also includes: generating an image quality label interface and displaying it on a display screen of an electronic device; displaying a training image and a target rectangular frame on the image quality label interface; when the target rectangular frame is selected, masking all backgrounds outside the selected target foreground of the training image, and the image within the target rectangular frame is the target image; and scoring the quality of the target image to obtain a quality label score.

[0015] In the embodiment of the present application, the video images extracted frame by frame are input into a multi-task network model for target detection, target category prediction and image quality assessment, so as to obtain a predicted feature map including a target detection frame of multiple candidate frames, a target category confidence and a target image quality score; the target detection result is obtained by post-processing the predicted feature map, and when the target category confidence of the target detection result is greater than a preset confidence and the target image quality score of the target detection result is greater than a preset score, a target image containing only the target foreground obtained by cropping the video image according to the four-dimensional target detection frame of the target detection result is input into a target recognition model for target recognition to obtain a target name; by predicting an image containing only the target foreground and predicting the quality of the image through a multi-task network model, the quality of the target image input into the target recognition model can be controlled, which not only effectively reduces the target misrecognition rate, but also reduces the number of calls to the target recognition model and reduces the operating load of the camera device. In addition, in the mode of target detection at the camera end and target recognition at the cloud server, the transmission cost of the target image data can be reduced, and useless information storage can be avoided, thereby reducing bandwidth load and memory occupancy.

[0016] According to another aspect of an embodiment of the present application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the target detection and recognition method or the multi-task network model construction and training method provided in any of the above embodiments.

[0017] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, and when the computer program is executed by a processor, the steps of the target detection and recognition method or the multi-task network model construction and training method provided in any of the above embodiments are implemented.

[0018] The above description is only an overview of the technical solution of the embodiment of the present application. In order to more clearly understand the technical means of the embodiment of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present application. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:

[0020] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application is shown;

[0021] Figure 2 A schematic diagram of a process for constructing and training a multi-task network model provided in an embodiment of the present application is shown;

[0022] Figure 3 A schematic diagram of the structure of a multi-task network model provided in an embodiment of the present application is shown;

[0023] Figure 4 A schematic diagram of the structure of the detection head module provided in an embodiment of the present application is shown;

[0024] Figure 5 A flow chart of a verification method for a multi-task network model provided in an embodiment of the present application is shown;

[0025] Figure 6 A flow chart of a method for testing a multi-task network model provided in an embodiment of the present application is shown;

[0026] Figure 7 A flow chart of a target detection and recognition method provided by an embodiment of the present application is shown;

[0027] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0028] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein.

[0029] Figure 1The schematic diagram of the application scenario provided by the embodiment of the present application is shown. As shown in the figure, the camera device 1 establishes a communication connection with the cloud server 2 through the network 3, and the terminal device 4 establishes a communication connection with the cloud server 2 through the network 3. The camera device 1 can be a camera for security monitoring, an animal monitoring camera, an IP camera or other video monitoring equipment, the network 3 includes but is not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a 4G / 5G network, WIFI, Bluetooth and a point-to-point (P2P) communication network. One or more, the terminal device 4 can be a touch-screen mobile phone, a smart phone, a tablet computer, a computer, a portable terminal device or other terminal electronic device with a display screen.

[0030] In the embodiment of the present application, the camera device 1 and the terminal device 4 may include one or more processors, which may be a central processing unit CPU, or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the present embodiment, which is not limited here. The one or more processors included in the terminal device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs, which is not limited here.

[0031] The camera device 1 is installed in an area that needs to be monitored (such as a home, office, shopping mall, field, road, etc.) so that the camera device 1 can capture the monitoring video in the monitoring area. After capturing the monitoring video, the camera device 1 can extract the video image frame by frame, and after performing target detection and target image quality assessment on the video image, the target image whose target image quality assessment meets the expected threshold can be uploaded to the cloud server 2 through the network 3. After the cloud server 2 performs target recognition on the target image, the target image and the recognized target name are sent to the terminal device 4 through the network 3 for the user to browse.

[0032] For example, when the camera device 1 captures a video of animal A, the camera device 1 can extract a video image from the video, perform target detection and target image quality assessment on the video image, and then send the target image that includes animal A and whose target image quality meets the expected threshold to the cloud server 2. The cloud server 2 identifies the target image and, after obtaining the target name animal A, sends the target image and target name to the terminal device 4 via the network 3.

[0033] In some application scenarios where the camera device 1 has target detection, target image quality assessment and target recognition functions, when the camera device 1 captures a video of animal A, the camera device 1 extracts a video image from the video, performs target detection and target image quality assessment on the video image, and then directly identifies the target image that includes animal A and whose target image quality meets the expected threshold, obtains the target name animal A, and then sends the target image and target name to the terminal device 4 via the network 3.

[0034] In some application scenarios where the camera device 1 does not have a target recognition function, when the camera device 1 captures a video of animal A, the camera device 1 extracts a video image from the video, and after performing target detection and target image quality assessment on the video image, the camera device 1 sends a target image including animal A and whose target image quality meets an expected threshold to the cloud server 2 via the network 3. The cloud server 2 identifies the target image and obtains the target name animal A. The cloud server 2 then sends the target image and target name to the terminal device 4 via the network 3 for display to the user.

[0035] The embodiment of the present application uses a trained multi-task network model to perform target detection, target category confidence detection and target image quality assessment on the video image to obtain a predicted feature map. The target image quality is then judged based on the predicted feature map, and the target image is cropped when the target image quality meets the preset requirements, and the target image is identified. First, the construction and training method of the multi-task network model used in the embodiment of the present application is introduced.

[0036] Figure 2 A flow chart of a method for constructing and training a multi-task network model provided in an embodiment of the present application is shown. This method can be completed by a local offline electronic device (such as an offline computer device) to construct and train the multi-task network model, and the trained multi-task network model can be loaded into the AI ​​chip of the camera device 1. The multi-task network model is used to perform target detection and target image quality assessment on images containing any target (such as faces, animals, vehicles, etc.). Target detection and target image quality assessment can be performed on images containing one target, and target detection and target image quality assessment can also be performed on images containing multiple targets. For example, when performing target detection and target image quality assessment on an image extracted from a video captured by the camera device 1, the camera device 1 can send the video image to the terminal device 4 via the network 3, and the target image and target name detected from the video image are displayed on the terminal device 4. Figure 2 As shown, the construction and training method of the multi-task network model includes the following steps:

[0037] Step S110: construct a multi-task network model.

[0038] Before building a multi-task network model, you need to build the dataset required by the multi-task network model. The dataset can be divided into a training image set and a validation image set, including but not limited to animal images, face images, car images, etc. The training image set is used to learn model parameters, and the validation image set is used to adjust model configuration, evaluate model performance, and prevent overfitting. By reasonably dividing the dataset and using the dataset to train and evaluate the model, the model's ability to generalize to new data in practical applications can be increased.

[0039] The training image set includes multiple training images annotated with labels, and the labels include target label boxes, category labels, and quality label scores. The verification image set includes multiple verification images annotated with labels, and the labels include target label boxes, category labels, and quality label scores. Specifically, the target label box is a rectangular box used to indicate the position and size of the target in the image, the category label indicates the target category in the target label box, and the quality label score refers to the evaluation value of the image quality in the target label box, which can be scored based on specific image quality indicators or evaluation criteria, such as resolution, color depth, contrast, noise level, etc. Training images include but are not limited to images of people, animals, cars, etc.

[0040] Taking an animal image as an example, the target label box indicates the position and size of the animal in the image. When the category label is 0, it means that the target category in the target label box is an animal. The quality label score indicates the evaluation value of the image quality of the animal in the target label box. When the image includes multiple animals, each animal has a corresponding target label box, category label, and quality label score.

[0041] In the embodiments of the present application, animal images are taken as an example to illustrate the process of constructing a training image set and a verification image set.

[0042] Collect public animal data sets from the Internet, collect animal videos from various cameras, and extract images frame by frame to form a proprietary data set. Integrate public data sets and proprietary data sets, and use image annotation software (such as LabelImg) to draw a target label box on the image, where the target label box can be a rectangular box, a polygonal box, etc. Take the animal in each animal image as the target. When the image includes multiple animals, draw a target label box one by one with each animal as the target. Set a category label for each target label box. For example, if the category label is set to 0, it means that the target category in the target label box is an animal, thereby forming an animal detection data set.

[0043] The animal detection dataset is randomly divided into dataset A and dataset B in a ratio of 1:1. Image quality scores are scored for all images in dataset A to obtain quality label scores, such as quality label scores within a range of 0 to 10. The quality label scores of all images in dataset B are set to 0, indicating that the quality label scores are not labeled. At this point, the construction of the animal detection dataset and the target image quality dataset is completed.

[0044] Datasets A and B are randomly divided into training sets and validation sets in a ratio of 9:1. The training set of dataset A and the training set of dataset B are integrated to obtain the training image set, and the validation set of dataset A and the validation set of dataset B are integrated to obtain the validation image set, which are used for training and validation of the model respectively.

[0045] At this point, the construction of the training image set and the verification image set is completed.

[0046] In some embodiments, the target image quality labeling software independently developed based on the LabelImg software can be used to perform image quality scores on all images in the dataset A to obtain a quality label score for each image. Specifically, an image quality label interface is first generated, and the image quality label interface is displayed on an electronic device (e.g., an offline computer device, Figure 1 The image and target rectangular frame of data set A are displayed on the display screen of the offline electronic device (not shown). The target rectangular frame can be the target label frame drawn as above or a redrawn rectangular frame. When the target rectangular frame is clicked, that is, when the target rectangular frame is selected, the software masks all the backgrounds outside the target rectangular frame (that is, the target foreground) in the image, and the image inside the target rectangular frame obtained after eliminating the background interference is the target image. Finally, the quality score of the target image can be obtained by scoring the quality of the target image.

[0047] Figure 3 The schematic diagram of the structure of the multi-task network model provided by the embodiment of the present application is shown. As shown in the figure, the multi-task network model includes a feature extraction module, a multi-scale fusion module and a detection head module. Among them, the detection head module includes multiple scale branches, for example, it can include three scale branches of large, medium and small, each scale branch includes a detection regression branch, a category prediction branch and a quality assessment branch, the last convolution layer of the quality assessment branch is connected in parallel with the last convolution layer of the detection regression branch, and the quality assessment branch and the detection regression branch share the remaining convolution layers.

[0048] Among them, the feature extraction module can extract features from the image to obtain a feature map with rich image information. Multiple convolution modules can be set in the feature extraction module, for example, 4 convolution modules are set: Module1, Module2, Module3, Module4, and the image input to the feature extraction module is sequentially extracted to obtain multiple feature maps at different scales, for example, feature maps of three scales: large, medium, and small.

[0049] The multi-scale fusion module is used to perform feature fusion on multiple feature maps at different scales output by the feature extraction module. In the embodiment of the present application, after the multi-scale fusion module performs feature fusion on the feature maps, three fused feature maps with deep semantic information and shallow positioning information, namely, large scale, medium scale and small scale, can be obtained.

[0050] Figure 4 FIG. 4 shows a schematic diagram of the structure of the detection head module in an embodiment of the present application. Figure 4 As shown in Figure 1, the detection regression branch, category prediction branch, and quality assessment branch of each scale branch of the detection head module perform target detection prediction, category prediction, and quality assessment prediction for each candidate box respectively. Figure 3 As shown, different scale branches of the detection head module respectively perform target detection prediction, category prediction and quality assessment prediction on multiple candidate boxes of fused feature maps at different scales. For example, the detection regression branch, category prediction branch and quality assessment branch of the large-scale branch in the detection head module perform target detection prediction, category prediction and quality assessment prediction on the large-scale fused feature map.

[0051] Since the target image input to the target recognition model is a local image that only contains the target foreground, it is only necessary to perform quality assessment on the local image of each target in the image. This is strongly related to the detection regression branch of the detection head module. The last convolutional layer of the quality assessment branch is connected in parallel with the last convolutional layer of the detection regression branch. The quality assessment branch and the detection regression branch share the remaining convolutional layers, which can achieve the purpose of predicting the local image quality of each target.

[0052] like Figure 4As shown, the detection regression branch, the category prediction branch, and the quality assessment branch can each include three convolutional layers: convolutional layer 1, convolutional layer 2, and convolutional layer 3, wherein the parameters of convolutional layer 1 and convolutional layer 2 of the detection regression branch and the quality assessment branch are shared. For example, the number of convolutional kernels in convolutional layer 1, convolutional layer 2, and convolutional layer 3 of the detection regression branch can be set to 64, 64, 64 respectively, the depth of the convolutional kernel can be set to 512, 64, 64 respectively, the size of the convolutional kernel can be set to 3×3, 3×3, 1×1 respectively, and the bias can be set to 64, 64, 64 respectively; the number of convolutional kernels in convolutional layer 1, convolutional layer 2, and convolutional layer 3 of the quality assessment branch can be set to 64, 64, 1 respectively, and the depth of the convolutional kernel can be set to 512, 64, 64 respectively. The numbers of convolution kernels in convolution layer 1, convolution layer 2 and convolution layer 3 of the category prediction branch can be set to 128, 128 and 1 respectively, the depths of the convolution kernels can be set to 512, 128 and 1 respectively, the sizes of the convolution kernels can be set to 3×3, 3×3 and 1×1 respectively, and the biases can be set to 128, 128 and 1 respectively.

[0053] Step S120: construct a loss function calculation module.

[0054] Specifically, let the total number of images in the batch be N, where N ≥ 1, and the category loss L of the multi-task network model cls The calculation formula is:

[0055]

[0056] Among them, y i represents the category label of the i-th target label box, p i represents the target category confidence of the target inside the i-th target detection box. When the category label of the i-th target label box is animal, y i is 1, when the category label of the i-th target label box is not an animal, y i Then it is 0. At this time, p i It represents the category confidence that the target in the i-th target detection box is an animal.

[0057] Bounding box regression loss L for multi-task network model box The calculation formula is:

[0058]

[0059] Among them, ρ(b,b gt ) represents the target label box b gtThe distance between the center point of the target detection box b, c represents the diagonal length of the minimum rectangular box (union) that encloses the target label box and the target detection box, IoU represents the ratio of the intersection area of ​​the target label box and the target detection box to the union area of ​​the target label box and the target detection box, w gt 、h gt , w, and h represent the width and height of the target label box and the target detection box respectively.

[0060] Category distribution loss L for multi-task network models dfl The calculation formula is:

[0061] L dfl =DFL(S i ,S i+1 )=-((y i+1 -y)log(S i )+(yy i )log(S i+1 )), Formula 3

[0062]

[0063] Among them, y represents the target category confidence of the target label box, y i ,y i+1 They represent the two nearest values ​​of y respectively.

[0064] Image quality assessment loss L for multi-task network model iqa The calculation formula is:

[0065]

[0066] Among them, IQA gt Represents the quality label score of the image within the target label box of the training image, IQA pred It represents the target image quality score of the image within the target detection box of the training image. IoU represents the ratio of the intersection area to the union area of ​​the target label box and the target detection box of the training image. Flag represents the flag bit of whether there is a quality label score for the training image. If there is a quality label score for the training image, flag is 1. If there is no quality label score for the training image, flag is 0.

[0067] Model loss L of the multi-task network model sum The calculation formula is:

[0068] L sum = cls L cls + box L box + dfl L dfl + iqa Liqa , Formula 5

[0069] Among them, L cls represents the category loss of the multi-task network model, L box represents the bounding box regression loss of the multi-task network model, L dfl represents the category distribution loss of the multi-task network model, L iqa represents the image quality assessment loss of the multi-task network model, λ cls , box , dfl and λ iqa Respectively represent L cls , L box , L dfl and L iqa The weight of .

[0070] Step S130: randomly extracting multiple training images from the training image set to form a batch of images.

[0071] The training image set includes multiple training images annotated with labels, and the labels include target label boxes, category labels, and quality label scores.

[0072] Specifically, a plurality of training images are randomly extracted from the aforementioned constructed training image set to form a batch of images. Preferably, the total number of training images extracted each time is fixed to N, where N≥1.

[0073] Step S140: input the training images in the batch of images one by one into the multi-task network model to obtain a predicted feature map.

[0074] Among them, the predicted feature map contains target detection boxes, target category confidences and target image quality scores for multiple candidate boxes. The detection regression branch outputs the target detection box, the category prediction branch outputs the target category confidence, and the quality assessment branch outputs the target image quality score.

[0075] Step S140 specifically includes:

[0076] Step a1: Input the video images one by one into the feature extraction module, extract features from the video images through the feature extraction module, and obtain feature maps of the video images at different scales.

[0077] Step a2: Input the feature maps at different scales into the multi-scale feature fusion module, and perform feature fusion on the feature maps at different scales through the multi-scale feature fusion module to obtain fused feature maps of the video image at different scales.

[0078] Step a3: Input the fused feature maps at different scales into the detection head module, perform target detection prediction on the fused feature maps through the detection regression branch to obtain target detection frames of multiple candidate frames; perform target category prediction on the fused feature maps through the category prediction branch to obtain target category confidences of multiple candidate frames; perform quality assessment prediction on the fused feature maps through the quality assessment branch to obtain target image quality scores of multiple candidate frames.

[0079] During the model training process, N training images in the batch of images are sequentially input into the multi-task network model to train the model.

[0080] In an embodiment of the present application, a training image is input, and the multi-task network model outputs prediction feature maps of different scales of the training image. For example, the large, medium, and small scale branches in the detection head module correspond to the output of prediction feature maps of large, medium, and small scales of the training image, respectively. Each prediction feature map includes multiple candidate boxes and the detection results predicted by each candidate box, wherein the detection results include the target detection box, the target category confidence, and the target image quality score. Specifically, the target detection box refers to the position and size of the target predicted by the detection regression branch in the training image, expressed as an integral, the target category confidence refers to the possibility that the target in the target detection box predicted by the category prediction branch is a certain category (such as an animal), and the target image quality score refers to the evaluation value of the image quality in the target detection box predicted by the quality evaluation branch.

[0081] A method of sharing parameters of the detection regression branch and the quality assessment branch is adopted to perform target image quality assessment on each image within the target detection box predicted by the detection regression branch. This enables the model to focus on the target foreground image quality in the input image when the model input is an image containing foreground and background, thereby effectively preventing the negative impact of background quality on the prediction of target foreground image quality. Furthermore, the function of target image quality assessment can be realized without increasing the memory occupancy of the camera device 1 while avoiding increasing the size of the target detection model and affecting the performance of the target detection model. In addition, the problem of being unable to independently add a target image quality assessment model due to limited resources of the camera device 1 is effectively solved.

[0082] As mentioned above, the feature extraction module can extract features from the training image to obtain feature maps at different scales, and the multi-scale fusion module can fuse the feature maps at different scales to obtain fused feature maps at different scales. Finally, the detection regression branch, category prediction branch, and quality assessment branch of the multiple scale branches of the detection head module respectively perform target detection prediction, target category prediction, and quality assessment prediction on the fused feature maps at different scales, and predict target detection boxes, target category confidence, and target image quality scores for multiple candidate boxes. This process is described in detail below.

[0083] like Figure 3 As shown, after the training image P1 is input into the feature extraction module, feature extraction is performed by Module1 and Module2 to obtain feature map P2. Feature map P2 is extracted by Module3 to obtain feature map P3. Feature map P3 is extracted by Module4 to obtain feature map P4.

[0084] Feature maps P2-P4 are input to the multi-scale fusion module; after one upsampling and one convolution layer, feature map P4 is fused with feature map P3 to obtain fused feature map F1; after one convolution layer and one upsampling, fused feature map F1 is fused with feature map P2 to obtain fused feature map F2; after one convolution layer, fused feature map F2 is fused with fused feature map T1; after one downsampling, fused feature map F1 is fused with one convolution layer to obtain fused feature map F2; after one convolution layer, fused feature map T2 is fused with one convolution layer to obtain fused feature map T2; after one downsampling, fused feature map T2 is fused with feature map P4 to obtain fused feature map F3; after one convolution layer, fused feature map F3 is fused with one convolution layer to obtain fused feature map T3; finally, the fused feature maps input to the detection head module by the multi-scale fusion module are: fused feature map T1, fused feature map T2 and fused feature map T3.

[0085] The detection regression branch of each scale branch performs target detection prediction on the fused feature map T1, the fused feature map T2 and the fused feature map T3 respectively, and obtains the target detection box boxes predicted by multiple candidate boxes; the last convolution layer of the quality assessment branch of each scale branch performs quality assessment prediction on the images in the multiple target detection boxes in the fused feature map T1, the fused feature map T2 and the fused feature map T3 respectively, and obtains the target image quality scores iqa predicted by multiple candidate boxes; the category prediction branch of each scale branch performs target category prediction on the targets in the multiple target detection boxes in the fused feature map T1, the fused feature map T2 and the fused feature map T3 respectively, and obtains the target category confidence cls predicted by multiple candidate boxes.

[0086] After step a3, the target detection boxes, target category confidences, and target image quality scores predicted by multiple candidate boxes can be concat and reshaped. Specifically, the prediction results of the prediction feature maps of different scales are connected through the concat operation, and the model can process the prediction results of all scales in one framework, which is convenient for subsequent non-maximum suppression (NMS) processing. The reshape operation can ensure that the shape of the prediction results matches the input requirements of the subsequent processing steps, thereby avoiding unnecessary data conversion and data errors.

[0087] Taking the batch image M×3×352×640 input into the multi-task network model as an example, the target detection box, target category confidence and target image quality score output by the multi-task network model are M×66×4620, where M represents the number of images in a batch, 4620 represents the total number of all target detection boxes divided into large, medium and small scales for each training image, and 66 consists of the target detection box predicted by each candidate box (64) + target image quality score (1) + target category confidence (1).

[0088] The feature extraction module can capture features of training images at different scales, which helps the model better understand and process complex input data. The multi-scale fusion module can fuse feature maps of different scales to fully utilize feature information of different scales and improve the performance of the model. In addition, by performing target detection prediction on fused feature maps at different scales, the model can detect targets of different sizes, thereby accurately predicting the target detection box and improving the detection accuracy of the model.

[0089] An image containing only the target foreground is predicted by the detection regression branch, the category prediction branch predicts the category of the image target, and the quality assessment branch predicts the quality of the image, so that the multi-task network model can predict the quality of the image containing only the target foreground when the input image is an image containing foreground and background, effectively preventing the negative impact of background quality on the prediction of target foreground image quality, and realizing the target image quality assessment function without affecting the performance of the original target detection model and without significantly increasing the memory occupancy rate of the camera device 1, effectively solving the problem of being unable to independently add a target image quality assessment model due to limited resources on the camera end.

[0090] In some embodiments, the method for constructing and training a multi-task network model may further include constructing a data enhancement module, so that the number, diversity and quality of training images can be increased through the data enhancement module, thereby improving the performance and robustness of the model. Step S140 specifically includes the following steps:

[0091] Step b1: Input the training images in the batch images into the data augmentation module one by one to obtain data augmented images.

[0092] Step b2: Input the data augmented image into the multi-task network model to obtain the predicted feature map.

[0093] Among them, the data enhancement module uses a variety of data enhancement methods to perform data enhancement processing on the training images, such as color transformation method, scale transformation method, up and down flip transformation method, left and right flip transformation method, rotation transformation method and target copy and paste transformation method.

[0094] Specifically, the data enhancement module can set the same or different activation probabilities for each data enhancement method, that is, the data enhancement module randomly selects one or more of the color transformation method, scale transformation method, upside down transformation method, left-right flip transformation method, rotation transformation method and target copy and paste transformation method to perform data enhancement processing on the training image, thereby increasing the diversity and complexity of the training image set, enriching the data and helping the model to learn better, thereby improving the generalization ability and robustness of the model.

[0095] Step S150: The target detection boxes, target category confidences, target image quality scores of multiple candidate boxes and the target label boxes, category labels, and quality label scores of the training images in the batch images are input into the loss function calculation module to obtain the model loss of the multi-task network model.

[0096] Specifically, all training images in the batch images are input into the multi-task network model to obtain the target detection boxes, target category confidences and target image quality scores of multiple candidate boxes, as well as the target label boxes, category labels and quality label scores of all training images in the batch images are all input into the loss function calculation module.

[0097] In the loss function calculation module, based on Formula 1, the category loss L of the multi-task network model is calculated according to the target category confidence and category label. xls ; Based on formula 2, the border regression loss L of the multi-task network model is calculated according to the target detection box and the target label box box ; Based on formula 3, the category distribution loss L of the multi-task network model is calculated according to the target category confidence dfl Based on Formula 4, the image quality assessment loss L of the multi-task network model is calculated according to the target image quality score, target detection box, target label box and quality label score. iqa ; Based on Formula 5, according to the category loss L cls , bounding box regression loss L box , category distribution loss L dfl and image quality assessment loss L iqa Calculate the model loss L of the multi-task network model sum .

[0098] Step S160: Use the back propagation algorithm to calculate the gradient of the model loss to each parameter of the multi-task network model, and update the parameters of the multi-task network model according to the gradient.

[0099] Specifically, starting from the output layer of the multi-task network model, the chain rule is used to calculate the gradient of the model loss function for each parameter of the multi-task network model layer by layer, and then the optimization method (such as gradient descent) and the gradient are used to adjust the parameters of the multi-task network model. By repeatedly iterating this process, the model loss of the multi-task network model can be gradually reduced.

[0100] Step S170: Determine whether the multi-task network model has converged. If so, execute step S180; if not, return to execute step S130.

[0101] In an embodiment of the present application, when the model loss of the multi-task network model no longer decreases, or when the gradient of the model loss to each parameter of the multi-task network model is very small and the parameters of the model can no longer be updated well, the multi-task network model converges and the training of the model is stopped; otherwise, multiple training images are continuously randomly extracted from the training image set to form a batch image to continue training the model until all the training images in the training image set are traversed, that is, all the training images in the training image set have been extracted to form a batch image, then the training is stopped and the weights of the multi-task network model after the last parameter update are saved.

[0102] Step S180: Save the weights of the multi-task network model.

[0103] Save the model's weights so that you can reload and use the multi-task network model after training is complete.

[0104] In the embodiment of the present application, the training images in the batch images are input into the multi-task network model to perform target detection, target category prediction and image quality assessment, and target detection frames, target category confidences and target image quality scores of multiple candidate frames of the training images are obtained. The model loss is calculated by the target detection frames, target category confidences and target image quality scores of the multiple candidate frames and the target label frames, category labels and quality label scores of the training images, and the parameters of the multi-task network model are updated by the model loss, so that the trained multi-task network model performs target detection, target category prediction and image quality assessment on the image input to the model, and the target detection frames, target category confidences and quality scores of the image are obtained. The target image quality score enables the multi-task network model to predict the image quality of only the target foreground in the image when the input image is an image containing foreground and background, effectively preventing the negative impact of background quality on the prediction of target foreground image quality, and realizing the target image quality assessment function without affecting the performance of the original target detection model and without significantly increasing the memory occupancy of the camera end, effectively solving the problem that the target image quality assessment model cannot be added independently due to limited camera resources, thereby reducing the transmission cost of target image data, reducing bandwidth load and reducing the number of calls to the recognition model in the target detection mode on the camera end and target recognition mode on the cloud server.

[0105] Figure 5 The flowchart of the verification method of the multi-task network model provided by the embodiment of the present application is shown. The verification method of the multi-task network model can be performed by a local offline computer, server or other electronic device ( Figure 1 (not shown) is used to verify the multi-task network model trained by the above embodiment to determine whether the multi-task network model is trained well. Figure 2 The construction and training method of the multi-task network model shown in the embodiment is to use the multi-task network model obtained after each training round. Figure 5 The multi-task network model verification method shown in the embodiment verifies the multi-task network model, so, Figure 5 The steps shown in the embodiment are Figure 2 The step S180 of the embodiment is executed before execution. Figure 5 As shown, the verification method of the multi-task network model includes the following steps:

[0106] Step S210: Load the weights of the multi-task network model saved in the current training round.

[0107] Specifically, use Figure 2 In the process of training the multi-task network model in the method for constructing and training a multi-task network model shown in the embodiment, the weight of the multi-task network model saved in the current training round is the weight of the multi-task network model saved after the multi-task network model converges, or the weight of the multi-task network model after the last parameter update saved after traversing all training images in the training image set.

[0108] Step S220: input the verification image in the verification image set into the multi-task network model to obtain the target detection box, target category confidence, and target image quality score of the verification image.

[0109] The verification image set includes multiple verification images annotated with labels, and the labels include target label boxes, category labels, and quality label scores. The verification image set in this step is the verification image set constructed above.

[0110] Specifically, a verification image in the verification image set is input into the multi-task network model to obtain a predicted feature map of the verification image. The predicted feature map contains target detection boxes predicted by multiple candidate boxes, target category confidence, and target image quality scores.

[0111] The processing of the verification image by the multi-task network model in this step can refer to the aforementioned step S150, which will not be repeated here.

[0112] Step S230: Calculate the model indicators of the current training round of the multi-task network model according to the target detection box, target category confidence, target image quality score of the verification image and the target label box, category label, and quality label score of the training image.

[0113] After obtaining the predicted feature map of the verification image, non-maximum suppression processing is performed on the predicted feature map. Specifically, the optimal detection result can be screened out from the detection results predicted by multiple candidate boxes as the target detection result. The target detection result includes the target detection box, the target category confidence and the target image quality score. For example, the detection result predicted by the candidate box with the highest target category confidence is used as the target detection result.

[0114] Then, the target detection frame of the target detection result is decoded to obtain a four-dimensional target detection frame, that is, the target detection frame represented by the integral is converted back to a four-dimensional target detection frame. Specifically, the target detection frame represented by the integral of the target detection result (usually the encoded bounding box parameters) is decoded, and the above parameters can be converted back to a four-dimensional target detection frame (i.e., the center point coordinates x, y, and the width w and height h).

[0115] In this embodiment, the model index of the current training round can be a weighted sum of the target detection index and the quality assessment index. Among them, the target detection index includes precision, recall, mAP@50 and mAP@5095, which are calculated by the four-dimensional target detection box of the verification image, the target category confidence and the category label and target label box of the training image; the quality assessment index includes PLCC (Pearson Linear Correlation Coefficient), SRCC (Spearman Rank Correlation Coefficient) and Total (PLCC+SRCC), which are calculated by the target image quality score of the verification image and the quality label score of the training image.

[0116] Step S240: Determine whether the model index of the current training round is greater than the preset index. If so, execute step S250; if not, execute step S260.

[0117] Step S250: taking the weight of the multi-task network model of the current training round as the optimal network weight, and using the model index of the current training round to update the preset index.

[0118] Step S260: Determine whether the maximum number of training rounds has been reached. If so, end the process. If not, return to step S130.

[0119] When the model index of the current training round is greater than the preset index, the weight of the multi-task network model of the current training round is used as the optimal network weight, and the model index of the current training round is updated to the preset index, and Figure 2 After the multi-task network model is obtained through training in the next training round, the weights of the multi-task network saved in the next training round are loaded to verify the multi-task network model obtained through training in the next training round until the training round of the model reaches the maximum training round, so that the multi-task network model with the best model index in multiple training rounds can be used as the multi-task network model outputted in the end. When the model index of the current training round is less than or equal to the preset index, the optimal network weight is not updated, and Figure 2 After the multi-task network model is obtained by training in the next training round of the embodiment, the weights of the multi-task network saved in the next training round are loaded to verify the multi-task network model obtained by training in the next training round until the training round of the model reaches the maximum training round.

[0120] Figure 6 The flowchart of the testing method of the multi-task network model provided by the embodiment of the present application is shown. The method can be performed by a local offline computer, server or other electronic device ( Figure 1 The multi-task network model trained by the above embodiment is tested to determine whether the multi-task network model is well trained. Figure 6 The steps shown in the embodiment are Figure 2 After the step S180 of the embodiment is executed, or after Figure 5 The step S260 of the embodiment is executed before execution. Figure 6 As shown, the testing method of the multi-task network model includes the following steps:

[0121] Step S310: Load the saved weights of the multi-task network model.

[0122] The files loaded in this step can be Figure 2 The weights of the multi-task network model trained in the embodiment shown can also be Figure 5 The weights of the multi-task network model verified by the illustrated embodiment.

[0123] Step S320: Input the test image into the multi-task network model to obtain the target detection result of the test image.

[0124] In the embodiment of the present application, the test image can be a video image taken by any camera device for the test model, including but not limited to human videos, animal videos, car videos, etc.

[0125] Among them, the target detection results of the test image include four-dimensional target detection box, target category confidence and target image quality score.

[0126] Specifically, the test image is input into the multi-task network model to obtain a predicted feature map containing target detection boxes, target category confidences, and target image quality scores predicted by multiple candidate boxes. Non-maximum suppression is performed on the predicted feature map to screen out target detection results in multiple candidate boxes. The target detection results include target detection boxes, target category confidences, and target image quality scores. The target detection boxes of the target detection results are decoded to obtain a four-dimensional target detection box, and the target category corresponding to the highest target category confidence is taken as the target category of the four-dimensional target detection box.

[0127] When the target detection box contains only one category of targets, the target detection box corresponds to only one target category confidence. When the target detection box contains multiple categories of targets, such as animals, people, and cars, the target detection box corresponds to three target category confidences.

[0128] In this case, it is necessary to select the target category corresponding to the highest target category confidence from one or more target category confidences as the target category of the four-dimensional target detection frame. For example, assuming that the target category confidence 1 of a target detection frame is 80%, the target category confidence 2 is 90%, the target category corresponding to the target category confidence 1 is human, and the target category corresponding to the target category confidence 2 is animal, then the target category of the four-dimensional target detection frame is animal.

[0129] The processing of the test image by the multi-task network model in this step can refer to the aforementioned step S150, which will not be repeated here.

[0130] Step S330: Determine whether the target category confidence of the target detection result is greater than a preset confidence. If so, execute step S340; if not, return to execute step S320.

[0131] In this step, the maximum target category confidence and the preset confidence can be directly compared. When the maximum target category confidence is greater than the preset confidence (e.g., 0.45), it indicates that the multi-task network model believes that the prediction that the target in the target detection frame of the test image is a certain category is relatively reliable, and the four-dimensional target detection frame, target category, and target image quality score of the test image are output; when the maximum target category confidence is less than or equal to the preset confidence (e.g., 0.45), it indicates that the multi-task network model believes that the prediction that the target in the target detection frame of the test image is a certain category is unreliable, and no content of the test image is output, and the test image is re-extracted frame by frame from the video captured by the camera device to test the multi-task network model.

[0132] Step S340: Output the four-dimensional target detection box, the target category corresponding to the highest target category confidence, and the target image quality score.

[0133] Figure 7 A flow chart of a target detection and recognition method provided by an embodiment of the present application is shown, and the method can be used for intelligent video surveillance. In the present embodiment, the method is performed by the aforementioned camera device 1, wherein the camera device 1 is installed and operated with a trained multi-task network model and a target recognition model, and the camera device 1 directly extracts video images frame by frame from the captured video to perform target detection and target recognition to obtain target detection results (e.g., target images) and target recognition results (e.g., target names). In another embodiment, the method can also be performed by the camera device 1 and the cloud server 2, wherein the camera device 1 is installed and operated with a trained multi-task network model, and the cloud server 2 is installed and operated with a target recognition model that can recognize multiple target types. The camera device 1 extracts video images frame by frame from the captured video and performs target detection through a trained multi-task network model to obtain a target image, and then sends the target image to the cloud server 2 through the network 3, and the cloud server 2 calls the target recognition model to perform target recognition on the target image to obtain a target recognition result (e.g., target name). The multi-task network model used in the embodiment of the present application is obtained by training the multi-task network model construction and training method for target detection and recognition in the aforementioned embodiment, and is verified and tested using the verification method and test method of the multi-task network model in the aforementioned embodiment. Figure 2 , Figure 5 and Figure 6 The same or similar steps as those in the embodiment shown can be referred to the above description, and the specific implementation process and beneficial effects thereof will not be described in detail in this embodiment. Figure 7 As shown, the target detection and recognition method includes the following steps:

[0134] Step S410: extracting video images frame by frame from the video captured by the camera device.

[0135] In this embodiment, the video may be a video captured by the camera device 1 , including but not limited to a video of a person, a video of an animal, a video of a car, and the like.

[0136] Optionally, the video image may include one, two or more targets. For example, the targets included in the video image may include: animal A, animal A and animal B, person A, person A and person B, animal A and person A, person A and car A, animal A, person A and car A, etc.

[0137] Step S420: Input the video images one by one into the multi-task network model to obtain a predicted feature map.

[0138] Among them, the multi-task network model includes a feature extraction module, a multi-scale feature fusion module and a detection head module. The detection head module includes multiple scale branches. Each scale branch includes a detection regression branch, a category prediction branch and a quality assessment branch. The last convolution layer of the quality assessment branch is connected in parallel with the last convolution layer of the detection regression branch, and the quality assessment branch and the detection regression branch share the remaining convolution layers.

[0139] Among them, the predicted feature map contains detection results of multiple candidate boxes, each candidate box corresponds to a detection result, and each detection result includes a target detection box, target category confidence and target image quality score. The target detection box is output by the detection regression branch, the target category confidence is output by the category prediction branch, and the target image quality score is output by the quality assessment branch.

[0140] Step S420 specifically includes:

[0141] Step c1: Input the video images one by one into the feature extraction module, extract features from the video images through the feature extraction module, and obtain feature maps of the video images at different scales.

[0142] Step c2: Input the feature maps at different scales into the multi-scale feature fusion module, and perform feature fusion on the feature maps at different scales through the multi-scale feature fusion module to obtain fused feature maps of the video image at different scales.

[0143] Step c2: Input the fused feature maps at different scales into the detection head module, perform target detection prediction on the fused feature maps through the detection regression branch to obtain target detection frames of multiple candidate frames, perform target category prediction on the fused feature maps through the category prediction branch to obtain target category confidences of multiple candidate frames, and perform quality assessment prediction on the fused feature maps through the quality assessment branch to obtain target image quality scores of multiple candidate frames.

[0144] Taking the multi-task network model trained using animal images and person images as an example, when the video image includes an animal A, the predicted feature map includes multiple target detection boxes predicted by multiple candidate boxes with animal A as the target, multiple target category confidences of animal A as the target, and multiple target image quality scores of the foreground image of animal A; when the video image includes an animal A and an animal B, the predicted feature map includes multiple target detection boxes predicted by multiple candidate boxes with animal A and animal B as the targets, multiple target category confidences 1 for animal A and multiple target category confidences for animal B as the target, and multiple target image quality scores of the foreground images of animal A and animal B.

[0145] Step S430: post-process the predicted feature map to obtain a target detection result, where the target detection result includes a four-dimensional target detection box, a target category confidence, and a target image quality score.

[0146] Step S430 specifically includes:

[0147] Step d1: Perform non-maximum suppression on the predicted feature map to filter out target detection results from multiple candidate boxes.

[0148] Step d2: Decode the target detection frame of the target detection result to obtain a four-dimensional target detection frame.

[0149] In this step, the detection result with the highest confidence level of the target category can be selected from multiple candidate boxes as the target detection result.

[0150] When the video image includes only one target, such as animal A, the target detection result obtained by screening in step S430 includes: a target detection frame with animal A as the target, the target category confidence of animal A, and the target image quality score of the foreground image of animal A; when the video image includes two targets, such as animal A and animal B, the target detection result obtained by screening in step S430 includes: a target detection frame with animal A and animal B as the targets, the target category confidence 1 of animal A and the target category confidence 2 of animal B, and the target image quality scores of the foreground images of animal A and animal B.

[0151] Specifically, after decoding the target detection frame represented by the integral in the target detection result, a four-dimensional target detection frame is obtained.

[0152] Step S440: Determine whether the target category confidence of the target detection result is greater than a preset confidence. If so, execute step S450; if not, return to execute step S410.

[0153] In this embodiment, when the target category confidence of the target detection result is greater than a preset confidence (for example, 0.45), it indicates that the multi-task network model believes that the prediction that the target in the target detection box of the video image is a certain category is relatively reliable, and then the four-dimensional target detection box and the target image quality score are displayed; when the target category confidence of the target detection result is less than or equal to the preset confidence threshold (for example, 0.45), it indicates that the multi-task network model believes that the prediction that the target in the target detection box of the video image is a certain category is unreliable, and then the four-dimensional target detection box and the target image quality score are not displayed, and the video image continues to be acquired for target detection and target image quality assessment.

[0154] Step S450: Determine whether the target image quality score of the target detection result is greater than a preset score. If so, execute step S460. If not, return to execute step S410. Assuming that the target image quality score is measured in percentage, the preset score can be set to any score value between 80 and 100, such as 80 or 90, which can be set according to the image quality satisfaction required by the user.

[0155] When the target image quality score is greater than the preset score, it indicates that the target image quality in the four-dimensional target detection frame meets the requirements; when the target image quality score is less than or equal to the preset evaluation threshold, it indicates that the target image quality in the four-dimensional target detection frame does not meet the requirements.

[0156] Step S460: cropping the target image from the video image according to the four-dimensional target detection frame.

[0157] Specifically, when the quality of the target image within the four-dimensional target detection frame meets the requirements, the video image is cropped according to the four-dimensional target detection frame to obtain a target image containing only the target foreground.

[0158] Step S470: Input the target image into the target recognition model to recognize the target name of the target image.

[0159] In an embodiment of the present application, the target image and target name may be output to the terminal device 4 simultaneously, or directly displayed on the display screen of the terminal device 4.

[0160] In the embodiment of the present application, a pre-trained target recognition model can be used to recognize the target image, or a target recognition model trained according to specific needs can be used. The target recognition model can run in the camera device 1 or the cloud server 2.

[0161] For example, when the target image contains a target of the category of animal A, the target image is input into the target recognition model for target recognition to obtain the target name: animal A. When the target image contains targets of multiple categories, the target name of the target image recognized by the target recognition model is the target name corresponding to the highest target category confidence in the target detection result. For example, when the target image includes targets of the three categories of animal A, person A, and car A, and the target name corresponding to the highest target category confidence in the target detection result is animal A, the target image is input into the target recognition model for target recognition to obtain the target name: animal A.

[0162] In some embodiments, the target category corresponding to the highest target category confidence may be taken in step S430 as the target category of the four-dimensional target detection box.

[0163] When the target detection frame in the target detection result contains only one category of targets, the target detection frame corresponds to only one target category confidence, and the target category corresponding to the target category confidence is used as the target category of the four-dimensional target detection frame.

[0164] When the target detection frame in the target detection result contains multiple categories of targets, such as animals, people, and cars, the target detection frame corresponds to three target category confidences, and the target category corresponding to the highest target category confidence among the three target category confidences is used as the target category of the four-dimensional target detection frame. For example, when the target category confidence of the target detection frame for people is 80%, the target category confidence of animals is 95%, and the target category confidence of cars is 90%, then the target category of the four-dimensional target detection frame is animals.

[0165] Therefore, when it is determined in step S440 that the target category confidence of the target detection result is greater than the preset confidence, the target category, the four-dimensional target detection frame, and the target image quality score may be displayed simultaneously.

[0166] In this case, this step S470 can input the cropped target image into the target recognition model corresponding to the target category for target recognition. Specifically, assuming that the target image contains targets of three categories: animal A, person A, and car A, when the displayed target category is animal, the target image is input into the animal recognition model for target recognition, and the target recognition result output by the animal recognition model is obtained: animal A; when the displayed target category is person, the target image is input into the person recognition model for target recognition, and the target recognition result output by the person recognition model is obtained: person A; when the target category displayed in the step is car, the target image is input into the car recognition model for target recognition, and the target recognition result output by the car recognition model is obtained: car A.

[0167] The specific implementation process, principles and references of the above steps Figure 2 , Figure 5 and Figure 6 The embodiments shown will not be described in detail here.

[0168] In the embodiment of the present application, the video images extracted frame by frame are input into a multi-task network model for target detection, target category prediction and image quality assessment, so as to obtain a predicted feature map including a target detection frame of multiple candidate frames, a target category confidence and a target image quality score; the target detection result is obtained by post-processing the predicted feature map, and when the target category confidence of the target detection result is greater than a preset confidence and the target image quality score of the target detection result is greater than a preset score, a target image containing only the target foreground obtained by cropping the video image according to the four-dimensional target detection frame of the target detection result is input into a target recognition model for target recognition to obtain a target name; by predicting an image containing only the target foreground and predicting the quality of the image through a multi-task network model, the quality of the target image input into the target recognition model can be controlled, which not only effectively reduces the target misrecognition rate, but also reduces the number of calls to the target recognition model and reduces the operating load of the camera device. In addition, in the mode of target detection at the camera end and target recognition at the cloud server, the transmission cost of the target image data can be reduced, and useless information storage can be avoided, thereby reducing bandwidth load and memory occupancy.

[0169] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present invention is shown. The electronic device may be the aforementioned camera device 1, cloud server 2, terminal device 4 and offline computer device. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.

[0170] like Figure 8 As shown, the electronic device 600 may include: a processor (processor) 602 and a memory (memory) 604.

[0171] The memory 604 is used to store a computer program 606. The memory 604 may include a high-speed RAM memory, or may also include a non-volatile memory, such as at least one disk memory. The computer program 606 may include computer executable instructions.

[0172] The processor 602 is used to execute the computer program 606 to implement the steps in the above target detection and recognition method embodiment.

[0173] The processor 602 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0174] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by one or more processors, it implements the above-mentioned target detection and recognition method embodiment, or implements the above-mentioned multi-task network model construction and training method embodiment.

[0175] An embodiment of the present application provides a computer program, which can be executed by one or more processors to implement the above-mentioned target detection and recognition method embodiment, or to implement the above-mentioned multi-task network model construction and training method embodiment.

[0176] An embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by one or more processors, it implements the above-mentioned target detection and recognition method embodiment, or implements the above-mentioned multi-task network model construction and training method embodiment.

[0177] In several embodiments provided in the present application, if any function is implemented in the form of a software function module / unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, part or all of the technical solution of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, server or other electronic device) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (RandomAccess Memory, RAM), disk or optical disk and other media that can store computer program code.

[0178] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for target detection and recognition, It is characterized in that The method comprises: Extracting video images frame by frame from the video captured by the camera device; Input the video images one by one into a multi-task network model to obtain a predicted feature map, wherein the multi-task network model includes a feature extraction module, a multi-scale feature fusion module and a detection head module, the detection head module includes multiple scale branches, each scale branch includes a detection regression branch, a category prediction branch and a quality assessment branch, the last convolution layer of the quality assessment branch is connected in parallel with the last convolution layer of the detection regression branch, the quality assessment branch and the detection regression branch share the remaining convolution layers, the predicted feature map includes a target detection box of multiple candidate boxes, a target category confidence and a target image quality score, the target detection box is output by the detection regression branch, the target category confidence is output by the category prediction branch, and the target image quality score is output by the quality assessment branch; Post-processing the predicted feature map to obtain a target detection result, wherein the target detection result includes a four-dimensional target detection box, a target category confidence, and a target image quality score; Determining whether the target category confidence of the target detection result is greater than a preset confidence; If the target category confidence of the target detection result is greater than the preset confidence, determining whether the target image quality score of the target detection result is greater than a preset score; If the target image quality score of the target detection result is greater than the preset score, cropping the target image from the video image according to the four-dimensional target detection frame; The target image is input into a target recognition model to recognize the target name of the target image.

2. The target detection and recognition method according to claim 1, It is characterized in that The post-processing of the predicted feature map to obtain the target detection result comprises: Performing non-maximum suppression processing on the predicted feature map to filter out the target detection result from the plurality of candidate frames; The target detection frame of the target detection result is decoded to obtain a four-dimensional target detection frame.

3. The target detection and recognition method according to claim 1, It is characterized in that The step of inputting the video images one by one into the multi-task network model to obtain a predicted feature map includes: Input the video images one by one into a feature extraction module, and extract features of the video images through the feature extraction module to obtain feature maps of the video images at different scales; Inputting the feature maps at different scales into the multi-scale feature fusion module, and performing feature fusion on the feature maps at different scales through the multi-scale feature fusion module to obtain fused feature maps of the video image at different scales; Inputting the fused feature maps at different scales into the detection head module; Performing target detection prediction on the fused feature map through the detection regression branch to obtain target detection frames of multiple candidate frames; Performing target category prediction on the fused feature map through the category prediction branch to obtain target category confidences of multiple candidate boxes; The quality assessment branch performs quality assessment prediction on the fused feature map to obtain target image quality scores of multiple candidate frames.

4. A method for constructing and training a multi-task network model for target detection and recognition. It is characterized in that The construction and training method of the multi-task network model includes: Constructing the multi-task network model, the multi-task network model includes a feature extraction module, a multi-scale feature fusion module and a detection head module, the detection head module includes multiple scale branches, each scale branch includes a detection regression branch, a category prediction branch and a quality assessment branch, the last convolution layer of the quality assessment branch is connected in parallel with the last convolution layer of the detection regression branch, and the quality assessment branch and the detection regression branch share the remaining convolution layers; Construct a loss function calculation module; Randomly extracting multiple training images from a training image set to form a batch of images, wherein the training image set includes multiple training images annotated with labels, and the labels include a target label box, a category label, and a quality label score; Inputting the training images in the batch of images one by one into the multi-task network model to obtain a predicted feature map, wherein the predicted feature map contains target detection boxes, target category confidences and target image quality scores of multiple candidate boxes, the detection regression branch outputs the target detection box, the category prediction branch outputs the target category confidence, and the quality assessment branch outputs the target image quality score; Inputting the target detection frames, target category confidences, target image quality scores of the multiple candidate frames and the target label frames, category labels, and quality label scores of the training images in the batch of images into the loss function calculation module to obtain the model loss of the multi-task network model; Using a back propagation algorithm to calculate the gradient of the model loss to each parameter of the multi-task network model, and updating the parameters of the multi-task network model according to the gradient; Determining whether the multi-task network model converges; If the multi-task network model converges, saving the weights of the multi-task network model; If the multi-task network model does not converge, the step of randomly extracting multiple training images from the training image set to form a batch image is performed.

5. The method for constructing and training a multi-task network model according to claim 4, It is characterized in that The total number of images in the batch of images is N, where N≥1; The model loss L of the multi-task network model sum for: L sum =λ cls L cls +λ box L box +λ dfl L afl +λ iqa L iqa , Among them, L cls represents the category loss of the multi-task network model, L box represents the bounding box regression loss of the multi-task network model, L dfl represents the category distribution loss of the multi-task network model, L iqa represents the image quality assessment loss of the multi-task network model, λ cls , box , dfl and λ iqa Respectively represent L cls , L box , L dfl and L iqa The weight of The image quality assessment loss L of the multi-task network model iqa for: Among them, IQA gt Represents the quality label score of the training image, IQA pred represents the target image quality score of the training image, IoU represents the ratio of the intersection area to the union area of ​​the target label box and the target detection box of the training image, flag represents the flag bit of whether the training image has the quality label score, if the training image has the quality label score, flag is 1, if the training image does not have the quality label score, flag is 0.

6. The method for constructing and training a multi-task network model according to claim 4, It is characterized in that The method further includes: constructing a data enhancement module, wherein the data enhancement module uses at least one of a plurality of data enhancement methods to perform data enhancement on the image, wherein the plurality of data enhancement methods include a color transformation method, a scale transformation method, an up-down flip transformation method, a left-right flip transformation method, a rotation transformation method, and a target copy-paste transformation method; The step of inputting the training images in the batch of images one by one into the multi-task network model to obtain a prediction feature map comprises: Inputting the training images in the batch of images into the data augmentation module one by one to obtain data augmented images; The data augmented image is input into the multi-task network model to obtain a predicted feature map.

7. The method for constructing and training a multi-task network model according to claim 4, It is characterized in that The method further includes: verifying the multi-task network model, and the verification method of the multi-task network model includes the following steps: Load the weights of the multi-task network model saved in the current training round; Inputting a verification image in a verification image set into the multi-task network model to obtain a target detection frame, a target category confidence, and a target image quality score of the verification image, wherein the verification image set includes a plurality of verification images annotated with labels, and the labels include a target label frame, a category label, and a quality label score; Calculate the model index of the current training round of the multi-task network model according to the target detection box, target category confidence, target image quality score of the verification image and the target label box, category label, and quality label score of the training image; Determine whether the model index of the current training round is greater than a preset index; If the model index of the current training round is greater than the preset index, the weight of the multi-task network model of the current training round is used as the optimal network weight, and the preset index is updated using the model index of the current training round, and the step of randomly extracting multiple training images from the training image set to form a batch image is performed until the maximum training round is reached; If the model index of the current training round is less than or equal to the preset index, the step of randomly extracting multiple training images from the training image set to form a batch image is performed until the maximum training round is reached.

8. The method for constructing and training a multi-task network model according to claim 4, It is characterized in that The method further includes: testing the multi-task network model, and the testing method of the multi-task network model includes the following steps: Loading the saved weights of the multi-task network model; Inputting a test image into the multi-task network model to obtain a target detection result of the test image, wherein the target detection result includes a four-dimensional target detection box, a target category confidence, and a target image quality score; Determining whether the target category confidence of the target detection result is greater than a preset confidence; If the target category confidence of the target detection result is greater than the preset confidence, outputting the four-dimensional target detection frame, the target category corresponding to the highest target category confidence and the target image quality score; If the target category confidence of the target detection result is less than or equal to the preset confidence, the step of inputting the test image into the multi-task network model to obtain the target detection result of the test image is executed.

9. The method for constructing and training a multi-task network model according to claim 4, It is characterized in that The method further comprises: generating an image quality label interface and displaying it on a display screen of an electronic device; Displaying the training image and the target rectangular frame on the image quality label interface; When the target rectangular frame is selected, mask processing is performed on all backgrounds outside the selected target foreground of the training image, and the image within the target rectangular frame is the target image; Performing a quality score on the target image to obtain the quality label score.

10. An electronic device comprising a memory, a processor and a computer program stored in the memory, It is characterized in that The processor executes the computer program to implement the target detection and recognition method described in any one of claims 1 to 3, or to implement the multi-task network model construction and training method described in any one of claims 4 to 9.

11. A computer-readable storage medium storing a computer program, It is characterized in that When the computer program is executed by a processor, it implements the target detection and recognition method described in any one of claims 1 to 3, or implements the multi-task network model construction and training method described in any one of claims 4 to 9.

Citation Information

Cited By

  • Detection method and system for warehouse-in and warehouse-out of non-inductive warehouse goods

    CN119942082A