Methods and apparatus, including computer program products, for detecting objects in images
By determining predicted features based on object features and feature map correlation in image processing, and optimizing feature extraction using convolutional neural networks and self-attention mechanisms, the problem of low detection accuracy in image processing is solved, achieving efficient and accurate object detection results.
Patent Information
- Application Number
- CN202311168058.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-11
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-09-11
AI Technical Summary
Existing technologies for object detection in image processing suffer from low detection accuracy and high computational costs, especially in complex scenarios such as human behavior analysis in security monitoring, where accurate identification is difficult.
After extracting the feature map of the input image, the predicted features of each object to be detected associated with the input image are determined based on the object features and the correlation between the feature maps of multiple objects to be detected. The predicted features are used for weighted calculation to improve the detection accuracy. Convolutional neural networks and self-attention mechanisms are used to optimize feature extraction.
It enables efficient and accurate detection of objects in images in complex scenarios, improves the accuracy of human behavior analysis, and meets the needs of practical applications.
Smart Images

Figure CN117197483B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, specifically computer vision, image processing, deep learning, and other technical fields, and can be applied to scenarios such as smart cities. Specifically, it relates to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for detecting objects in an image. Background Technology
[0002] Artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies mainly include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.
[0003] With the development of artificial intelligence technology, deep learning-based visual models are widely used in the field of image recognition to improve the intelligence and efficiency of image processing.
[0004] The methods described in this section are not necessarily methods that had been previously conceived or adopted. Unless otherwise specified, no method described in this section should be assumed to be prior art simply because it is included in this section. Similarly, unless otherwise specified, the issues mentioned in this section should not be considered to be accepted in any prior art. Summary of the Invention
[0005] This disclosure provides a method, apparatus, electronic device, computer-readable storage medium, and computer program product for detecting objects in an image.
[0006] According to one aspect of this disclosure, a method for detecting objects in an image is provided, comprising:
[0007] According to another aspect of this disclosure, an apparatus for detecting objects in an image is provided, comprising:
[0008] According to another aspect of this disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method described above for detecting objects in an image.
[0009] According to another aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are used to cause the computer to perform the above-described method for detecting objects in an image.
[0010] According to another aspect of this disclosure, a computer program product is provided, including a computer program, wherein the computer program, when executed by a processor, is capable of implementing the above-described method for detecting objects in an image.
[0011] According to one or more embodiments of this disclosure, the accuracy of detecting objects in an image can be improved.
[0012] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0013] The accompanying drawings exemplify embodiments and form part of the specification, serving together with the textual description to explain exemplary implementations of the embodiments. The illustrated embodiments are for illustrative purposes only and do not limit the scope of the claims. Throughout the drawings, the same reference numerals refer to similar but not necessarily identical elements.
[0014] Figure 1 A schematic diagram of an exemplary system in which various methods described herein may be implemented, according to exemplary embodiments of the present disclosure;
[0015] Figure 2 A flowchart is shown of a method for detecting objects in an image according to an exemplary embodiment of the present disclosure;
[0016] Figure 3 A schematic diagram of the structure of a model for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown;
[0017] Figure 4 A flowchart is shown of a method for training a model for detecting objects in an image according to an exemplary embodiment of the present disclosure;
[0018] Figure 5 A structural block diagram of an apparatus for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown;
[0019] Figure 6 A structural block diagram of a training apparatus for a model for detecting objects in an image, according to an exemplary embodiment of the present disclosure, is shown.
[0020] Figure 7 A structural block diagram of an exemplary electronic device that can be used to implement embodiments of the present disclosure is shown. Detailed Implementation
[0021] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0022] In this disclosure, unless otherwise stated, the use of terms such as "first," "second," etc., to describe various elements is not intended to limit the positional, temporal, or importance relationships of these elements; such terms are merely used to distinguish one element from another. In some examples, the first element and the second element may refer to the same instance of that element, while in other cases, based on the context, they may refer to different instances.
[0023] The terminology used in the description of the various examples described in this disclosure is for the purpose of describing particular examples only and is not intended to be limiting. Unless the context explicitly indicates otherwise, an element may be one or more unless the number of elements is specifically limited. Furthermore, the term "and / or" as used in this disclosure covers any one of the listed items and all possible combinations thereof.
[0024] In related technologies, end-to-end visual models are typically trained based on the task requirements of image processing. For example, when it is necessary to detect a specific object in an image, the model is trained using an image containing the object to be detected, resulting in a model for detecting objects in the image. In this case, to improve detection accuracy, it is necessary to increase the complexity of the model or expand the training dataset, which requires a higher computational cost.
[0025] Based on this, the present disclosure provides a method for detecting objects in an image. After extracting the feature map of the input image, based on the correlation between the object features corresponding to multiple objects to be detected and the feature maps, the corresponding predicted features of each object to be detected associated with the input image are determined. Based on the predicted features, the corresponding detection result of each object to be detected is determined, thereby obtaining the detection results for multiple objects to be detected more accurately and efficiently, and effectively enhancing the detection performance.
[0026] The embodiments of this disclosure will now be described in detail with reference to the accompanying drawings.
[0027] Figure 1 A schematic diagram of an exemplary system 100 in which the various methods and apparatus described herein can be implemented according to embodiments of this disclosure is shown. Reference Figure 1The system 100 includes one or more client devices 101, 102, 103, 104, 105 and 106, a server 120, and one or more communication networks 110 coupling the one or more client devices to the server 120. The client devices 101, 102, 103, 104, 105 and 106 can be configured to execute one or more applications.
[0028] In embodiments of this disclosure, server 120 may run one or more services or software applications that enable the execution of methods for detecting objects in an image.
[0029] In some embodiments, server 120 may also provide other services or software applications, which may include non-virtual and virtual environments. In some embodiments, these services may be provided as web-based services or cloud services, such as to users of client devices 101, 102, 103, 104, 105, and / or 106 under a Software as a Service (SaaS) model.
[0030] exist Figure 1 In the configuration shown, server 120 may include one or more components that implement the functions performed by server 120. These components may include software components, hardware components, or combinations thereof that can be executed by one or more processors. Users operating client devices 101, 102, 103, 104, 105, and / or 106 can sequentially interact with server 120 using one or more client applications to utilize the services provided by these components. It should be understood that various different system configurations are possible and may differ from system 100. Therefore, Figure 1 This is an example of a system used to implement the various methods described herein, and is not intended to be limiting.
[0031] Users can use client devices 101, 102, 103, 104, 105, and / or 106 to send input images. The client devices can provide an interface that allows users to interact with the client devices. The client devices can also output information to the user through this interface. Although... Figure 1 Only six client devices are described, but those skilled in the art will understand that this disclosure can support any number of client devices.
[0032] Client devices 101, 102, 103, 104, 105, and / or 106 may include various categories of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptops), workstation computers, wearable devices, smart screen devices, self-service terminal devices, service robots, gaming systems, thin clients, various messaging devices, sensors, or other sensing devices. These computer devices can run various categories and versions of software applications and operating systems, such as Microsoft Windows, Apple iOS, UNIX-like operating systems, Linux or Linux-like operating systems (such as Google Chrome OS); or include various mobile operating systems, such as Microsoft Windows Mobile OS, iOS, Windows Phone, and Android. Portable handheld devices may include cellular phones, smartphones, tablets, personal digital assistants (PDAs), etc. Wearable devices may include head-mounted displays (such as smart glasses) and other devices. Gaming systems may include various handheld gaming devices, internet-enabled gaming devices, etc. Client devices can run a variety of different applications, such as various Internet-related applications, communication applications (e.g., email applications), short message service (SMS) applications, and can use various communication protocols.
[0033] Network 110 can be any type of network well known to those skilled in the art, and can use any of a variety of available protocols (including but not limited to TCP / IP, SNA, IPX, etc.) to support data communication. By way of example only, one or more networks 110 can be a local area network (LAN), an Ethernet-based network, a token ring network, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a blockchain network, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.
[0034] Server 120 may include one or more general-purpose computers, special-purpose server computers (e.g., PC (personal computer) servers, UNIX servers, mid-range servers), blade servers, mainframe computers, server clusters, or any other suitable arrangement and / or combination. Server 120 may include one or more virtual machines running a virtual operating system, or other computing architectures involving virtualization (e.g., one or more flexible pools of logical storage devices that can be virtualized to maintain virtual storage devices for servers). In various embodiments, server 120 may run one or more services or software applications that provide the functionality described below.
[0035] The computing unit in server 120 can run one or more operating systems, including any of the aforementioned operating systems and any commercially available server operating system. Server 120 can also run any of a variety of additional server applications and / or middleware applications, including HTTP servers, FTP servers, CGI servers, JAVA servers, database servers, etc.
[0036] In some implementations, server 120 may include one or more applications to analyze and merge data feeds and / or event updates received from users of client devices 101, 102, 103, 104, 105, and 106. Server 120 may also include one or more applications to display data feeds and / or real-time events via one or more display devices of client devices 101, 102, 103, 104, 105, and 106.
[0037] In some implementations, server 120 can be a server for a distributed system or a server integrated with blockchain. Server 120 can also be a cloud server, or an intelligent cloud computing server or intelligent cloud host with artificial intelligence technology. A cloud server is a host product in the cloud computing service system, designed to address the shortcomings of traditional physical hosts and Virtual Private Server (VPS) services, such as high management difficulty and weak business scalability.
[0038] System 100 may also include one or more databases 130. In some embodiments, these databases may be used to store data and other information. For example, one or more of the databases 130 may be used to store information such as audio files and video files. Databases 130 may reside in various locations. For example, a database used by server 120 may be local to server 120, or it may be located away from server 120 and may communicate with server 120 via a network-based or dedicated connection. Databases 130 may be of different categories. In some embodiments, the database used by server 120 may be, for example, a relational database. One or more of these databases may store, update, and retrieve data from and from the databases in response to commands.
[0039] In some embodiments, one or more of the databases 130 may also be used by an application to store application data. The databases used by the application may be different categories of databases, such as key-value stores, object stores, or regular stores supported by a file system.
[0040] Figure 1The system 100 can be configured and operated in various ways to enable the application of the various methods and apparatus described in this disclosure.
[0041] Figure 2 A flowchart of a method 200 for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown. Figure 2 As shown, method 200 includes:
[0042] Step S201: Extract features from the input image to obtain the feature map of the input image;
[0043] Step S202: Obtain multiple object features corresponding to multiple objects to be detected;
[0044] Step S203: For each of the plurality of objects to be detected, based on the object features corresponding to the object to be detected and the feature map, determine the relevance weight corresponding to each pixel in the feature map, wherein the relevance weight corresponding to each pixel indicates the probability that the pixel corresponds to the object to be detected;
[0045] Step S204: Perform a weighted calculation on each pixel in the feature map based on the relevance weights, and determine the predicted features corresponding to the object to be detected based on the weighted feature map; and
[0046] Step S205: Based on the predicted features, determine the detection result for the object to be detected.
[0047] By utilizing the above detection method, after extracting the feature map of the input image, based on the correlation between the object features corresponding to each of the multiple objects to be detected and the feature maps, the corresponding predicted features of each object to be detected associated with the input image can be determined. The predicted features are used to efficiently and accurately indicate the features of the input image that are closely related to each object to be detected, and then the corresponding detection result of each object to be detected is determined based on the predicted features, so as to obtain the detection results for multiple objects to be detected, which can improve the accuracy and efficiency of detection.
[0048] In some examples, the object to be detected can be a predefined target object. In other examples, the object to be detected can also be a specific image feature, such as color features, pattern features, or the category features of the objects contained in the image. Understandably, multiple objects to be detected can be pre-configured manually according to needs, as long as different objects to be detected can correspond to different detectable image features. This disclosure does not limit the specific type of the object to be detected.
[0049] In some examples, the detection result can be a binary classification result indicating the presence or absence of the object to be detected. In this case, each object to be detected can correspond to an image category label. When a result indicating the presence or absence of each object to be detected is output, it is equivalent to obtaining one or more image category labels corresponding to the input image, thus achieving a multi-label classification task for the input image. In some examples, when the object to be detected is a predefined target object, the detection result can further include the location information of the object to be detected, thus achieving a target detection task for the input image.
[0050] In practical applications, image recognition technology is widely used in fields such as security monitoring. It determines whether a person in a specific scenario is exhibiting abnormal behavior by detecting and recognizing images containing human bodies. Generally speaking, human movements are highly complex, making it difficult to obtain accurate human behavior analysis results by simply recognizing image features. Furthermore, in the aforementioned scenarios, it is necessary to combine other features in the scene (such as objects interacting with the person) to determine human behavior, further increasing the complexity of human image recognition.
[0051] According to some embodiments, the input image includes a human body, and the object to be detected includes a human action category to be detected. By configuring the human action category to be detected as the object to be detected according to the actual scenario requirements, method 200 can accurately and efficiently extract predictive features closely related to the target human action category, thereby identifying human behavior in the input image, improving the accuracy of human behavior analysis, and fully meeting the needs of practical application scenarios.
[0052] In some examples, feature extraction of the input image in step S201 can be achieved using a feature extraction network, i.e., by inputting the input image into the feature extraction network to obtain a feature map. For example, an optimized feature extraction network can be obtained by training an image processing model that includes the feature extraction network. The training method can be, for example, supervised training based on labeled samples.
[0053] According to some embodiments, the object features corresponding to the object to be detected are obtained using an image processing model that includes a feature extraction network, and the image processing model is trained using sample images including the object to be detected. Thus, an optimized feature extraction network can be obtained by training the overall image processing model, thereby obtaining the corresponding object features of the object to be detected based on a standard image of the object. The feature extraction network can be, for example, a convolutional neural network, a residual network, etc.
[0054] Understandably, feature extraction for images is an upstream task in image processing. Therefore, various types of downstream image feature-based processing networks can be added on top of image feature extraction to obtain various types of image processing models, such as image classification models and object detection models.
[0055] In one example, an image classification model could be built based on a feature extraction network and a classification network, allowing it to be trained using sample images labeled with the true categories. In another example, an object detection model could be built based on a feature extraction network and a classification-regression network, allowing it to be trained using sample images labeled with the category and location information of the true object detection boxes.
[0056] In some examples, multiple object features corresponding to multiple objects to be detected can be stored in a database, thereby enabling the object features to be obtained directly in each image detection process.
[0057] In some embodiments, when using a feature extraction network to obtain the object features of the object to be detected, step S201 involves extracting features from the input image to obtain a feature map of the input image, which includes inputting the input image into the feature extraction network described above to obtain the feature map of the input image. By using the same feature extraction network to obtain standard object features and input image features, training steps can be saved and detection accuracy can be improved.
[0058] According to some embodiments, the image processing model further includes a classification network. The classification result output by the classification network is used to indicate whether the image input to the image processing model includes the object to be detected. Determining the detection result for the object to be detected based on the predicted features includes inputting the predicted features into the classification network to obtain a detection result indicating whether the input image includes the object to be detected. Therefore, a relatively simple classification task can be performed based on the predicted features, thereby achieving accurate and efficient detection of objects in an image.
[0059] According to some embodiments, the classification network includes multiple binary classifiers corresponding to the plurality of objects to be detected, and the step of inputting the predicted features into the classification network to obtain a detection result indicating whether the input image includes the object to be detected includes: inputting the predicted features into the binary classifier corresponding to the object to be detected to obtain a detection result indicating whether the input image includes the object to be detected. Thus, binary classifiers with simple structures and low training difficulty can be used to classify the predicted features corresponding to each object to be detected, and multi-classification can be achieved by combining multiple binary classifiers, saving resources while improving detection accuracy.
[0060] In some examples, the determination of the relevance weight corresponding to each pixel in the feature map in step S203, based on the object features corresponding to the object to be detected and the feature map, can be implemented based on a mutual attention mechanism. Understandably, the attention information in the mutual attention mechanism is used to characterize the relevance between the query term and the key term. In this example, the object features of the object to be detected can be used as the query term of the mutual attention mechanism, and the features of the input image can be used as the key term. The resulting attention information is the relevance weight.
[0061] As described in step S203, the correlation weight is used to indicate the probability that each pixel corresponds to the object to be detected. In some examples, when the object to be detected is a preset target object, the correlation weight of each pixel may be used to indicate the probability that the input image contains the target object and that the pixel or pixels within a preset range around the pixel belong to the target object. In some examples, when the object to be detected is a specific target image feature, the correlation weight may be used to indicate the probability that the pixel or pixels within a preset range around the pixel can indicate the target image feature.
[0062] In some examples, the result obtained by performing step S203 may be a weighted heatmap corresponding to the feature map, where the heat value of each pixel in the weighted heatmap indicates the relevance weight of the pixel at the corresponding position in the feature map.
[0063] In some examples, step S204, which involves weighting each pixel in the feature map based on the relevance weights to determine the predicted features corresponding to the object to be detected based on the weighted feature map, may include performing a linear mapping transformation on the obtained weighted feature map to obtain the predicted features in vector form. In this case, the object features corresponding to the object to be detected can also be determined based on a similar linear mapping transformation, so that the object feature vector and the image features of the object to be detected can be in the same high-dimensional feature space.
[0064] According to some embodiments, method 200 further includes: determining a self-attention weight corresponding to each pixel in the feature map based on a self-attention mechanism; and performing a weighted calculation on each pixel in the feature map based on the self-attention weights to update the feature map, wherein the relevance weight corresponding to each pixel in the feature map is determined based on the updated feature map. Thus, by determining the self-attention weights to indicate the importance of each pixel in the feature map, and performing a weighted calculation based on the importance to optimize the feature map of the input image, the updated feature map can more accurately indicate key features, thereby improving detection accuracy.
[0065] Figure 3 A schematic diagram of the structure of a model for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown. Figure 3 As shown, the model used to detect objects in an image includes a feature extraction network 301, a self-attention encoder 302, a mutual attention decoder 303, and a classification network 404.
[0066] By inputting the input image into the feature extraction network 301, a preliminary feature map is obtained, indicating the shallow visual features of the input image. The feature extraction network 301 can be, for example, a convolutional neural network or a feature extraction network based on a Transformer structure. By inputting the preliminary feature map into the self-attention encoder 302, the self-attention mechanism determines the self-attention weight corresponding to each pixel in the feature map, and then updates the feature map based on the self-attention weights, so that the updated feature map can more accurately indicate key features. After optimizing the encoding of image features using the self-attention encoder 302, its updated feature map and the corresponding object features of multiple objects to be detected are input into the mutual attention decoder 303 to obtain the relevance weight of each pixel in the feature map for each object to be detected, thus obtaining the predicted features of the input image corresponding to each object to be detected. Using the predicted features corresponding to each object to be detected, the image features closely related to that object in the input image can be more accurately and efficiently indicated. By inputting the predicted features corresponding to multiple objects to be detected into the classification network 304, the detection result for each object to be detected can be obtained.
[0067] In this example, the classification network 304 can be, for example, multiple parallel binary classifiers, each corresponding to a target object. By inputting the predicted features of each target object into the binary classifier corresponding to that target object, a detection result indicating whether the target object is included in the input image can be obtained.
[0068] In one example, when the input image includes a human body and multiple objects to be detected belong to multiple categories of human actions to be detected, a detection result indicating the category of human actions in each input image can be obtained.
[0069] According to one aspect of this disclosure, a method for training a model for detecting objects in an image is also provided. Figure 4 A flowchart illustrating a training method 400 for a model for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown. The model for detecting objects in an image includes a feature extraction network and a detection network. Figure 4 As shown, method 400 includes:
[0070] Step S401: Obtain a sample image including the sample object, and label the real information of the sample object;
[0071] Step S402: Initialize multiple object features corresponding to multiple objects to be detected;
[0072] Step S403: Input the sample image into the feature extraction network to obtain the feature map of the sample image;
[0073] Step S404: For each of the plurality of objects to be detected, based on the object features corresponding to the object to be detected and the feature map, determine the relevance weight corresponding to each pixel in the feature map, wherein the relevance weight corresponding to each pixel indicates the probability that the pixel corresponds to the object to be detected;
[0074] Step S405: Perform a weighted calculation on each pixel in the feature map based on the correlation weight, so as to determine the predicted feature corresponding to the object to be detected based on the weighted feature map;
[0075] Step S406: Input the predicted features into the detection network to obtain the detection result for the object to be detected output by the classification network;
[0076] Step S407: Calculate the loss value based on the multiple detection results corresponding to the multiple objects to be detected and the real information of the sample objects;
[0077] Step S408: Based on the loss value, adjust the parameters of the feature extraction network and the detection network; and
[0078] Step S409: Input the sample image into the feature extraction network after parameter adjustment to update the object features corresponding to the sample object.
[0079] By using sample images for training to obtain a model for detecting objects in images and the corresponding object features of the objects to be detected, it is possible to obtain a set of trained detection models and object features more efficiently, and then perform object detection in images based on this, thereby improving detection accuracy.
[0080] According to some embodiments, the detection network is a classification network, and the detection result for the object to be detected indicates whether the object to be detected is included in the sample image. Thus, a relatively simple classification task can be performed based on predicted features, thereby achieving accurate and efficient detection of objects in an image.
[0081] According to one aspect of this disclosure, an apparatus for detecting objects in an image is also provided. Figure 5A structural block diagram of an apparatus 500 for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown. Figure 5 As shown, the device 500 includes:
[0082] The feature extraction unit 501 is configured to extract features from the input image to obtain a feature map of the input image;
[0083] The first acquisition unit 502 is configured to acquire multiple object features corresponding to multiple objects to be detected;
[0084] The first determining unit 503 is configured to, for each of the plurality of objects to be detected, determine the relevance weight corresponding to each pixel in the feature map based on the object features corresponding to the object to be detected and the feature map, wherein the relevance weight corresponding to each pixel indicates the probability that the pixel corresponds to the object to be detected.
[0085] The first calculation unit 504 is configured to perform a weighted calculation on each pixel in the feature map based on the correlation weight, so as to determine the predicted features corresponding to the object to be detected based on the weighted feature map; and
[0086] The second determining unit 505 is configured to determine the detection result for the object to be detected based on the predicted features.
[0087] According to some embodiments, the object features corresponding to the object to be detected are obtained using an image processing model that includes a feature extraction network, and the image processing model is trained using sample images including the object to be detected.
[0088] According to some embodiments, the feature extraction unit 501 is configured to input the input image into the feature extraction network to obtain a feature map of the input image.
[0089] According to some embodiments, the image processing model further includes a classification network, the classification result output by the classification network being used to indicate whether the image input to the image processing model includes the object to be detected, and the second determining unit 505 is configured to: input the predicted features into the classification network to obtain a detection result indicating whether the input image includes the object to be detected.
[0090] According to some embodiments, the classification network includes multiple binary classifiers corresponding to the plurality of objects to be detected, and the second determining unit 505 is configured to: input the predicted features into the binary classifier corresponding to the object to be detected to obtain a detection result indicating whether the input image includes the object to be detected.
[0091] According to some embodiments, the apparatus 500 further includes: a third determining unit configured to determine a self-attention weight corresponding to each pixel in the feature map based on a self-attention mechanism; and a second calculating unit configured to perform a weighted calculation on each pixel in the feature map based on the self-attention weight to update the feature map, wherein the relevance weight corresponding to each pixel in the feature map is determined based on the updated feature map.
[0092] According to some embodiments, the input image includes a human body, and the object to be detected includes a category of human motion to be detected.
[0093] It should be understood that Figure 5 The operation of each unit of the apparatus 500 for detecting objects in an image shown can be synchronized with... Figure 2 The steps in the method 200 for detecting objects in an image are described accordingly. Therefore, the operations, features, and advantages described above for method 200 also apply to apparatus 500 and its constituent units. For the sake of brevity, some operations, features, and advantages will not be repeated here.
[0094] According to one aspect of this disclosure, a training apparatus for a model for detecting objects in an image is also provided. Figure 6 A structural block diagram of a training apparatus 600 for detecting objects in an image according to an exemplary embodiment of the present disclosure is shown. The model for detecting objects in an image includes a feature extraction network and a detection network. Figure 6 As shown, the device 600 includes:
[0095] The second acquisition unit 601 is configured to acquire a sample image including a sample object and label the real information of the sample object;
[0096] Initialization unit 602 is configured to initialize multiple object features corresponding to multiple objects to be detected;
[0097] The first input unit 603 is configured to input the sample image into the feature extraction network to obtain a feature map of the sample image;
[0098] The fourth determining unit 604 is configured to, for each of the plurality of objects to be detected, determine the relevance weight corresponding to each pixel in the feature map based on the object features corresponding to the object to be detected and the feature map, wherein the relevance weight corresponding to each pixel indicates the probability that the pixel corresponds to the object to be detected.
[0099] The third calculation unit 605 is configured to perform a weighted calculation on each pixel in the feature map based on the correlation weight, so as to determine the predicted features corresponding to the object to be detected based on the weighted feature map; and
[0100] The second input unit 606 is configured to input the predicted features into the detection network to obtain the detection result for the object to be detected output by the classification network;
[0101] The fourth calculation unit 607 is configured to calculate the loss value based on multiple detection results corresponding to the multiple objects to be detected and the real information of the sample objects;
[0102] The parameter tuning unit 608 is configured to adjust the parameters of the feature extraction network and the detection network based on the loss value; and
[0103] The update unit 609 is configured to input the sample image into the feature extraction network after parameter adjustment in order to update the object features corresponding to the sample object.
[0104] According to some embodiments, the detection network is a classification network, and the detection result for the object to be detected indicates whether the sample image includes the object to be detected.
[0105] It should be understood that Figure 6 The operation of each unit of the training device 600 for the model used to detect objects in an image, as shown, can be synchronized with... Figure 4 The steps in the training method 400 for detecting objects in an image described correspond to each other. Therefore, the operations, features, and advantages described above for method 400 also apply to device 600 and its constituent units.
[0106] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the technical solution disclosed herein comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0107] According to another aspect of this disclosure, an electronic device is also provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the above-described method for detecting objects in an image.
[0108] According to another aspect of this disclosure, a non-transitory computer-readable storage medium storing computer instructions is also provided, wherein the computer instructions are used to cause the computer to perform the above-described method for detecting objects in an image.
[0109] According to another aspect of this disclosure, a computer program product is also provided, comprising a computer program, wherein the computer program, when executed by a processor, implements the above-described method for detecting objects in an image.
[0110] refer to Figure 7 The present invention describes a structural block diagram of an electronic device 700 that can serve as a server or client of the present disclosure, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0111] like Figure 7 As shown, device 700 includes a computing unit 701, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 702 or a computer program loaded from storage unit 708 into random access memory (RAM) 703. RAM 703 may also store various programs and data required for the operation of device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.
[0112] Multiple components in device 700 are connected to I / O interface 705, including: input unit 706, output unit 707, storage unit 708, and communication unit 709. Input unit 706 can be any type of device capable of inputting information to device 700. Input unit 706 can receive input numerical or character information and generate key signal inputs related to user settings and / or function control of the electronic device, and may include, but is not limited to, a mouse, keyboard, touchscreen, trackpad, trackball, joystick, microphone, and / or remote control. Output unit 707 can be any type of device capable of presenting information, and may include, but is not limited to, a monitor, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 708 may include, but is not limited to, a hard disk and an optical disk. Communication unit 709 allows device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth™ devices, 802.11 devices, WiFi devices, WiMax devices, cellular communication devices, and / or the like.
[0113] The computing unit 701 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as methods for detecting objects in an image. For example, in some embodiments, the method for detecting objects in an image may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by computing unit 701, one or more steps of the method for detecting objects in an image described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform methods for detecting objects in an image by any other suitable means (e.g., by means of firmware).
[0114] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0115] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0116] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0117] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0118] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), the Internet, and blockchain networks.
[0119] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0120] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0121] While embodiments or examples of this disclosure have been described with reference to the accompanying drawings, it should be understood that the methods, systems, and devices described above are merely exemplary embodiments or examples, and the scope of the invention is not limited to these embodiments or examples. Various elements in the embodiments or examples may be omitted or replaced by their equivalents. Furthermore, the steps may be performed in a different order than that described in this disclosure. Further, various elements in the embodiments or examples may be combined in various ways. Importantly, as the technology evolves, many elements described herein can be replaced by equivalents that appear after this disclosure.
Claims
1. A method for detecting an object in an image, comprising: performing feature extraction on an input image to obtain a feature map of the input image; obtaining a plurality of object features respectively corresponding to a plurality of to-be-detected objects; for each to-be-detected object in the plurality of to-be-detected objects, determining a query of a mutual attention mechanism based on the object feature corresponding to the to-be-detected object, and determining a key of the mutual attention mechanism based on the feature map, to determine a weight heat map corresponding to the feature map by using the mutual attention mechanism, wherein a heat value of each pixel point in the weight heat map indicates a relevance weight of a pixel point at a corresponding position in the feature map, and the relevance weight corresponding to each pixel point in the feature map indicates a probability that the pixel point corresponds to the to-be-detected object, wherein when the to-be-detected object is a preset target object, the heat value is used to indicate a probability that the input image contains the target object and a pixel point or a pixel point within a preset range around the pixel point belongs to the target object; performing weighted calculation based on the heat value of each pixel point in the weight heat map and each pixel point in the feature map, and performing linear mapping transformation on the feature map after the weighted calculation to obtain a predicted feature corresponding to the to-be-detected object in a vector form; and determining a detection result for the to-be-detected object based on the predicted feature, comprising: inputting the predicted feature into a binary classifier corresponding to the to-be-detected object to obtain a detection result indicating whether the input image includes the to-be-detected object.
2. The method of claim 1, wherein, The object feature corresponding to the to-be-detected object is obtained by using an image processing model comprising a feature extraction network, and the image processing model is obtained by training using sample images comprising the to-be-detected object.
3. The method of claim 2, wherein, The feature extraction on the input image to obtain the feature map of the input image comprises: inputting the input image into the feature extraction network to obtain the feature map of the input image.
4. The method of any one of claims 1-3, further comprising: determining a self-attention weight corresponding to each pixel point in the feature map based on a self-attention mechanism; and performing weighted calculation on each pixel point in the feature map based on the self-attention weight to update the feature map, and wherein the relevance weight corresponding to each pixel point in the feature map is determined based on the updated feature map. The input image comprises a human body, and the to-be-detected object comprises a to-be-detected human action category.
5. The method of any one of claims 1-3, wherein, 6. A training method of a model for detecting an object in an image, the model for detecting an object in an image comprising a feature extraction network and a detection network, the detection network comprising a plurality of binary classifiers respectively corresponding to a plurality of to-be-detected objects, the method comprising: obtaining a sample image comprising a sample object and labeling real information of the sample object; initializing a plurality of object features respectively corresponding to a plurality of to-be-detected objects; inputting the sample image into the feature extraction network to obtain a feature map of the sample image; for each to-be-detected object in the plurality of to-be-detected objects, The query terms for the mutual attention mechanism are determined based on the object features corresponding to the object to be detected, and the key terms for the mutual attention mechanism are determined based on the feature map. The mutual attention mechanism is used to determine the weight heatmap corresponding to the feature map. The heatmap value of each pixel in the weight heatmap indicates the relevance weight of the pixel at the corresponding position in the feature map. The relevance weight corresponding to each pixel in the feature map indicates the probability that the pixel corresponds to the object to be detected. When the object to be detected is a preset target object, the heatmap value is used to indicate the probability that the sample image contains the target object and that the pixel or the pixels within a preset range around the pixel belong to the target object. The heat value of each pixel in the weighted heatmap and each pixel in the feature map are weighted and calculated, and the weighted feature map is transformed by linear mapping to obtain the predicted features in vector form corresponding to the object to be detected. The predicted features are input into the binary classifier corresponding to the object to be detected in the detection network to obtain a detection result indicating whether the sample image includes the object to be detected; Based on the multiple detection results corresponding to the multiple objects to be detected and the real information of the sample objects, the loss value is calculated; Based on the loss value, adjust the parameters of the feature extraction network and the detection network; and The sample image is input into the feature extraction network after parameter adjustment to update the object features corresponding to the sample object.
7. An apparatus for detecting objects in an image, comprising: The feature extraction unit is configured to extract features from the input image to obtain a feature map of the input image; The first acquisition unit is configured to acquire multiple object features corresponding to multiple objects to be detected; The first determining unit is configured to, for each of the plurality of objects to be detected, determine a query term for the mutual attention mechanism based on the object features corresponding to the object to be detected, and determine a key term for the mutual attention mechanism based on the feature map, so as to determine a weight heatmap corresponding to the feature map using the mutual attention mechanism. The heatmap value of each pixel in the weight heatmap indicates the relevance weight of the pixel at the corresponding position in the feature map, and the relevance weight corresponding to each pixel in the feature map indicates the probability that the pixel corresponds to the object to be detected. When the object to be detected is a preset target object, the heatmap value is used to indicate the probability that the input image contains the target object and that the pixel or pixels within a preset range around the pixel belong to the target object. The first calculation unit is configured to perform a weighted calculation based on the heat value of each pixel in the weighted heatmap and each pixel in the feature map, and to perform a linear mapping transformation on the weighted feature map to obtain a vector-form predicted feature corresponding to the object to be detected; and The second determining unit is configured to determine a detection result for the object to be detected based on the predicted features, including: inputting the predicted features into a binary classifier corresponding to the object to be detected to obtain a detection result indicating whether the input image includes the object to be detected.
8. The apparatus of claim 7, wherein, The object features corresponding to the object to be detected are obtained using an image processing model that includes a feature extraction network, and the image processing model is trained using sample images including the object to be detected.
9. The apparatus of claim 8, wherein, The feature extraction unit is configured as follows: The input image is input into the feature extraction network to obtain the feature map of the input image.
10. The apparatus of any one of claims 7-9, further comprising: The third determining unit is configured to determine the self-attention weight corresponding to each pixel in the feature map based on the self-attention mechanism. as well as The second computation unit is configured to perform a weighted calculation on each pixel in the feature map based on the self-attention weights to update the feature map. Furthermore, the relevance weight corresponding to each pixel in the feature map is determined based on the updated feature map.
11. The apparatus of any one of claims 7-9, wherein, The input image includes a human body, and the object to be detected includes the human action category to be detected.
12. A training apparatus for a model for detecting objects in an image, the model for detecting objects in an image comprising a feature extraction network and a detection network, the detection network comprising multiple binary classifiers corresponding to multiple objects to be detected, the apparatus comprising: The second acquisition unit is configured to acquire a sample image including a sample object and label the real information of the sample object; The initialization unit is configured to initialize multiple object features corresponding to multiple objects to be detected; The first input unit is configured to input the sample image into the feature extraction network to obtain a feature map of the sample image; The fourth determining unit is configured to, for each of the plurality of objects to be detected, determine a query term for the mutual attention mechanism based on the object features corresponding to the object to be detected, and determine a key term for the mutual attention mechanism based on the feature map, so as to determine a weighted heatmap corresponding to the feature map using the mutual attention mechanism. The heatmap value of each pixel in the weighted heatmap indicates the relevance weight of the pixel at the corresponding position in the feature map, and the relevance weight corresponding to each pixel in the feature map indicates the probability that the pixel corresponds to the object to be detected. When the object to be detected is a preset target object, the heatmap value is used to indicate the probability that the sample image contains the target object and that the pixel or the pixels within a preset range around the pixel belong to the target object. The third calculation unit is configured to perform weighted calculations based on the heat value of each pixel in the weighted heatmap and each pixel in the feature map, and to perform a linear mapping transformation on the weighted feature map to obtain a vector-form predicted feature corresponding to the object to be detected. The second input unit is configured to input the predicted features into the binary classifier in the detection network corresponding to the object to be detected, so as to obtain a detection result indicating whether the sample image includes the object to be detected; The fourth calculation unit is configured to calculate the loss value based on multiple detection results corresponding to the multiple objects to be detected and the real information of the sample objects; A parameter tuning unit is configured to adjust the parameters of the feature extraction network and the detection network based on the loss value; and The update unit is configured to input the sample image into the feature extraction network after parameter adjustment in order to update the object features corresponding to the sample object.
13. An electronic device, comprising: At least one processor; as well as A memory that is communicatively connected to the at least one processor; in The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-6.
15. A computer program product comprising a computer program, wherein, The computer program, when executed by a processor, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Object detection method and device, computer readable storage medium and computer equipment
CN109886282A
Image detection method and device and computer readable storage medium
CN111402228A
Transform-based traffic scene small sample target detection method and device
CN116052108A
