Training method and device of object detection model, computer equipment, medium and program product
By employing parallel input and feature-level alignment during object detection model training, the problem of high computational cost of the GLIP model is solved, enabling rapid training and adaptation to open-world object detection of unknown categories.
Patent Information
- Application Number
- CN202510690575.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2026-11-27
AI Technical Summary
Existing open-world object detection training methods based on the GLIP model involve large computational loads, resulting in long training times and making them unsuitable for practical engineering deployments.
Parallel input is used instead of serial input. The features of reference category text samples and image samples are extracted by the current text encoder and image encoder respectively, and the model parameters are adjusted to meet the matching conditions. The fusion operation is removed to reduce the amount of computation.
It shortens the training time of the object detection model, reduces the amount of computation, supports streaming processing and low-resource deployment, adapts to unknown categories, and enables open-world object detection.
Smart Images

Figure CN123182235A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a training method, apparatus, computer device, medium, and program product for an object detection model. Background Technology
[0002] Object detection refers to locating and recognizing objects in an image. This type of object detection typically relies on a predefined set of categories, such as the 80 categories in the COCO dataset, meaning it can only detect categories learned during training. Open-world object detection, on the other hand, refers to locating and recognizing any object in an image, and it can detect categories not learned during training.
[0003] In related technologies, Grounded Language-Image Pre-training (GLIP) models are generally used as object detection models to achieve open-world object detection. During the training of the GLIP model, it learns more refined connections between images and text phrases, unifying object detection and phrase association tasks in pre-training.
[0004] However, training the GLIP model for open-world detection is computationally intensive, resulting in a long training time, which is not conducive to practical engineering deployment. Summary of the Invention
[0005] To address the aforementioned technical issues, this application provides a training method, apparatus, computer equipment, medium, and program product for an object detection model, which reduces computational load, shortens the training time for the object detection model, and facilitates the engineering deployment of the object detection model.
[0006] The embodiments of this application disclose the following technical solutions:
[0007] On one hand, embodiments of this application provide a training method for an object detection model, wherein the current object detection model includes a current text encoder, a current image encoder, and a current recognizer, and the method includes:
[0008] Acquire a first image sample and a target location, wherein the first image sample includes at least one target object, and the target location indicates a preset position of the target object in the first image sample;
[0009] Multiple reference category text sample features are obtained. These multiple reference category text sample features are extracted from the multiple reference category text samples by the current text encoder. Each of the multiple reference category text samples is used to describe one of the multiple reference categories. The multiple reference categories include the target category corresponding to the target object.
[0010] The object image sample features of the target object are extracted from the first image sample by the current image encoder;
[0011] The current recognizer determines the predicted position of the target object in the first image sample and the predicted category text feature based on the object image sample features, wherein the predicted category text feature refers to the predicted category of the target object.
[0012] The current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted position and the target position satisfy a first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition.
[0013] On the other hand, embodiments of this application provide a method for training an object detection model, the method comprising:
[0014] Obtain multiple second initial reference category text samples and initial image samples;
[0015] The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples.
[0016] Multiple second text sample features are extracted from the multiple first input sequences by a second text encoder;
[0017] Extract a partial image including the target object from the initial image sample;
[0018] The second image sample features are extracted from the local image using a second image encoder.
[0019] The local sample features of the target object included in the initial image sample are extracted from the initial image sample by the current classifier, as well as the classification sample features of the target object.
[0020] The model parameters of the current classifier are adjusted so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model, which includes a classifier trained based on the current classifier and the second text encoder.
[0021] On the other hand, embodiments of this application provide a training device for an object detection model. The current object detection model includes a current text encoder, a current image encoder, and a current recognizer. The device includes: an acquisition unit, an extraction unit, a recognition unit, and a training unit.
[0022] The acquisition unit is used to acquire a first image sample and a target location, wherein the first image sample includes at least one target object, and the target location indicates a preset position of the target object in the first image sample;
[0023] The acquisition unit is further configured to acquire multiple reference category text sample features, which are obtained by the current text encoder from the multiple reference category text samples respectively. The multiple reference category text samples are used to describe one of the multiple reference categories, and the multiple reference categories include the target category corresponding to the target object.
[0024] The extraction unit is used to extract object image sample features of the target object from the first image sample through the current image encoder;
[0025] The recognition unit is used to determine the predicted position of the target object in the first image sample and the predicted category text feature based on the object image sample features using the current recognizer, wherein the predicted category text feature refers to the predicted category of the target object;
[0026] The training unit is configured to train the current object detection model by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted position and the target position satisfy a first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition.
[0027] On the other hand, embodiments of this application provide a training apparatus for an object detection model, the apparatus comprising: an acquisition unit, a splicing unit, an extraction unit, a truncating unit, and a training unit;
[0028] The acquisition unit is used to acquire multiple second initial reference category text samples and initial image samples;
[0029] The splicing unit is used to splice the learnable parameters with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples.
[0030] The extraction unit is used to extract multiple second text sample features from the multiple first input sequences through a second text encoder;
[0031] The cropping unit is used to crop a partial image including the target object from the initial image sample;
[0032] The extraction unit is further configured to extract second image sample features from the local image using a second image encoder;
[0033] The extraction unit is further configured to extract local sample features of the target object included in the initial image sample and classification sample features of the target object from the initial image sample using the current classifier;
[0034] The training unit is used to adjust the model parameters of the current classifier so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model. The second object detection model includes a classifier trained based on the current classifier and the second text encoder.
[0035] On the other hand, embodiments of this application provide a computer device, the computer device including a processor and a memory:
[0036] The memory is used to store computer programs and to transfer the computer programs to the processor;
[0037] The processor is configured to execute the methods described above according to instructions in the computer program.
[0038] On the other hand, embodiments of this application provide a computer-readable storage medium for storing a computer program for performing the methods described above.
[0039] On the other hand, embodiments of this application provide a computer program product including a computer program, which, when run on a computer device, causes the computer device to perform the methods described above.
[0040] As can be seen from the above technical solution, the first image sample and target location are obtained. The first image sample includes at least one target object to be identified, and the target location indicates a preset position of the target object in the first image sample. The target object in the first image sample is extracted by the current image encoder to obtain object image sample features describing the target object. Multiple reference category text sample features are obtained, each describing a reference category to which an object belongs. These multiple reference category text sample features include the reference category text sample features corresponding to the target category, i.e., the reference category text sample features corresponding to the reference category to which the target object belongs. The reference category text sample features are extracted by the current text encoder from the reference category text samples describing the reference category. Since the multiple reference category text samples are extracted separately, it is equivalent to inputting multiple reference category text samples into the current text encoder in parallel, eliminating the need for repeated calculations and reducing computational load. Furthermore, this method can dynamically expand the reference categories by adding reference category text samples to adapt to unknown categories, achieving open-world object detection. The object image sample features are identified by the current recognizer to determine the predicted position of the target object in the first image sample and the predicted category text features of the target object. Finally, the current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted location and the target location satisfy the first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy the second matching condition. This allows the first object detection model trained based on the current object detection model to not only identify the location of the object in the image but also to identify the category to which the object belongs. During the training process of the object detection model, alignment is performed directly at the feature level, i.e., the blending operation is removed. This not only forces the first object detection model to learn cross-modal semantic consistency through the alignment process but also reduces the computational cost required to train the first object detection model. This shortens the training time of the object detection model and facilitates its engineering deployment. Attached Figure Description
[0041] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a schematic diagram illustrating the training process of a GLIP model in related technologies;
[0043] Figure 2A schematic diagram of a computer system for a multimodal model training method provided in an embodiment of this application;
[0044] Figure 3 A schematic diagram illustrating an application scenario of a training method for an object detection model provided in an embodiment of this application;
[0045] Figure 4 A flowchart illustrating a training method for an object detection model provided in an embodiment of this application;
[0046] Figure 5 A schematic diagram of a first image sample provided in an embodiment of this application;
[0047] Figure 6 This is a schematic diagram illustrating the application process of a first object detection model provided in an embodiment of this application;
[0048] Figure 7 This is a schematic diagram illustrating a classification result obtained based on an application image, as provided in an embodiment of this application.
[0049] Figure 8 A schematic diagram of an initial image sample provided in an embodiment of this application;
[0050] Figure 9 A schematic diagram illustrating the acquisition of a first image sample provided in an embodiment of this application;
[0051] Figure 10 A schematic diagram illustrating the training of a second object detection model provided in an embodiment of this application;
[0052] Figure 11 A schematic diagram illustrating the training of learnable parameters provided in an embodiment of this application;
[0053] Figure 12 A schematic diagram of the structure of a training device for an object detection model provided in an embodiment of this application;
[0054] Figure 13 A schematic diagram of the structure of a training device for an object detection model provided in an embodiment of this application;
[0055] Figure 14 This application provides a schematic diagram of the structure of a server according to an embodiment of the present application.
[0056] Figure 15 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0058] It should be noted that this application may display a prompt interface, pop-up window, or output voice prompt information before and during the collection of user-related data (such as the first image sample, the second image sample, etc.). This prompt interface, pop-up window, or voice prompt information is used to inform the user that their relevant data is being collected. This ensures that the application only begins the steps related to collecting user-related data after receiving confirmation from the user regarding the prompt interface or pop-up window; otherwise (i.e., without receiving confirmation from the user), the steps to collect user-related data end, meaning no user-related data is collected. In other words, all user data collected in this application is collected with the user's consent and authorization, and the collection, use, and processing of relevant user data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0059] Among related technologies, while the GLIP model can achieve open-world object detection, its training process involves a large amount of computation. The following section combines... Figure 1 Perform the analysis.
[0060] See Figure 1 The figure illustrates the training process of a GLIP model in related technologies. Figure 1 In this process, multiple reference category text samples (i.e., airplanes, people, dogs, etc.) used for training are combined to form an input sequence, which is then fed into the current text encoder at once. The current text encoder extracts features to obtain initial text sample features. Image samples used for training are input into the visual encoder to obtain image features. Multiple text layers and multiple neck networks are used to fuse the image features and initial text sample features, resulting in reference category text sample features for each reference category text sample and object image sample features for each object. Finally, based on the training objective of maximizing the similarity between object image sample features and their corresponding reference category text sample features, a GLIP model is trained. This GLIP model includes a text encoder trained on the current text encoder and a visual encoder trained on the current visual encoder.
[0061] In this process, numerous fusion operations are used to continuously integrate image features and initial text sample features to improve recognition accuracy. However, during the training of the GLIP model, fusion operations result in a large amount of computation, leading to a long training time. Furthermore, multiple reference category text samples need to be combined into a single sentence input, which is equivalent to serially inputting multiple text category samples into the current text encoder (hereinafter referred to as the serial input method). This causes a surge in the number of tokens, limiting the number of categories available for training, causing excessive memory load on computing devices such as Graphics Processing Units (GPUs), and leading to numerous repetitive computations. For example, under the same hardware conditions, the serial input method is limited by hardware limitations and cannot infer a large number of categories at once, thus limiting the object categories. As another example, when testing the Large Vocabulary Instance Segmentation (LVIS) dataset using the original GLIP method, since this dataset contains 1203 categories and processes 30 labels each time, it requires 41 processing steps, equivalent to performing 41 inferences on a single image. This method is time-consuming and unsuitable for industrial applications.
[0062] In other words, training the GLIP model for open-world detection is computationally intensive, resulting in a long training time, which is not conducive to practical engineering deployment.
[0063] Based on this, embodiments of this application provide a training method for an object detection model. By modifying the serial input method to a parallel input method, the computational load is reduced while ensuring that the first object detection model can achieve open-world object detection. By removing the fusion operation, the computational load is further reduced, thereby shortening the training time of the object detection model and facilitating the engineering deployment of the first object detection model.
[0064] To facilitate understanding of the training method for the object detection model provided in this application embodiment, the computer system for training the object detection model will be described below.
[0065] See Figure 2 This figure is a schematic diagram of a computer system for a multimodal model training method provided in an embodiment of this application. The computer system 200 includes a terminal device 210 and a server 220. The terminal device 210 and the server 220 can communicate with each other through a communication network. The device can be a terminal device or a server.
[0066] The communication network uses standard communication technologies and / or protocols, typically the Internet, but can also be any network, including but not limited to Bluetooth, local area network (LAN), metropolitan area network (MAN), wide area network (WAN), mobile, private network, or any combination of virtual private network. In some embodiments, custom or dedicated data communication technologies may be used to replace or supplement the aforementioned data communication technologies.
[0067] The terminal device can be an electronic device such as a smartphone, wearable device, personal computer (PC), intelligent voice interaction device, smart home appliance, vehicle terminal, aircraft, or unmanned vending terminal. A client application for the target application can be installed and run on the terminal device. This target application can be an application supporting multi-modal image recognition, or other applications supporting image storage, image creation, and image display; this application does not limit its scope. Furthermore, this application does not limit the form of the target application, including but not limited to applications (Apps), mini-programs, etc., installed on the terminal device, and can also be in the form of a webpage.
[0068] A server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services such as cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and basic cloud computing services such as big data. The server can be a backend server for the aforementioned target application, providing backend services to the client of the target application.
[0069] To facilitate understanding of the object detection model training method provided in this application embodiment, the following example uses a server as the execution subject of the object detection model training method to illustrate the application scenarios of the object detection model training method.
[0070] See Figure 3 This figure is a schematic diagram illustrating an application scenario of a training method for an object detection model provided in an embodiment of this application. Figure 3 In this application scenario, terminal device 211, server 221, and server 222 are included.
[0071] Server 221 acquires multiple reference category text sample features. Each reference category text sample feature describes a reference category to which the object belongs. For example, airplane, person, and dog are three reference category text samples, corresponding to three reference categories. The reference category text sample features are extracted by the current text encoder from the reference category text samples describing that reference category. Figure 3 As shown, multiple reference category text samples are used as input sequences and independently input into the current text encoder. The current text encoder extracts the reference category text sample features corresponding to each reference category text sample.
[0072] In other words, multiple reference category text samples are extracted separately, which is equivalent to inputting multiple reference category text samples into the current text encoder in parallel, encoding each reference category text sample independently. This supports streaming processing and low-resource deployment, reducing computational load. Moreover, this method does not rely on collinear relationships in sentences and can dynamically expand the reference categories by adding reference category text samples, thereby adapting to unknown categories and achieving open-world object detection.
[0073] Server 221 acquires a first image sample and a target location. The first image sample includes at least one target object, and the target location indicates a preset position of the target object within the first image sample. As a possible implementation, the target location can be marked within the first image sample. For example, see [link to previous section]. Figure 3 The first image sample contains a reference bounding box, which includes the target object. The reference bounding box marks the preset position of the target object within the first image sample. The first image sample is then extracted using the current image encoder to obtain object image sample features describing the target object. (Continue to see...) Figure 3 The current image encoder extracts image regions marked by reference recognition boxes to obtain object image sample features describing the corresponding target object. The current recognizer then identifies these object image sample features to obtain the predicted position of the target object in the first image sample, as well as the predicted category text feature of the target object, which indicates the predicted category of the target object. For example... Figure 3 As shown, based on the first image sample, multiple predicted recognition boxes are obtained to identify each target object, as well as the predicted category text features corresponding to each target object. The predicted recognition boxes are used to describe the predicted position of the target object in the first image sample obtained by prediction.
[0074] Finally, server 221 trains the current object detection model by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted location and the target location satisfy the first matching condition, and / or the predicted category text features and the reference category text sample features corresponding to the target category satisfy the second matching condition, and continues as follows. Figure 3 As shown, this can minimize the difference between the predicted location and the target location, and the target category and the predicted category ( Figure 3 This approach not only outputs predicted category text features but also minimizes the differences between predicted categories. This allows the first object detection model trained on the current model to not only identify the location of objects in images but also to recognize the reference category to which the object belongs. During the training process, alignment is performed directly at the feature level, eliminating blending operations. This alignment process forces the first object detection model to learn cross-modal semantic consistency and reduces the computational cost of training it. This shortens the training time and facilitates the engineering deployment of the first object detection model.
[0075] After training the first object detection model, server 221 can deploy the trained first object detection model on server 221 or on other servers. For example... Figure 3 As shown, server 221 sends the first object detection model to server 222, deploys the first object detection model on server 222, and server 222 provides object detection services.
[0076] The terminal device 211 has a target application installed. The user sends a detection command for the video through the target application. The server 222 then detects the objects in the video based on the detection command, identifies the objects in the video through a recognition box, marks the reference category to which the object belongs on the recognition box, and returns it as the detection result to the terminal device 221.
[0077] The object detection model training method provided in this application embodiment can be executed by a server. However, in other embodiments of this application, the terminal device may also have similar functions to the server to execute the object detection model training method provided in this application embodiment, or the terminal device and the server may jointly execute the object detection model training method provided in this application embodiment. This embodiment does not limit this.
[0078] The following describes in detail a training method for an object detection model provided in this application through method embodiments.
[0079] See Figure 4This figure is a schematic flowchart illustrating a training method for an object detection model provided in an embodiment of this application. For ease of description, the following embodiment uses a server as the execution entity of the object detection model training method. Figure 4 As shown, the training methods for this object detection model include S401-S405, as detailed below.
[0080] S401: Obtain the first image sample and target location.
[0081] The first image sample is an image used for training, which includes at least one object, and the at least one object includes at least one target object waiting to be identified. That is, the target object is the object waiting to be identified during the training process. The object is a physical object that occupies a certain space, such as an airplane, a person, a dog, etc.
[0082] The target position is used to describe the preset position of the target object in the first image sample. The preset position refers to a known location in the first image sample, used to indicate the image area occupied by the target object in the first image sample. The embodiments of this application do not specifically limit the form of the target position. For example, the preset position of the target object can be marked in the first image sample by using a reference recognition box. Another example is that the preset position of the target object in the first image sample can be outlined using the coordinates of four points (up, down, left, and right). Yet another example is that the preset position of the target object in the first image sample can be marked by tracing the target object within the first image sample.
[0083] The reference recognition box is a type of recognition box, and the shape of the recognition box is not specifically limited in this application embodiment, such as a rectangle or a circle. The following explanation uses the example of marking the position of a target object in a first image sample using a reference recognition box. Different objects are outlined by different reference recognition boxes; that is, a portion of the image region in the first image sample is marked by a reference recognition box, and this image region includes a target object in the first image sample.
[0084] See Figure 5 This figure is a schematic diagram of a first image sample provided in an embodiment of this application. Figure 5 In the example, four target objects are identified using four reference bounding boxes: a dog, a person, shoes, and a shirt. In other words, each target object enclosed by a reference bounding box has a target category. The target category can be described in text form, resulting in reference category text samples, etc.
[0085] S402: Obtain features from multiple reference category text samples.
[0086] The reference category text sample features are extracted from the reference category text samples by the current text encoder and are used to describe the features of the reference category text samples.
[0087] The current text encoder is used for feature extraction from text. After training, the current text encoder can be used to obtain the first text encoder. That is, the current text encoder and the first text encoder have similar structures but different model parameters. Training the current text encoder and adjusting its model parameters will yield the first text encoder. For example, if the current text encoder needs 500 training iterations to obtain the first text encoder, then the models obtained from the 1st to the 499th training iterations are all the current text encoder, while the model obtained from the 500th training iteration is the first text encoder. This application does not specifically limit the first text encoder; it can be a text encoder in a GLIP model, a Bag of Words (BoW) model, a Long Short-Term Memory (LSTM) network, etc.
[0088] Reference category text samples are texts used for training to describe the reference categories to which objects belong, such as airplane, person, dog, etc. Multiple reference category text samples each correspond to one of the reference categories for multiple objects. These multiple reference category text samples include reference category text samples describing the target category to which the target object in the first image sample belongs. Different reference category text samples are used to describe different reference categories. Each reference category text sample corresponds to a reference category text sample feature. The current text encoder extracts reference category text samples from each of the multiple reference category text samples to obtain the reference category text sample features corresponding to each reference category text sample, thus obtaining multiple reference category text sample features. These multiple reference category text sample features are used to describe the reference category text samples for multiple objects, including the target object. The multiple reference category text sample features include reference category text sample features describing the target category to which the target object belongs.
[0089] As one possible approach, an offline vocabulary can be created, such as one based on caption data. For example, a vocabulary of approximately 13,000 reference category text samples could be generated based on the Coyo dataset. When using the vocabulary, multiple reference category text samples can be directly obtained from the offline vocabulary, which is convenient and fast. At the same time, the vocabulary expands the number of categories and improves the accuracy of zero-shot recognition.
[0090] It should be noted that, as mentioned above, in related technologies, multiple reference category text samples are combined into a single input sequence and used as a sentence for feature extraction (i.e., the process of feature extraction), which is a serial input method. However, in this embodiment, multiple reference category text samples are no longer combined into a single input sequence for feature extraction. Instead, they are treated as multiple input sequences, each treated as a sentence for feature extraction. This is equivalent to inputting multiple reference category text samples into the current text encoder in parallel, eliminating the need for repetitive calculations and reducing computational load. Furthermore, this method allows for the addition or deletion of reference category text samples without affecting other reference category text samples, thereby enabling dynamic expansion of reference category text samples, adapting to unknown categories, and achieving open-world object detection.
[0091] The embodiments of this application do not specifically limit the number of reference category text samples that make up the input sequence. Those skilled in the art can set it according to actual needs. The following describes two methods as examples.
[0092] Method 1 involves dividing the b reference category text samples into d combinations, with each combination including one or more reference category text samples. Each combination is then used as an input sequence and fed into the current text encoder. Here, b is a positive integer, and d is a positive integer less than b.
[0093] Method 2: Obtain multiple reference category text samples, input each reference category text sample independently into the current text encoder, and extract the features of the multiple reference category text samples through the current text encoder.
[0094] In this context, "independent input" means that multiple reference category text samples are no longer combined into a single sentence and input into the current text encoder. Instead, each reference category text sample is input as a separate sentence into the current text encoder. The current text encoder then extracts the features corresponding to each reference category text sample individually.
[0095] In other words, since multiple reference category text samples are input to the current text encoder independently, the current text encoder extracts features from each reference category text sample separately. Therefore, the extraction processes of the multiple extracted reference category text sample features do not affect each other and are all executed independently. This application does not specifically limit the extraction order between the features of multiple reference category text samples; those skilled in the art can set it according to actual needs.
[0096] Therefore, each reference category text sample is used as an input sequence, that is, each reference category text sample is input into the current text encoder as a sentence. This is equivalent to inputting multiple reference category text samples into the current text encoder in parallel, no longer relying on the co-occurrence relationship in the input sequence. This not only reduces the amount of computation, but also allows each reference category text sample to be encoded independently, thus supporting streaming processing and low-resource deployment. This further reduces the amount of computation, and not only can it make great use of text features during training, making it easy to introduce normal negative samples, but it can also achieve a large number of categories inference at once.
[0097] This application does not specifically limit the timing of obtaining the features of the reference category text samples. Those skilled in the art can set it according to actual needs. The following describes two methods as examples.
[0098] Method 1 involves pre-acquiring reference category text samples. Specifically, multiple reference category text samples are pre-acquired, and the current text encoder extracts features from these samples. This allows subsequent training to utilize these multiple reference category text sample features, regardless of which image is used as the first image sample. The multiple reference category text samples only need to include the reference category text samples corresponding to the target category. This method is convenient and fast, reduces training time, and improves user experience.
[0099] Method two allows for real-time acquisition. Specifically, after acquiring the first image sample, multiple reference category text samples can be selectively acquired based on the first image sample (e.g., multiple reference category text samples and the target object in the first image sample belong to the same sub-domain). The current text encoder then extracts features from these multiple reference category text samples. Therefore, by selectively choosing multiple corresponding reference category text samples based on the first image sample, the training of the first object detection model required for the refined domain can be achieved, improving the accuracy of the first object detection model.
[0100] S403: Extract the object image sample features of the target object from the first image sample using the current image encoder.
[0101] The current image encoder is used for feature extraction from an image. After training, the current image encoder can be used to obtain the first image encoder. That is, the current image encoder and the first image encoder have similar structures but different model parameters. Training the current image encoder and adjusting its model parameters will yield the first image encoder. For example, if the current image encoder requires 500 training iterations to obtain the first image encoder, then the models obtained from the 1st to the 499th training iterations are all the current image encoder, while the model obtained from the 500th training iteration is the first image encoder. This application does not specifically limit the first image encoder; it can be a text encoder in a GLIP model, a Convolutional Neural Network (CNN), a Recurrent Neural Network (CNN), etc.
[0102] Object image sample features are used to describe the characteristics of the target object and are extracted by the current image encoder. Taking a reference bounding box as the target location as an example, the image region marked by the reference bounding box includes a target object. The current image encoder extracts features from the image region marked by the reference bounding box to obtain object image sample features describing the target object outlined by the reference bounding box. These object image sample features are used to describe the characteristics of the target object.
[0103] S404: Using the current recognizer, determine the predicted position of the target object in the first image sample based on the object image sample features, as well as the predicted category text features.
[0104] The current recognizer can be obtained through training. That is, the current recognizer and the original recognizer have similar structures but different model parameters. By training the current recognizer and adjusting its model parameters, the original recognizer can be obtained. For example, if the current recognizer requires 500 training iterations to obtain the original recognizer, then the models obtained from the 1st to the 499th training iterations are all the current recognizer, and the model obtained from the 500th training iteration is the original recognizer. This application does not specifically limit the recognizer; it can be the head network of a GLIP model (such as a classification head and regression head), a Convolutional Neural Network (CNN), a Recurrent Neural Network (CNN), etc.
[0105] The current recognizer is used to identify the location of objects in an image and the category to which the objects belong. Specifically, the current recognizer is used to identify the predicted location and predicted category text features of the target object in the first image sample. For example, the object image sample features are input into the current recognizer, and the current recognizer extracts features from the image region bounded by the reference recognition box in the first image sample to obtain the predicted recognition box corresponding to the bounded image region, and the predicted category of the target object in the predicted recognition box.
[0106] The predicted position is obtained by searching for the object image sample features in the first image sample, which is the predicted position of the object image sample features in the first image sample. That is, the position predicted by the current recognizer is used to describe the position of the target object in the first image sample obtained by prediction.
[0107] The embodiments of this application do not specify the form of the predicted position. For example, the predicted position of the target object is marked in the first image sample by using a predicted recognition box. Another example is to circle the predicted position of the target object in the first image sample using the coordinates of four points (up, down, left, and right) obtained from the prediction. Yet another example is to mark the predicted position of the target object in the first image sample by outlining it.
[0108] A predicted bounding box is a type of recognition box that searches within a first image sample based on the object's image sample features to determine the position of those features within the first image sample, and then identifies the object using the predicted bounding box. Essentially, the current recognizer does not know the position of the target object corresponding to the object's image sample features within the first image sample; it searches for the object based on those features.
[0109] The predicted category text feature refers to the predicted category of the target object, used to describe the predicted category of the target object. The predicted category is the category to which the target object belongs, predicted by the current recognizer. For example, the current recognizer can select the category most similar to the target object from multiple reference category text samples and output the predicted category text feature, which is the feature used to describe the predicted category. For example, the similarity between the features of each reference category text sample and the features of the object image sample can be calculated, and then the predicted category text feature can be obtained by combining the features of the reference category text sample with the highest similarity, and even the predicted category can be obtained. The embodiments of this application do not specifically limit the form of the obtained predicted category, which can be in text form, speech form, etc.
[0110] One possible implementation is to use the current recognizer to identify the features of the object image sample and multiple reference category text sample features to obtain a predicted bounding box in the first image sample, as well as the predicted category text features and predicted category text corresponding to the target object within the predicted bounding box. For example, the object image sample features and multiple reference category text sample features are input into the current recognizer. The current recognizer then extracts features from the image region bounded by the reference bounding boxes in the first image sample, obtaining the predicted bounding box corresponding to the bounded image region, and the predicted category text corresponding to the target object within the predicted bounding box. Thus, the use of multiple reference category text sample features allows the current recognizer to enhance its understanding of the object and improve its recognition capability.
[0111] S405: Train the current object detection model by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted location and the target location satisfy a first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition.
[0112] The current object detection model includes a current text encoder, a current image encoder, and a current recognizer. Training the current object detection model involves adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer so that the predicted location and the target location satisfy a first matching condition, and / or the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition. Thus, after the current object detection model is trained, a first object detection model is obtained; the current text encoder is trained to obtain a first text encoder; the current image encoder is trained to obtain a first image encoder; and the current recognizer is trained to obtain a recognizer.
[0113] The adjustment of model parameters for the current text encoder, current image encoder, and / or current recognizer includes six methods: adjusting the model parameters for the current text encoder, adjusting the model parameters for the current image encoder, adjusting the model parameters for the current recognizer, adjusting the model parameters for both the current text encoder and the current image encoder, adjusting the model parameters for both the current text encoder and the current recognizer, adjusting the model parameters for both the current image encoder and the current recognizer, and adjusting the model parameters for the current text encoder, the current image encoder, and the current recognizer.
[0114] The embodiments of this application do not specifically limit the conditions for the completion of model training. It can be that the number of iterations in the model training process meets a preset number, the current object detection model obtained by training enables the predicted position and the target position to meet the first matching condition, and / or the predicted category text features and the reference category text sample features corresponding to the target category meet the second matching condition, etc., that is, the first matching condition and / or the second matching condition are used as training targets, etc., and this application does not make specific limitations in this regard.
[0115] The first matching condition is that the difference between the predicted and target locations is less than a first difference threshold. This application does not specifically limit the first difference threshold; for example, it may simply mean minimizing the difference between the predicted and target locations. The first matching condition is used as the training objective to train the current object detection model, enabling the trained model to identify the location of objects in an image.
[0116] Taking the predicted bounding box as the predicted location and the reference bounding box as the target location as an example, the predicted bounding box and the reference bounding box can satisfy the first matching condition, such as the difference between the predicted bounding box and the reference bounding box being less than the first difference threshold, or the difference between the predicted bounding box and the reference bounding box being minimized.
[0117] The second matching condition is that the difference between the predicted category text features and the reference category text sample features corresponding to the target category is less than a second difference threshold. This application does not specifically limit the second difference threshold; for example, it could be minimizing the difference between the predicted category text features and the reference category text sample features corresponding to the target category. Using the second matching condition as the training objective, the current object detection model is trained so that the trained first object detection model can determine the category to which the object belongs.
[0118] The predicted category text features are used to describe the predicted text and can be obtained through the current recognizer. That is, the current recognizer determines the predicted position of the target object in the first image sample, the predicted category of the target object, and the predicted category text features, etc., based on the object image sample features. This application does not impose specific limitations on this.
[0119] This application does not specifically limit the training objective of training the current object detection model. For example, it uses localization loss and phrase-region alignment loss as loss functions for illustration. In this embodiment, the predicted location is the predicted bounding box, the target location is the reference bounding box, and the predicted category text features are represented by the predicted category text.
[0120] Among them, the predicted recognition box and the reference recognition box satisfy the first matching condition and can be identified by the localization loss. The localization loss is used to optimize the regression accuracy of the recognition box and can be GIoU Loss, Smooth L1 Loss, etc., so that the first object detection model can optimize the coordinates of the detection box and make it accurately cover each object.
[0121] If the predicted category text and the reference category text sample corresponding to the target category satisfy the second matching condition, it can be identified by the phrase-region alignment loss. The phrase-region alignment loss is used to optimize the matching accuracy between the reference category text sample and the image region. It can be a contrastive loss or a binary cross-entropy loss, so that the first object detection model can ensure that the object in the text is correctly associated with the image region containing the object in the image, and avoid misaligning the image region to other categories or the background.
[0122] As a possible implementation, a classification loss can be introduced as a loss function on top of the localization loss and phrase-region alignment loss. The classification loss is used to deal with the class imbalance problem and can be the cross-entropy loss function, focal loss, etc., to ensure that the first object detection model can distinguish between each object in the image and the background.
[0123] Therefore, by training the current object detection model collaboratively using three loss functions, it can achieve dynamic category generalization based on classification loss (supporting the definition of new categories through input text), spatial accuracy through localization loss (ensuring that the bounding box is physically aligned with the corresponding object), and semantic consistency through phrase-region alignment loss, thereby establishing a semantic bridge between language and vision. Thus, the first object detection model simultaneously possesses dynamic category generalization capability, spatial localization capability, and cross-modal semantic alignment capability.
[0124] As described above, the process involves acquiring a first image sample and a target location. The first image sample includes at least one target object to be identified, and the target location indicates a preset position of the target object within the first image sample. The target object in the first image sample is extracted using the current image encoder to obtain object image sample features describing the target object. Multiple reference category text sample features are then acquired. Each reference category text sample feature describes a reference category to which an object belongs, and these multiple reference category text sample features include those corresponding to the target category, i.e., the reference category text sample features corresponding to the reference category to which the target object belongs. The reference category text sample features are extracted using the current text encoder from the reference category text samples describing the reference category. Since these multiple reference category text samples are extracted separately, it is equivalent to inputting multiple reference category text samples into the current text encoder in parallel, eliminating redundant calculations and reducing computational load. Furthermore, this method can dynamically expand the reference categories by adding reference category text samples to adapt to unknown categories, achieving open-world object detection. The object image sample features are then identified using the current recognizer to determine the predicted position of the target object in the first image sample and the predicted category text features of the target object. Finally, the current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted location and the target location satisfy the first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy the second matching condition. This allows the first object detection model trained based on the current object detection model to not only identify the location of the object in the image but also to identify the category to which the object belongs. During the training process of the object detection model, alignment is performed directly at the feature level, i.e., the blending operation is removed. This not only forces the first object detection model to learn cross-modal semantic consistency through the alignment process but also reduces the computational cost required to train the first object detection model. This shortens the training time of the object detection model and facilitates its engineering deployment.
[0125] Furthermore, this implementation trains both the current text encoder and the current image encoder together during training, without freezing them. It trains only the current classifier, thus avoiding a reduction in similarity scores and facilitating engineering applications. For example, traditional object detection algorithms typically use score_thr = 0.05 and max_per_img = 100 when calculating mAP on the COCO or LVIS datasets. However, because these algorithms tend to have low scores, some methods reduce score_thr to 0.0001. On the LVIS dataset, the more bounding boxes, the higher the mAP. Therefore, although the mAP of these algorithms seems good, they are not practically user-friendly.
[0126] As one possible implementation, positive and negative sample pairs can be obtained to train the current object detection model by introducing contrastive learning. In this embodiment, the target location is identified by a reference bounding box, which is used to identify the target location of the target object in the first image sample; that is, the target location of the target object in the first image sample is identified by the reference bounding box.
[0127] Positive sample pairs include an image region and a corresponding reference category text sample. The image region is the portion of the image identified by the reference bounding box in the first image sample, i.e., the image area occupied by the target object in the first image sample. The corresponding reference category text sample is the reference category text sample corresponding to the target category to which the target object belongs within that image region; hereinafter referred to as the target category corresponding reference category text sample. Negative sample pairs include the image region and other reference category text samples. These other reference category text samples are the reference category text samples other than the target category corresponding reference category text sample among the multiple reference category text samples for the first image sample. See also... Figure 5 The image region identified by reference bounding box 1 and the dog constitute a positive sample, while the image region identified by reference bounding box 1 and the human constitute a negative sample. The reference bounding box is used to identify the target location in the first image sample.
[0128] The embodiments of this application do not specifically limit the timing of acquiring positive and negative samples. For example, positive sample pairs can be acquired simultaneously with the acquisition of the first image sample, and then negative sample pairs can be constructed based on the positive sample pairs. Alternatively, positive and negative sample pairs can be constructed based on the first image sample after it has been acquired. Yet another example is that positive and negative sample pairs can be acquired simultaneously with the acquisition of the first image sample.
[0129] After obtaining positive and negative sample pairs, the second matching condition can be refined to ensure that the similarity between the reference category text sample features and the object image sample features from the same positive sample pair is greater than a first threshold, and the similarity between the reference category text sample features and the object image sample features from the same negative sample pair is less than a second threshold, wherein the second threshold is less than the first threshold. Those skilled in the art can set this threshold according to actual needs. For example, the second matching condition can be refined to maximize the similarity between the reference category text sample features and the object image sample features from the same positive sample pair, and minimize the similarity between the reference category text sample features and the object image sample features from the same negative sample pair, etc.
[0130] In this context, a positive sample pair includes an image region identified by a reference bounding box in the first image sample and a reference category text sample corresponding to the target category to which the target object within the image region belongs. A positive sample pair can include an image region and a reference category text sample corresponding to the target category. The reference category text sample features describing the reference category text sample corresponding to the target category and the object image sample features describing the image region both come from the same positive sample pair. Similarly, a negative sample pair includes the image region and other reference category text samples. The object image sample features describing the image region and the reference category text sample features describing other reference category text samples both come from the same negative sample pair.
[0131] Therefore, in this embodiment, the predicted location can be represented by the aforementioned predicted recognition box. Thus, during the training of the current object detection model, the model parameters of the current text encoder, the current image encoder, and / or the current recognizer can be adjusted so that the predicted recognition box and the reference recognition box satisfy the first matching condition, and / or the similarity between the reference category text sample features and the object image sample features from the same positive sample pair is greater than the first threshold, and the similarity between the reference category text sample features and the object image sample features from the same negative sample pair is less than the second threshold.
[0132] In other words, based on ensuring that the predicted and reference bounding boxes satisfy the first matching condition, the second matching condition enables the model to learn the characteristics of positive sample pairs and distinguish negative sample pairs. For example, the model is required to push away negative samples and bring closer positive samples in the shared semantic space, thereby reducing intermodal ambiguity. Thus, by constraining negative samples, the model is forced to distinguish fine-grained semantic differences, such as the difference between a cat and a tiger, thereby reducing intermodal semantic ambiguity, lowering the risk of overfitting, and making it more suitable for open-world object detection.
[0133] As one possible approach, to improve model accuracy, the accuracy of the training data can be enhanced. Based on this, this application embodiment obtains a detection data set aligned dataset, and the two datasets are described below.
[0134] Detection datasets are used for object detection tasks, the core of which is to label the category and location of objects in an image (usually represented as bounding boxes, such as reference bounding boxes). These datasets help models learn to recognize objects in images and locate their positions. For example, the COCO (Common Objects in Context) dataset includes over 330,000 images labeled with 80 common object categories (such as people, vehicles, animals, etc.).
[0135] Grounding datasets are used for vision-language alignment tasks (such as visual question answering and image caption generation), the core of which is to associate text descriptions with specific regions or objects in an image. These datasets help models learn the semantic correspondence between text and images. The RefCOCO series datasets (RefCOCO, RefCOCO+, RefCOCOg, etc.) build upon the COCO dataset by annotating the images with the regions in the image corresponding to the objects described in the text.
[0136] Based on this, first image samples can be obtained from the detection dataset and the alignment dataset. For example, in a training session, a batch of first image samples can be obtained, with half of the first image samples coming from the detection dataset and half from the alignment dataset.
[0137] Furthermore, after obtaining the first image samples based on the detection dataset and the alignment dataset, positive sample pairs and negative sample pairs can be constructed based on the detection dataset and the alignment dataset. The process of constructing positive sample pairs will be explained below.
[0138] (1) Obtain a first image sample from the detection dataset. This first image sample is labeled with the target category and target location of the target object, thereby obtaining the image region constituting the positive sample pair and the reference category text sample corresponding to the target category included in the image region. Thus, the reference category text sample corresponding to the target category in the positive sample pair obtained based on the detection dataset is used to describe the category of the target object in the first image sample.
[0139] (2) Obtain the first image sample from the alignment dataset and associate the text description with the image region containing the target object in the first image sample. That is, the text description is used to describe the attributes of the target object in the image region. Compared with the category, the text description has a higher richness, such as a green airplane or a lively puppy. Thus, the image region constituting the positive sample pair and the reference category text sample corresponding to the target category included in the image region can be obtained. The reference category text sample corresponding to the target category is used to describe the features of the target object in the first image sample. Compared with the reference category text sample corresponding to the target category obtained based on the detection dataset, the richness of the description of the target object is higher.
[0140] As one possible implementation, negative sample pairs can be constructed in different ways for different datasets. For example, if the positive sample pairs come from the detection dataset, constructing multiple reference category text samples for training based on the detection dataset is equivalent to constructing negative sample pairs based on the detection dataset, such as sampling other category texts from the multiple categories included in the detection dataset. If the positive sample pairs come from the alignment dataset, constructing multiple reference category text samples for training based on the alignment dataset is equivalent to constructing negative sample pairs based on the alignment dataset, such as sampling other category texts from the multiple categories included in the alignment dataset.
[0141] Therefore, in positive sample pairs constructed based on the detection dataset, the reference category text samples corresponding to the target category only describe the category. In contrast, in positive sample pairs constructed based on the alignment dataset, the reference category text samples corresponding to the target category describe other object-related features in addition to the category description. Thus, the first object detection model trained on positive sample pairs can not only learn to identify objects in images and locate their positions, but also learn the semantic correspondence between text and images, thereby improving the accuracy of the first object detection model. Moreover, for the detection dataset, negative sample pairs are obtained from multiple categories of text included in the detection dataset, and for the alignment dataset, negative sample pairs are obtained from multiple categories of text included in the alignment dataset, and can even be obtained from offline vocabularies, making the training more targeted. After learning coarse-grained localization based on the detection dataset, the first object detection model can also learn fine-grained semantic alignment based on the alignment dataset. The combination of the two can construct a complete inference chain from vision to semantics. In addition, combined training can reduce intermediate steps (such as the cascaded process of first detecting the dataset and then aligning the dataset), reducing computational overhead and error accumulation.
[0142] This application does not specifically limit the method of constructing negative sample pairs. The following describes two methods as examples.
[0143] Method 1: Construct negative sample pairs based on the aligned dataset.
[0144] Specifically, n categories of text are obtained from a vocabulary containing m categories of text. Other reference category text samples are determined from the n categories of text and the reference category text samples corresponding to the target object included in the first image sample. Negative sample pairs are obtained based on the other reference category text samples and the image region.
[0145] Where m is a positive integer, and n is a positive integer less than or equal to m. The vocabulary is pre-constructed and includes multiple category texts, each describing a category. As one possible implementation, the vocabulary can be constructed based on alignment data, which is not specifically limited in this application. Other reference category text samples are the reference category text samples other than the reference category text sample corresponding to the target category among the multiple reference category text samples. It should be noted that if the first image sample includes a target object and corresponds to a reference category text sample, then other reference category text samples can be determined from the n category texts.
[0146] Therefore, when constructing negative sample pairs based on the aligned dataset, partial category text can be sampled from a pre-constructed vocabulary. Based on the partial category text and the category text included in the first image sample, other reference category text samples included in the negative sample pair can be determined. This is equivalent to adding negative samples within each batch based on offline dictionaries or other vocabulary, thereby compensating for the performance loss caused by simplifying the model and improving the performance of the first object detection model.
[0147] Method 2: Construct negative sample pairs based on the detection dataset.
[0148] Specifically, k reference category text samples are obtained from multiple reference category text samples included in the detection dataset. Other reference category text samples are determined from the k reference category text samples and the reference category text samples corresponding to the target object included in the first image sample. Negative sample pairs are obtained based on the other reference category text samples and the image region.
[0149] Where k is a positive integer. Other reference category text samples are the reference category text samples other than the reference category text sample corresponding to the target category among multiple reference category text samples. It should be noted that if the first image sample includes a target object and corresponds to a reference category text sample, then other reference category text samples can be determined from the k reference category text samples.
[0150] Therefore, when constructing negative sample pairs based on the detection dataset, some reference category text samples can be sampled from the multiple categories of text included in the detection dataset. Based on these reference category text samples and the reference category text samples corresponding to the target objects included in the first image sample, other reference category text samples included in the negative sample pairs can be determined. This is equivalent to selecting some categories from the existing categories to train the model, enabling the model to classify known categories better and improving the model's accuracy.
[0151] As one possible implementation, if the first image sample used to train the model includes multiple sub-image samples, and the number of reference category text samples included in these sub-image samples is different, then multiple category texts can be sampled from a preset category text, so that the number of reference category text samples corresponding to each of the multiple sub-image samples is the same, thereby ensuring the learning accuracy of the model. The following explanation uses the example of the first image sample including a first sub-image sample and a second sub-image sample.
[0152] Specifically, for the first sub-image sample, p category texts are sampled from the preset category texts. These p category texts, along with the reference category text samples corresponding to the target objects included in the first sub-image sample, are determined as multiple reference category text samples for the first sub-image sample, where p is a positive integer. For the second sub-image sample, q category texts are sampled from the preset category texts. These q category texts, along with the reference category text samples corresponding to the target objects included in the second sub-image sample, are determined as multiple reference category text samples for the second sub-image sample, where q is a positive integer. The number of multiple reference category text samples for the first sub-image sample is equal to the number of multiple reference category text samples for the second sub-image sample.
[0153] Therefore, by increasing the number of reference category text samples corresponding to each sub-image sample through sampling, such as supplementing the number of categories to 150, not only can different category texts be added to different sub-image samples to improve the model's learning ability, but the number of multiple reference category text samples among multiple sub-image samples can also be kept the same, thus ensuring the model's learning efficiency.
[0154] As one possible implementation, the application process of the trained first object detection model is described below. In this embodiment, the first object detection model includes a first image encoder and a recognizer, as detailed in A1-A3.
[0155] A1: Get the application image.
[0156] An application image is an image that is waiting to be recognized during the application process. It can be a video frame from a video or a screenshot obtained from a webpage, etc. This application makes specific limitations on this.
[0157] A2: Extract object image features from the objects included in the application image using the first image encoder.
[0158] The first image encoder is trained based on the current image encoders mentioned above in S401-S405. The first image encoder is used to extract features from the image. It can extract object image features of the objects to be identified in the application image from the application image through the first image encoder. The object image features are used to describe the characteristics of the objects.
[0159] A3: By using a recognizer to identify the features of an object image, the location of the object in the applied image and the category to which the object belongs can be obtained.
[0160] The recognizer is trained based on the aforementioned current recognizer. During the training process, the current recognizer determines the predicted position, predicted category text features, and predicted category of the target object in the first image sample based on the object image sample features. The recognizer then identifies the object image features to obtain the object's position in the application image and the category to which the object, marked by the recognition box, belongs. This position can be indicated by a recognition box or other means; this application does not specifically limit this. The recognition box is used to identify the object's position in the application image. Furthermore, the category text features corresponding to the object's category can be output to the user by the recognizer or not; this application does not specifically limit this either.
[0161] See Figure 6 This figure is a schematic diagram illustrating the application process of a first object detection model provided in an embodiment of this application. Figure 6 In the process, the application image is input into the first image encoder, which obtains the object image features of the objects in the application image. The object image features are then input into the recognizer, which obtains the recognition boxes and categories corresponding to the two objects.
[0162] It should be noted that, in addition to identifying the location and category of objects within an application image using bounding boxes, it can also indicate the probability that an object belongs to that category, allowing users to decide whether to accept the classification result. See also Figure 7 This figure is a schematic diagram illustrating a classification result obtained based on an application image, provided in an embodiment of this application. Figure 7 The diagram shows the categories and probabilities of two objects that can be identified, such as the probability that an object is a man being 0.52.
[0163] Therefore, the first object detection model obtained through training can not only identify the location of objects in an image, but also identify the category of objects. It is suitable for various scenarios of object detection in images, such as the detection of goods in web pages, the detection of people, vehicles and other objects in videos, etc. It is convenient, fast and highly accurate.
[0164] As one possible implementation, if, during the training process, the current recognizer is trained to recognize objects based on multiple reference category text sample features—that is, by using the current recognizer to determine the predicted position of the target object in the first image sample and the predicted category of the target object based on the object image sample features and multiple reference category text sample features—then in this embodiment, the first object detection model may include a first text encoder, a first image encoder, and a recognizer. During application, multiple second text features can also be acquired. The recognizer then identifies the object image features and the multiple second text features to obtain the object's position in the application image (e.g., a bounding box) and the object's category. Thus, the multiple second text features enable the current recognizer to enhance its understanding of the object and improve its recognition capability. These multiple second text features are obtained by extracting multiple texts describing the category from the first text encoder.
[0165] Furthermore, multiple second text features can be extracted in advance; that is, all second text features can be pre-calculated, thus directly obtaining multiple second text features. The recognizer then identifies the object's location in the applied image and its category by combining the object's image features with these multiple second text features. Therefore, by pre-extracting multiple second text features, the operation of the first object detection model is greatly accelerated, improving object recognition speed and enhancing the user experience.
[0166] To facilitate a further understanding of the technical solutions provided in the embodiments of this application, the following description takes the execution subject of the object detection model training method provided in the embodiments of this application as a server as an example, and provides an overall exemplary introduction to the object detection model training method.
[0167] The training process of the first object detection model will be explained below.
[0168] The current object detection model is based on GLIPv1 / v2 or GroundDINO (an open set object detection model) and has three improvements:
[0169] (1) The serial input method for sample texts describing multiple categories is changed to a parallel input method. That is, the input format of n categories in a sentence is changed to input n sentences at the same time, with each category as a separate sentence. Thus, during the training process, not only can the text features be greatly utilized and normal negative samples be easily introduced, but also a large number of categories can be inferred at once.
[0170] (2) Introduce an offline vocabulary. For example, generate a large offline vocabulary based on a caption dataset, such as approximately 13,000 words using Coyo. It should be noted that in actual training, the training dataset is divided into two parts: the detection dataset and the grounding dataset. For each image sample, the number of multiple reference category text samples is supplemented to 150. However, for the detection dataset, negative samples need to be taken from within the original detection dataset, while for the grounding dataset, they are sampled from the collected offline vocabulary.
[0171] (3) Eliminate the fusion operation and remove the fusion operation and neck network operation, and perform alignment directly at the feature level. In this way, all text features can be pre-calculated during the deployment phase, which greatly accelerates the operation of the entire model. Using an offline dictionary to increase negative samples in each batch can compensate for the performance loss caused by simplifying the model.
[0172] Therefore, the training process is as follows: First image samples are acquired, including at least one target object. Each target object is marked with a reference bounding box to indicate its location within the image sample. Multiple reference category text sample features are acquired, extracted by the current text encoder from the multiple reference category text samples. Each reference category text sample describes one of the multiple reference categories, including the target category corresponding to the target object. Object image sample features of the target object are extracted from the first image sample using the current image encoder. The predicted bounding box of the target object in the first image sample and the predicted category text features of the target object are determined by the current recognizer based on the object image sample features. The current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted bounding box and the reference bounding box satisfy a first matching condition, and the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition. The relevant training process can be found in the aforementioned S401-S405, and will not be repeated here.
[0173] To verify the effectiveness of the improved first object detection model, the results of the algorithm were compared in detail, as shown in Table 1.
[0174] Table 1
[0175]
[0176] Mean Pixel Accuracy (mAP) is a commonly used evaluation metric in semantic segmentation tasks, measuring the accuracy of pixel classification predicted by the model. In object detection, if the detection results are transformed into semantic segmentation (e.g., pixel-level annotation of detected target regions), MPA can also be used to evaluate the region classification accuracy of the object detection results. Average Precision with Recall (Apr) is a metric used in object detection to evaluate the average precision of a model under different recall rates. It comprehensively considers both precision and recall, providing a more complete reflection of model performance.
[0177] In Table 1, GLIP, GLIPv2, and GroundDINO are open-source solutions, while DetCLIP is a closed-source solution. It can be seen that the embodiments of this application achieve good results on datasets of similar size.
[0178] To further verify the algorithm, this application's embodiments were compared with other algorithms. The most basic algorithm is based on the ATSS framework, while this application's embodiments further implemented the algorithm on DETR (based on a full transformers architecture) due to its inherent advantages in text-image alignment. Specifically, this application's embodiments adopted the DeformableDETR algorithm, and detailed comparison results are shown in Table 2.
[0179] Table 2
[0180]
[0181] The Average Precision (AP) for Common Classes (APc) is a metric for the average precision (AP) of common class objects in the dataset. In object detection tasks, datasets are often divided into rare, common, and frequent classes based on the frequency of occurrence of objects. APC is specifically used to evaluate the model's detection performance for common classes. The Average Precision (APf) for Frequent Classes (APf) is a metric for the average precision (AP) of frequently occurring class objects in the dataset, used to evaluate the model's detection performance for high-frequency classes. The Generalized Mean Average Precision (GMPA) is a metric for the average precision (AP) of frequently occurring class objects in the dataset, used to evaluate the model's detection performance for high-frequency classes.
[0182] As shown in Table 2, using the same training dataset, the embodiments of this application achieved a significant improvement of 10 percentage points on the COCO dataset and more than doubled the performance on the G1.8 test set. Furthermore, the G1.8k, 2.3k, and 3.2k datasets are general category data obtained through continuous iteration and cleaning; the increase in data volume is accompanied by an increase in difficulty. Despite this, the algorithm of the embodiments of this application still exhibits good performance. It should be noted that although the performance on the COCO dataset decreased, this is mainly due to the addition of more data from other categories, which made some basic categories sparse. The goal of the embodiments of this application is not merely to improve the score on the COCO dataset, but to improve the overall performance and applicability of the algorithm by specifically adding data.
[0183] It should be noted that methods for iterating and cleaning the dataset can be found in the following sections. Figure 9 The embodiments shown will not be described in detail here.
[0184] As one possible implementation, to improve the performance of the first object detection model, this application provides a method to improve the quality of training data, namely, generating higher-quality training data through a data engine. This is described in detail below, see B1-B5 for specific details.
[0185] B1: Obtain initial image samples.
[0186] Compared to the first image sample, the initial image sample is an image without a reference recognition box. In this embodiment, the first image sample is obtained by adding a reference recognition box to the target object included in the initial image sample.
[0187] B2: Based on the initial image sample, obtain a sample of explanatory text to describe the initial image sample.
[0188] The explanatory text sample is the text used to describe the initial image sample.
[0189] See Figure 8 This figure is a schematic diagram of an initial image sample provided in an embodiment of this application. Figure 8 The image shown is the initial image sample, and the descriptive text sample for this initial image sample can be "a man crouching down to pet a dog".
[0190] This application does not specifically limit the method of generating explanatory text samples. For example, explanatory text samples of the initial image samples can be generated using a caption model such as a bootstrapping language-image pretraining (BLIP). Alternatively, explanatory text samples of the initial image samples can be generated using a vision-language model (VLM).
[0191] B3: Extract keywords from the explanatory text sample of the initial image sample.
[0192] Keywords are the key words in the text sample. Continuing with the example of "a man who squats down to pet a dog", the keywords obtained could be "man", etc.
[0193] This application does not specifically limit the method of extracting keywords. For example, the Named Entity Recognition (NER) model can be used to segment words to obtain corresponding noun phrases, and the noun phrases can be identified as keywords.
[0194] B4: Detect multiple initial reference category text samples and initial image samples to obtain reference recognition boxes in the initial image samples and reference category text samples corresponding to the target category.
[0195] The first initial reference category text sample is text used to describe a category. Multiple first initial reference category text samples are used to describe multiple categories, and different first initial reference category text samples are used to describe different categories. The multiple first initial reference category text samples are derived from the keywords and preset category texts extracted above. The preset category text is a pre-set text description corresponding to a category, which can be a television, a water cup, a flower, a potted plant, etc., and this application does not make any specific limitations on it.
[0196] This application does not specifically limit the detection method, such as using a pre-trained object detection model. The object detection model detects text and images to obtain the location of objects in the image (which can be identified by reference bounding boxes) and the category to which the objects belong. This application does not specifically limit the object detection model, such as Open-Vocabulary Object Detection via Vision and Language Knowledge Distillation (ViLD), a first object detection model, a second object detection model, etc. The second object detection model will be used as an example in the following explanation; see C1-C6 for details, and will not be elaborated upon here.
[0197] As one possible implementation, before detecting the first initial reference category text sample and the initial image sample, one or more operations such as matching filtering, identifying the initial bounding box, and adding a specific category can be performed on the initial image sample, which will be explained in detail below.
[0198] (1) Matching Filtering. Image samples may come from existing image-text sets. However, in existing image-text sets, the accuracy of the text in a sample pair in describing the image is likely low. Therefore, matching filtering can be used to select and retain sample pairs from multiple image-text pairs included in the image-text set, where the text in one sample pair has a high accuracy in describing the image, while deleting sample pairs where the text in the text pair has a low accuracy in describing the image. Subsequently, the text with high accuracy and the first initial reference category text sample can be used as descriptions of the initial image sample for detection, thereby improving the detection accuracy.
[0199] This application does not specifically limit the matching filtering method. The CLIP model can be used to calculate the similarity between text and images belonging to the same sample pair. Sample pairs with a similarity less than or equal to the similarity threshold are deleted, while sample pairs with a similarity greater than the similarity threshold are retained.
[0200] As one possible implementation, English CLIPs, such as openai-clip, can be used, as can Chinese CLIPs, such as ChineseCLIP. Among these, Chinese CLIPs can also detect Chinese characters, making them more suitable for scenarios involving Chinese.
[0201] (2) Identify the initial bounding box. The initial image sample is an image sample without a bounding box. The target object included in the initial image sample can be identified by methods such as Objectness (i.e., the probability that a certain region in the image contains an object). This adds the initial bounding box corresponding to the target object to the initial image sample so that the first object detection model or the second object detection model can detect it, thereby improving the accuracy of the detection.
[0202] (3) Add specific categories. Specific categories refer to the categories required for subsequent detection, such as categories in professional fields. Models such as the expectation model can be used to identify objects with specific categories (such as professional terms in the medical field) in the initial image samples, so as to increase the accuracy of subsequent detection by the first object detection model.
[0203] B5: The initial image sample with the reference recognition box is determined as the first image sample.
[0204] The reference recognition box obtained by detecting the initial image sample can accurately outline the position of the target object in the image, thus obtaining a more accurate first image sample.
[0205] See Figure 9 This figure is a schematic diagram of obtaining a first image sample according to an embodiment of this application. An image can be obtained from an image-text set and used as an initial image sample. A descriptive text sample is generated based on the initial image sample. Sample pairs with low accuracy in describing the image are removed from the image-text set through a matching filtering operation; target objects in the initial image sample are identified to obtain an initial image sample with an initial bounding box, which is used to identify the target object in the initial image sample; target objects of a specific category are identified in the initial image sample.
[0206] By inputting initial image samples with specific categories and initial bounding boxes into a second object detection model, along with keywords and preset category text extracted from descriptive text samples, the second object detection model detects objects in the initial image samples, resulting in a first image sample with reference bounding boxes. This is equivalent to correcting the initial bounding boxes using the second object detection model, thereby obtaining reference bounding boxes and improving the accuracy of the first image sample.
[0207] As one possible implementation, the first image sample obtained can be deleted if the image and text are inconsistent, such as the first image sample whose reference recognition box does not match the reference category text sample corresponding to the target category, or the text describing the first image sample inaccurately.
[0208] Therefore, by using a data engine, descriptive text samples are generated for the images in the image-text pair. Keywords are extracted from the descriptive text samples. Based on the keywords, preset category text, and the image, detection is performed to obtain the reference recognition box corresponding to the target object in the image, as well as the reference category text sample corresponding to the target category. This realizes the generation of reference recognition boxes for the target objects included in the images in the image-text pair, resulting in a first image sample with reference recognition boxes. This leads to the first image sample and the target location, improving the accuracy of the data used for training, and thus improving the accuracy of the first object detection model.
[0209] This application does not specifically limit the detection method. As one possible implementation, detection can be achieved through a second object detection model. Specifically, the second object detection model can be used to detect multiple first initial reference category text samples and initial image samples to obtain reference recognition boxes in the initial image samples, and reference category text samples corresponding to the target category to which the target object in the reference recognition box belongs, i.e., reference category text samples corresponding to the target category.
[0210] The second object detection model is used to detect the location and category of objects in an image. The second object detection model is trained using learnable parameters.
[0211] The learnable parameter can increase the richness of the description of the target object corresponding to the reference recognition box. Therefore, compared with the training data, the richness of the description of the target object can be improved based on the learnable parameter, thereby improving the recognition of the target object by the second object detection model and improving the accuracy of the second object detection model.
[0212] Learnable parameters can be constructed offline. They are obtained through training on a large amount of data and are equivalent to average concepts. They can substitute for various attributes of a category, such as representing red or blue.
[0213] Compared to categories, categories with learnable parameters offer richer descriptions; for example, "red airplane" is a richer description than "airplane." For subsequent second-object detection models, richer input sequences achieve higher scores; for instance, "a red stop sign" scores higher than "traffic sign." Taking the CLIP model as an example, the image-text pairs used in CLIP training typically contain long text descriptions, a significant difference compared to categories with only a single noun. The clearer the description, the higher the image-text matching accuracy of the CLIP model.
[0214] Therefore, by introducing learnable parameters, the text in the input sequence becomes richer in its description of the target object, effectively adding contextual information. This leads to higher scores in matching text and image features, reducing the discrepancy between training and testing, and improving the recognition ability of the second object detection model. Consequently, it achieves better performance on classification tasks, resulting in a 3 percentage point improvement. Furthermore, for specific categories of tasks, performance is significantly improved, eliminating the need for manually designing prompts and increasing convenience.
[0215] As one possible implementation, the training process of the second object detection model is described below, see C1-C6 for details.
[0216] Before explaining the training process of the second object detection model, let's first describe the basic components of the object detection algorithm: the backbone network, the neck network, and the head network. The head network can include a classification head (cls head) and a regression head (reg head). The backbone network extracts features from the input image, the neck network further processes the features extracted by the backbone network, the head network predicts the object's category and location, the classification head predicts the object's category probability, and the regression head predicts the object's bounding box coordinates.
[0217] Taking closed-set detection algorithms as an example, if trained on the COCO dataset, which contains 80 categories, the classifier head is essentially an 80×D matrix. If we expand it from 80 categories to N categories, it becomes an N×D matrix, where D represents the feature dimension, and N and D are positive integers.
[0218] Having grasped this basic concept, closed-set detection algorithms can be transformed into open-set detection algorithms. This process is essentially equivalent to replacing the classification head, that is, replacing an 80×D matrix with an N×D matrix. Therefore, open-set detection algorithms mainly focus on how to obtain a classification head and how to align image features with the features of the classification head.
[0219] In related technologies, in order to achieve the goal of the open set detection algorithm, it is generally trained together with the text used to describe the category and the image corresponding to the category. The text is then converted into a category description such as "a photo of [CLASS]" for subsequent training. However, the text format used in the actual training process is usually different from the prompts during testing (such as descriptions of images, rather than just categories), which leads to a significant difference between training and testing, resulting in poor accuracy of the trained model.
[0220] Based on this, embodiments of this application define a set of learnable parameters and [CLASS] to form labels to generate the final input sequence, which is then used for training along with the images. This will be explained in detail below.
[0221] C1: The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences.
[0222] As one possible implementation, multiple second initial reference category text samples and initial image samples can be obtained before C1. The second initial reference category text samples are text used to describe the reference category to which the object belongs; multiple second initial reference category text samples are used to describe multiple reference categories, and different second initial reference category text samples are used to describe different reference categories. Learnable parameters are used to increase the richness of the description of the target object to be recognized (such as an object outlined by a real recognition bounding box) by the second initial reference category text samples.
[0223] The learnable parameters and the second initial category text are concatenated to obtain a first input sequence. Then, the learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences. These first input sequences are the content input into the model and are obtained by concatenating the learnable parameters and the second initial reference category text samples. Compared to the second initial reference category text samples, the first input sequences obtained by concatenating the learnable parameters and the second initial reference category text provide a richer description of the target object. Therefore, compared to training the second object detection model based solely on the second initial reference category text samples, the second object detection model trained based on the first input sequences has a stronger object recognition ability and thus higher accuracy.
[0224] C2: Multiple second text sample features are extracted from multiple first input sequences using a second text encoder.
[0225] The second text encoder is a type of text encoder used to extract features from text. The second text encoder may be the same as or different from the first text encoder, and this application does not make any specific limitation in this regard.
[0226] The first input sequence is fed into the second text encoder, which extracts features to obtain second text sample features for each of the first input sequences. These second text sample features are used to describe the first input sequence.
[0227] C3: Extract a local image including the target object from the initial image sample.
[0228] Since the initial image sample may contain one or more target objects, or a cluttered background, in order to improve the accuracy of recognition, a local image can be extracted from the initial image sample. This local image contains only the target object, and thus contains less other information than the initial image sample, so as to improve the accuracy of subsequent target object recognition.
[0229] C4: Extract the second image sample features from the local image using the second image encoder.
[0230] The second image encoder is an image encoder used to extract features from an image. The second image encoder may be the same as or different from the first image encoder; those skilled in the art can configure it according to actual needs.
[0231] The second image encoder can extract second image sample features from the local image. The second image sample features are used to describe the local image. The local image only includes the target object, so the second image sample features can describe the target object included in the local image.
[0232] C5: Extract local sample features of the target object from the initial image samples using the current classifier, as well as the classification sample features of the target object.
[0233] The current classifier is an untrained classifier used to extract local sample features describing the target object and classification sample features of the target object's category from the image. This application does not specifically limit the current classifier; it can be a detection model such as Region of Interest Align (RoIAlign).
[0234] For example, an initial image sample is input into the current classifier, and the current classifier performs detection, obtaining local sample features of the target object in the initial image sample, as well as classification sample features of the target object. The local sample features describe the characteristics of the region where the target object is located in the initial image, while the classification sample features describe the characteristics of the category to which the target object belongs.
[0235] It should be noted that the current classifier can output not only local sample features and classification sample features, but also bounding boxes that identify the location of target objects. For example, when the current classifier identifies a target object in an initial image sample, it uses bounding boxes to mark the location of the target object in the initial image sample, then extracts features from the image region within the bounding boxes to obtain local sample features, and determines the classification sample features corresponding to the target object's category based on these local sample features.
[0236] C6: Adjust the model parameters of the current classifier so that the local sample features and the second image sample features satisfy the third matching condition, and / or, the classification sample features and the second text sample features of the target object satisfy the fourth matching condition, to obtain the second object detection model.
[0237] The local sample features and the second image sample features satisfy the third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy the fourth matching condition, are used as training targets. The model parameters of the current classifier are adjusted to obtain the trained classifier, and then the second object detection model including the classifier and the second text encoder is obtained.
[0238] The embodiments of this application do not specifically limit the conditions for the completion of model training. It can be that the number of iterations in the model training process meets a preset number, the current classifier obtained by training enables the local sample features and the second image sample features to meet the third matching condition, and / or the classification sample features and the second text sample features of the target object to meet the fourth matching condition, etc., that is, the third matching condition and the fourth matching condition are used as training targets, etc. This application does not make specific limitations in this regard.
[0239] The local sample features and the second image sample features satisfy a third matching condition, which can be defined as the difference between the local sample features and the second image sample features being less than a third difference threshold. This embodiment does not specifically limit the third difference threshold; for example, it could be the minimization of the difference between the local sample features and the second image sample features. Using the third matching condition as the training objective, the current classifier is trained to better understand the global contextual information of the image, enabling the head network included in the current classifier to learn richer contextual information. By ensuring that the local sample features and the second image sample features satisfy the third matching condition, the current classifier can be trained to mimic the output of the second text encoder, thereby achieving a more comprehensive image understanding capability.
[0240] The classification sample features and the second text sample features of the target object satisfy the fourth matching condition, which can be that the difference between the classification sample features and the second text sample features of the target object is less than the fourth difference threshold. This application embodiment does not specifically limit the fourth difference threshold; for example, it could be minimizing the difference between the classification sample features and the second text sample features of the target object. The fourth matching condition is used as the training objective to train the current classifier, enabling the trained classifier to distinguish different categories, including categories known during training and new categories. The training objective is to increase the similarity between the classification sample features and the second text sample features of the target object, allowing the current classifier to extract visual features that are better aligned with the second text sample features of the target object. This means mapping visual features to a space similar to text features, thereby achieving text-based classification.
[0241] The second text sample feature of the target object is the second text sample feature corresponding to the target object included in the cropped local image, which is one of multiple second text sample features. The second object detection model includes a classifier trained based on the current classifier and a second text encoder.
[0242] Therefore, by introducing learnable parameters, the text in the input sequence becomes richer in its description of the target object, effectively adding contextual information. This leads to higher scores in matching text and image features, reducing the discrepancy between training and testing, and improving the recognition ability of the second object detection model. Consequently, it achieves better performance on classification tasks, resulting in a 3 percentage point improvement. Furthermore, for specific categories, performance is significantly improved, eliminating the need for manually designing prompts and increasing convenience. Moreover, the method of concatenating the learnable parameters with the second initial reference category text samples used for training to obtain the first input sequence is convenient and fast.
[0243] As one possible implementation, after training the second object detection model, the application process of the second object detection model will be explained below. The example will be taken as detecting multiple first initial reference category text samples and initial image samples through the second object detection model to obtain the reference recognition box in the initial image sample and the reference category text sample corresponding to the target category. See D1-D4 for details.
[0244] D1: Multiple first text features are extracted from multiple first initial reference category text samples by a second text encoder.
[0245] Multiple first initial reference category text samples are input into the second text encoder, and the second text encoder extracts the first text features corresponding to each first initial reference category text sample.
[0246] D2: The initial image samples are detected by a classifier to obtain the reference recognition box and the visual features of the image region identified by the reference recognition box in the initial image samples.
[0247] The initial image sample is input into the classifier, which performs recognition to obtain the reference recognition box corresponding to the target object in the initial image sample, as well as the features corresponding to the image region marked by the reference recognition box, i.e., visual features.
[0248] As mentioned above, the classifier can align text features and image features, so visual features and the first text features are in the same feature space.
[0249] D3: Calculate the similarity between visual features and multiple first text features respectively.
[0250] Similarity is used to describe the degree of similarity between visual features and primary text features. It can be calculated using methods such as cosine similarity and Euclidean distance. This application does not impose any specific limitations on this.
[0251] D4: Based on multiple similarities, determine the reference category text sample corresponding to the target category.
[0252] The similarity between the visual feature and each first text feature is calculated separately to obtain the similarity between the visual feature and each first text feature. Each first text feature is used to describe a reference category. Thus, multiple similarities can describe the degree of similarity between the visual feature and each reference category. In this way, the first initial reference category text sample corresponding to the first text feature with high similarity can be determined as the reference category text sample corresponding to the reference category to which the object identified by the reference recognition box belongs, that is, the reference category text sample corresponding to the target category.
[0253] Therefore, after training the second object detection model, the first text features of the first initial reference category text samples used to identify each category can be extracted based on the second text encoder included in the second object detection model. Then, detection is performed by the classifier included in the second object detection model to obtain the reference recognition box and visual features of each target object in the initial image sample. Thus, the reference category text sample to which each target object belongs is determined based on the similarity between the visual features and the first text features. Therefore, the detection and classification of objects in the image is achieved based on the second object detection model with high accuracy.
[0254] As one possible implementation, labeling and model training can be combined, i.e., labeling is done once the model is trained, thereby improving the accuracy of the model and the data by iteratively labeling and training the model. The following explanation will continue using the second object detection model as an example.
[0255] For the i-th detection, where i is a positive integer, first obtain the current classifier obtained from the i-th training. Then, use the second text encoder, the second image encoder, and the current classifier obtained from the i-th training (i.e., the second object detection model obtained from the i-th training) to detect the initial reference category text samples and the initial image samples of the i-th round, to obtain the current reference recognition box in the initial image samples of the (i+1)-th round, and the reference category text sample corresponding to the current target category.
[0256] For the (i+1)th training iteration, first obtain the reference bounding boxes in the initial image samples of the (i+1)th iteration, as well as the reference category text samples corresponding to the target category. Use the initial image samples of the (i+1)th iteration as the second initial reference category text samples, and perform the aforementioned training process C1-C6 to obtain the current classifier obtained from the (i+1)th training iteration.
[0257] For the (i+1)th detection, first obtain the current classifier obtained from the (i+1)th training, and then use the second text encoder, the second image encoder and the current classifier obtained from the (i+1)th training to detect the initial reference category text sample and the initial image sample of the (i+1)th round, to obtain the reference category text sample corresponding to the target category in the initial image sample of the (i+2)th round.
[0258] By following this pattern, a combination of training and detection is used to achieve cyclical labeling and model training, thereby improving the accuracy of the second object detection model and the accuracy of the first image sample.
[0259] As one possible implementation, the training process of the learnable parameters is described below, see E1-E5 for details.
[0260] E1: Obtain the currently learnable parameters, multiple third initial reference category text samples, and a second image sample including at least one target object.
[0261] The currently learnable parameters are those that have not yet been fully trained. The third initial reference category text sample is text describing the category and is used to train the learnable parameters. The second image sample includes at least one target object and is used to train the learnable parameters.
[0262] As one possible implementation, the second image sample may include at least one target object belonging to one of a plurality of third initial reference text samples. Alternatively, to improve the accuracy of subsequent learnable parameters, the second image sample may include only one object.
[0263] As one possible implementation, a tokenizer, such as a tokenizer, can be used to segment the file composed of multiple third initial category texts, thereby obtaining multiple third initial reference category text samples. E2: The currently learnable parameters and the multiple third initial reference category text samples are concatenated to obtain multiple second input sequences.
[0264] The current learnable parameters and the third initial reference class text samples are concatenated to obtain the second input sequence. Thus, the current learnable parameters and each third initial reference class text sample are concatenated separately to obtain multiple second input sequences.
[0265] E3: Extract multiple third text sample features from multiple second input sequences using a third text encoder.
[0266] The third text encoder is used to extract text features. The second input sequence is fed into the third text encoder, which extracts third text sample features from the second input sequence. These third text sample features describe the characteristics of the second input sequence. Thus, the third text encoder extracts multiple third text sample features from multiple second input sequences.
[0267] The embodiments of this application do not specifically limit the third text encoder, such as the text encoder in CLIP, which can be the same as or different from the second text encoder.
[0268] E4: The features of the third image sample are extracted from the second image sample by the third image encoder.
[0269] The third image encoder is used to extract image features. The second image sample is input into the third image encoder, which extracts features from the second image sample to obtain third image sample features. These third image sample features describe the characteristics of the second image sample. Thus, multiple third image sample features are extracted from multiple second image samples using the third image encoder.
[0270] The embodiments of this application do not specifically limit the third image encoder, such as the image encoder in CLIP, which can be the same as or different from the second image encoder.
[0271] E5: Adjust the current learnable parameters so that the similarity between the features of the third image sample and the features of the third text sample of the target object satisfies the fifth matching condition, and obtain the learnable parameters.
[0272] Among them, the third text sample feature of the target object is the text sample feature corresponding to one of the target objects included in the second image sample among multiple third text sample features.
[0273] The embodiments of this application do not specifically limit the conditions for the completion of the training of learnable parameters. It can be that the number of iterations in the training process meets a preset number, and the learned parameters obtained by training can make the similarity between the features of the third image sample and the features of the third text sample of the target object meet the fifth matching condition, that is, the fifth matching condition is used as the training target, etc. This application does not make specific limitations in this regard.
[0274] The similarity between the features of the third image sample and the features of the third text sample of the target object satisfies the fifth matching condition. This condition can be defined as the similarity between the features of the third image sample and the features of the third text sample of the target object being greater than the fifth difference threshold. This embodiment does not specifically limit the fifth difference threshold; for example, it could be the minimum difference between the features of the third image sample and the features of the third text sample of the target object. The fifth matching condition is used as the training objective to train the currently learnable parameters. This allows the trained learnable parameters, combined with the third initial reference category text sample, to better describe the third image sample, enabling the subsequent model to understand the global contextual information of the image.
[0275] As one possible implementation, the fifth matching condition can be that the similarity between the third image sample features and the third text sample features of the target object is greater than a fifth difference threshold, and the similarity between the third image sample and other third text sample features is less than or equal to a sixth difference threshold, where the fifth difference threshold is greater than the sixth difference threshold. In other words, the fifth matching condition makes positive sample pairs (such as an object and its corresponding category) more similar and negative sample pairs (such as an object and other objects' corresponding categories) less similar. Here, "other third text sample features" refers to the third text sample features other than those of the target object among multiple third text sample features.
[0276] Therefore, by introducing contrastive learning, the accuracy of the learnable parameters is improved, and the combination of the learned parameters obtained from training and the third initial reference category text samples can better describe the third image samples, so that the subsequent model can understand the global context information of the image.
[0277] As one possible implementation, learnable parameters with universality can be trained (e.g., using multiple third initial reference category text samples of various categories), while learnable parameters with specificity can also be trained (e.g., training a single learnable parameter using multiple third initial reference category text samples belonging to a specific domain). For example, different learnable parameters can be trained for different domains, such as training a single learnable parameter for the medical field and a single learnable parameter for the medical device field.
[0278] Based on this, the target learnable parameters corresponding to the target domain can be determined from multiple learnable parameters according to the target domain to which the second initial reference category text sample belongs. The target learnable parameters are then concatenated with multiple second initial reference category text samples to obtain multiple first input sequences.
[0279] Therefore, by training different learnable parameters for different domains, when recognizing text samples of the second initial reference category in the target domain, the target learnable parameters corresponding to the target domain can be obtained. These target learnable parameters are then concatenated with the text samples of the second initial reference category to obtain the first input sequence, thus enabling subsequent training. Compared to universal learnable parameters, different learnable parameters corresponding to different domains are more specific, resulting in higher accuracy for the subsequently trained second object detection model.
[0280] To facilitate a further understanding of the technical solutions provided in the embodiments of this application, the following description takes the execution subject of the training method for the object detection model provided in the embodiments of this application as a server as an example to provide an overall exemplary introduction to the training method for the second object detection model.
[0281] The second object detection model is based on the ViLD model, but introduces learnable parameters for joint training. The training process of the classifier in the second object detection model will be explained below.
[0282] See Figure 10 This figure is a schematic diagram illustrating the training of a second object detection model provided in an embodiment of this application. Figure 10 In this process, learnable parameters are concatenated with multiple second initial reference category text samples (such as airplanes, people, dogs, trees, etc.) to obtain multiple first input sequences. A second text encoder extracts multiple second text sample features from these first input sequences. A local image including the target object is cropped from the initial image sample, and a second image encoder extracts second image sample features from this local image. The current classifier extracts local sample features including the target object from the initial image sample, as well as classification sample features of the target object. The model parameters of the current classifier are adjusted so that the local sample features and the second image sample features satisfy a third matching condition, and the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, resulting in a trained classifier and a second object detection model. For details, please refer to the explanations in E1-E5 above; they will not be repeated here.
[0283] After training the classifier, a second object detection model is obtained based on the second text encoder and the classifier. Multiple first text features can be extracted from multiple first initial reference category text samples using the second text encoder; the classifier detects the initial image samples to obtain the visual features of the reference recognition boxes and the image regions identified by the reference recognition boxes in the initial image samples; the similarity between the visual features and the multiple first text features is calculated; and based on the multiple similarities, the reference category text samples corresponding to the target category are determined.
[0284] The training process for the learnable parameters is then explained.
[0285] See Figure 11 This figure is a schematic diagram illustrating the training of learnable parameters provided in an embodiment of this application. Figure 11 In this context, the currently learnable parameters can be represented as [V]1, [V]2, ..., [V]. M After transforming the initial third reference category text samples into category descriptions (e.g., a photo of [CLASS]), the category descriptions are concatenated with the currently learnable parameters to obtain multiple second input sequences. These second input sequences are then fed into a third text encoder to obtain the third text sample features corresponding to each second input sequence. Similarly, second image samples are fed into a third image encoder to obtain the third image sample features corresponding to each second image sample. By calculating the similarity between the third text sample features and the third image sample features, and based on the training objective of maximizing the similarity between positive sample pairs and minimizing the similarity between negative sample pairs, the currently learnable parameters are trained, thus obtaining the learnable parameters.
[0286] See Table 3, which presents the experimental results based on the second object detection model.
[0287] Table 3
[0288]
[0289] As shown in Table 3, we can focus on two metrics: mAP and Apr. The former represents the detection performance of the entire dataset, while the latter represents the detection performance of a specific category. The embodiments of this application show a significant improvement over the ViLD method on the standard test set, and require only 4.3% of the computational resources.
[0290] In addition to the training method for the object detection model described above, this application also provides a corresponding training device for the object detection model, so that the above-described object detection model training method can be applied and implemented in practice.
[0291] See Figure 12 This figure is a schematic diagram of the structure of a training device for an object detection model provided in an embodiment of this application. The current object detection model includes a current text encoder, a current image encoder, and a current recognizer, such as... Figure 12 As shown, the training device 1200 for the object detection model includes: an acquisition unit 1201, an extraction unit 1202, a recognition unit 1203, and a training unit 1204.
[0292] The acquisition unit 1201 is used to acquire a first image sample and a target location, wherein the first image sample includes at least one target object, and the target location indicates a preset position of the target object in the first image sample;
[0293] The acquisition unit 1201 is further configured to acquire multiple reference category text sample features, which are obtained by the current text encoder from the multiple reference category text samples respectively. The multiple reference category text samples are used to describe one of the multiple reference categories, and the multiple reference categories include the target category corresponding to the target object.
[0294] The extraction unit 1202 is used to extract the object image sample features of the target object from the first image sample through the current image encoder;
[0295] The recognition unit 1203 is used to determine the predicted position of the target object in the first image sample and the predicted category text feature based on the object image sample features through the current recognizer, wherein the predicted category text feature refers to the predicted category of the target object;
[0296] The training unit 1204 is used to train the current object detection model by adjusting the model parameters of the current text encoder, the current image encoder and / or the current recognizer, so that the predicted position and the target position satisfy a first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition.
[0297] As can be seen from the above technical solution, the first image sample and target location are obtained. The first image sample includes at least one target object to be identified, and the target location indicates a preset position of the target object in the first image sample. The target object in the first image sample is extracted by the current image encoder to obtain object image sample features describing the target object. Multiple reference category text sample features are obtained, each describing a reference category to which an object belongs. These multiple reference category text sample features include the reference category text sample features corresponding to the target category, i.e., the reference category text sample features corresponding to the reference category to which the target object belongs. The reference category text sample features are extracted by the current text encoder from the reference category text samples describing the reference category. Since the multiple reference category text samples are extracted separately, it is equivalent to inputting multiple reference category text samples into the current text encoder in parallel, eliminating the need for repeated calculations and reducing computational load. Furthermore, this method can dynamically expand the reference categories by adding reference category text samples to adapt to unknown categories, achieving open-world object detection. The object image sample features are identified by the current recognizer to determine the predicted position of the target object in the first image sample and the predicted category text features of the target object. Finally, the current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted location and the target location satisfy the first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy the second matching condition. This allows the first object detection model trained based on the current object detection model to not only identify the location of the object in the image but also to identify the category to which the object belongs. During the training process of the object detection model, alignment is performed directly at the feature level, i.e., the blending operation is removed. This not only forces the first object detection model to learn cross-modal semantic consistency through the alignment process but also reduces the computational cost required to train the first object detection model. This shortens the training time of the object detection model and facilitates its engineering deployment.
[0298] As one possible implementation, the second matching condition is that the similarity between the reference category text features and the object image sample features from the same positive sample pair is greater than a first threshold, and the similarity between the reference category text sample features and the object image sample features from the same negative sample pair is less than a second threshold.
[0299] Wherein, the second threshold is less than the first threshold, the positive sample pair includes an image region and a reference category text sample corresponding to the target category, the negative sample pair includes the image region and other reference category text samples, the other reference category text samples are reference category text samples other than the reference category text sample corresponding to the target category among the plurality of reference category text samples, the image region is a portion of the image identified by the reference recognition box in the first image sample, and the target position in the first image sample is identified by the reference recognition box.
[0300] As one possible implementation, the training device 1200 for the object detection model further includes a construction unit for:
[0301] A detection dataset and an alignment dataset are obtained. Reference category text samples corresponding to the target category in the positive sample pairs obtained based on the detection dataset are used to describe the target category. Reference category text samples corresponding to the target category in the positive sample pairs obtained based on the alignment dataset are used to describe the attributes of the target object.
[0302] If the positive sample pair comes from the detection dataset, then the negative sample pair and the plurality of reference category text samples are constructed based on the detection dataset; if the positive sample pair comes from the alignment dataset, then the negative sample pair and the plurality of reference category text samples are constructed based on the alignment dataset.
[0303] As one possible implementation, the building unit is specifically used for:
[0304] Obtain n categories of text from a vocabulary containing m categories of text, where m is a positive integer and n is a positive integer less than or equal to m;
[0305] From the n categories of text and the reference category text samples corresponding to the target object, determine the other reference category text samples;
[0306] The negative sample pair is obtained based on the other reference category text samples and the image region.
[0307] As one possible implementation, the building unit is specifically used for:
[0308] Obtain k reference category text samples from the multiple reference category text samples included in the detection dataset, where k is a positive integer;
[0309] The other reference category text samples are determined from the k reference category text samples and the reference category text samples corresponding to the target object;
[0310] The negative sample pair is obtained based on the other reference category text samples and the image region.
[0311] As one possible implementation, if the number of target objects included in the first image sample is less than the number of the plurality of reference category text samples, and the first image sample includes a first sub-image sample and a second sub-image sample, then the training device 1200 of the object detection model further includes a sampling unit for:
[0312] For the first sub-image sample, p category texts are sampled from the preset category texts. The p category texts and the reference category text samples corresponding to the target objects included in the first sub-image sample are determined as multiple reference category text samples of the first sub-image sample, where p is a positive integer.
[0313] For the second sub-image sample, q category texts are sampled from the preset category texts. The q category texts and the reference category text samples corresponding to the target objects included in the second sub-image sample are determined as multiple reference category text samples of the second sub-image sample, where q is a positive integer. The number of multiple reference category text samples of the first sub-image sample is equal to the number of multiple reference category text samples of the second sub-image sample.
[0314] As one possible implementation, the acquisition unit 1201 is specifically used for:
[0315] Obtain text samples from the multiple reference categories;
[0316] The multiple reference category text samples are independently input into the current text encoder, and the features of the multiple reference category text samples are extracted by the current text encoder.
[0317] As one possible implementation, the identification unit 1203 is specifically used for:
[0318] Using the current recognizer, the predicted position of the target object in the first image sample, the predicted category text features, and the predicted category of the target object are determined based on the object image sample features;
[0319] The training device 1200 for the object detection model further includes an application unit for:
[0320] Get the application image;
[0321] Object image features are extracted from the objects included in the application image by a first image encoder, wherein the first image encoder is trained by the current image encoder;
[0322] The object image features are identified by a recognizer to obtain the object's location in the application image and the category to which the object belongs. The recognizer is trained from the current recognizer.
[0323] As one possible implementation, the acquisition unit 1201 is specifically used for:
[0324] Obtain initial image samples;
[0325] Based on the initial image sample, obtain a descriptive text sample to describe the initial image sample;
[0326] Keywords are extracted from the descriptive text sample of the initial image sample;
[0327] Multiple first initial reference category text samples and the initial image sample are detected to obtain reference recognition boxes in the initial image sample and reference category text samples corresponding to the target category. The multiple first initial reference category text samples include the keyword and preset category text. The reference recognition boxes are used to identify the target location in the first image sample.
[0328] The initial image sample with the reference recognition box is determined as the first image sample.
[0329] As one possible implementation, the acquisition unit 1201 is specifically used for:
[0330] The second object detection model is used to detect the multiple first initial reference category text samples and the initial image samples to obtain reference recognition boxes in the initial image samples and reference category text samples corresponding to the target category. The second object detection model is trained with learnable parameters, which are used to increase the richness of the description of the target object corresponding to the reference recognition box.
[0331] As one possible implementation, the training unit 1204 is further configured to:
[0332] The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples.
[0333] Multiple second text sample features are extracted from the multiple first input sequences by a second text encoder;
[0334] Extract a partial image including the target object from the initial image sample;
[0335] The second image sample features are extracted from the local image using a second image encoder.
[0336] The local sample features of the target object included in the initial image sample are extracted from the initial image sample by the current classifier, as well as the classification sample features of the target object.
[0337] The model parameters of the current classifier are adjusted so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model, which includes a classifier trained based on the current classifier and the second text encoder.
[0338] As one possible implementation, the training device 1200 for the object detection model further includes an application unit for:
[0339] The second text encoder extracts multiple first text features from the multiple first initial reference category text samples;
[0340] The classifier detects the initial image sample to obtain a reference bounding box and visual features of the image region identified by the reference bounding box in the initial image sample. The visual features are in the same feature space as the first text features.
[0341] Calculate the similarity between the visual features and the plurality of first text features respectively;
[0342] Based on multiple similarities, a reference category text sample corresponding to the target category is determined.
[0343] As one possible implementation, the training unit 1204 is specifically used for:
[0344] Based on the target domain to which the second initial reference category text sample belongs, target learnable parameters corresponding to the target domain are determined from multiple learnable parameters. Different domains correspond to different learnable parameters.
[0345] The target learnable parameters are concatenated with multiple second initial reference category text samples to obtain the multiple first input sequences.
[0346] As one possible implementation, the training unit 1204 is further configured to:
[0347] Acquire the currently learnable parameters, multiple third initial reference category text samples, and a second image sample including at least one of the target objects;
[0348] The currently learnable parameters and the multiple third initial reference category text samples are concatenated to obtain multiple second input sequences;
[0349] Multiple third text sample features are extracted from the multiple second input sequences by a third text encoder;
[0350] The features of the third image sample are extracted from the second image sample using a third image encoder.
[0351] The current learnable parameters are adjusted so that the similarity between the third image sample features and the third text sample features of the target object satisfies the fifth matching condition, thus obtaining the learnable parameters.
[0352] As one possible implementation, the training unit 1204 is specifically used for:
[0353] The current learnable parameters are adjusted so that the similarity between the third image sample features and the third text sample features of the target object is greater than a fifth difference threshold, and the similarity between the third image sample and other third text sample features is less than or equal to a sixth difference threshold, thus obtaining the learnable parameters. The other third text sample features are features other than the third text sample features of the target object among the plurality of third text sample features, and the sixth difference threshold is less than the fifth difference threshold.
[0354] See Figure 13 This figure is a schematic diagram of the structure of a training device for an object detection model provided in an embodiment of this application. Figure 13 As shown, the training device 1300 for the object detection model includes: an acquisition unit 1301, a splicing unit 1302, an extraction unit 1303, a cropping unit 1304, and a training unit 1305.
[0355] The acquisition unit 1301 is used to acquire multiple second initial reference category text samples and initial image samples;
[0356] The splicing unit 1302 is used to splice the learnable parameters with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples.
[0357] The extraction unit 1303 is used to extract multiple second text sample features from the multiple first input sequences through a second text encoder;
[0358] The cropping unit 1304 is used to crop a partial image including the target object from the initial image sample;
[0359] The extraction unit 1303 is further configured to extract second image sample features from the local image using a second image encoder;
[0360] The extraction unit 1303 is further configured to extract local sample features of the target object included in the initial image sample and classification sample features of the target object from the initial image sample through the current classifier;
[0361] The training unit 1305 is used to adjust the model parameters of the current classifier so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model. The second object detection model includes a classifier trained based on the current classifier and the second text encoder.
[0362] Therefore, by introducing learnable parameters, the text in the input sequence becomes richer in its description of the target object, effectively adding contextual information. This leads to higher scores in matching text and image features, reducing the discrepancy between training and testing, and improving the recognition ability of the second object detection model. Consequently, it achieves better performance on classification tasks, resulting in a 3 percentage point improvement. Furthermore, for specific categories, performance is significantly improved, eliminating the need for manually designing prompts and increasing convenience. Moreover, the method of concatenating the learnable parameters with the second initial reference category text samples used for training to obtain the first input sequence is convenient and fast.
[0363] This application also provides a computer device, which can be a server or a terminal device. The computer device provided in this application will be described below from a hardware objectification perspective. Figure 14 The diagram shown is a schematic of the server's structure. Figure 15 The diagram shown is a structural schematic of the terminal device.
[0364] See Figure 14This figure is a schematic diagram of a server structure provided in an embodiment of this application. The server 1400 can vary considerably due to different configurations or performance. It may include one or more processors 1422, such as a central processing unit (CPU), memory 1432, and one or more application programs 1442 or data storage media 1430 (e.g., one or more mass storage devices). The memory 1432 and storage media 1430 can be temporary or persistent storage. The program stored in the storage media 1430 may include one or more modules (not shown in the figure), each module may include a series of instruction operations on the server. Furthermore, the processor 1422 may be configured to communicate with the storage media 1430 and execute the series of instruction operations in the storage media 1430 on the server 1400.
[0365] Server 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input / output interfaces 1458, and / or one or more operating systems 1441, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.
[0366] The steps performed by the server in the above embodiments can be based on this Figure 14 The server structure shown.
[0367] The processor 1422 is used to perform the following steps:
[0368] Acquire a first image sample and a target location, wherein the first image sample includes at least one target object, and the target location indicates a preset position of the target object in the first image sample;
[0369] Multiple reference category text sample features are obtained. These multiple reference category text sample features are extracted from the multiple reference category text samples by the current text encoder. Each of the multiple reference category text samples is used to describe one of the multiple reference categories. The multiple reference categories include the target category corresponding to the target object.
[0370] The object image sample features of the target object are extracted from the first image sample by the current image encoder;
[0371] The current recognizer determines the predicted position of the target object in the first image sample and the predicted category text feature based on the object image sample features, wherein the predicted category text feature refers to the predicted category of the target object.
[0372] The current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted position and the target position satisfy a first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition.
[0373] Alternatively, processor 1422 may perform the following steps:
[0374] Obtain multiple second initial reference category text samples and initial image samples;
[0375] The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples.
[0376] Multiple second text sample features are extracted from the multiple first input sequences by a second text encoder;
[0377] Extract a partial image including the target object from the initial image sample;
[0378] The second image sample features are extracted from the local image using a second image encoder.
[0379] The local sample features of the target object included in the initial image sample are extracted from the initial image sample by the current classifier, as well as the classification sample features of the target object.
[0380] The model parameters of the current classifier are adjusted so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model, which includes a classifier trained based on the current classifier and the second text encoder.
[0381] Optionally, the processor 1422 may also execute method steps of any specific implementation of the object detection model training method in the embodiments of this application.
[0382] See Figure 15This figure is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. The description will be based on a smartphone as an example. Figure 15 The diagram shown is a partial structural block diagram of the smartphone, which includes: a radio frequency (RF) circuit 1510, a memory 1520, an input unit 1530, a display unit 1540, a sensor 1550, an audio circuit 1560, a Wi-Fi module 1570, a processor 1580, and a power supply 1590, among other components. Those skilled in the art will understand that... Figure 15 The smartphone structure shown does not constitute a limitation on smartphones and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0383] The following is combined Figure 15 A detailed introduction to the various components of a smartphone:
[0384] The RF circuit 1510 can be used to receive and transmit signals during information transmission or calls. In particular, it receives downlink information from the base station and processes it with the processor 1580; in addition, it transmits uplink data to the base station.
[0385] The memory 1520 can be used to store software programs and modules, and the processor 1580 runs the software programs and modules stored in the memory 1520 to realize various functions and data processing of the smartphone.
[0386] Input unit 1530 can be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the smartphone. Specifically, input unit 1530 may include touch panel 1531 and other input devices 1532. Touch panel 1531, also known as a touch screen, can collect touch operations on or near the user and drive corresponding connected devices according to a pre-set program. In addition to touch panel 1531, input unit 1530 may also include other input devices 1532. Specifically, other input devices 1532 may include, but are not limited to, one or more of the following: physical keyboard, function keys (such as volume control buttons, power buttons, etc.), trackball, mouse, joystick, etc.
[0387] The display unit 1540 can be used to display information input by the user or information provided to the user, as well as various menus of the smartphone. The display unit 1540 may include a display panel 1541, which may optionally be configured as a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.
[0388] Smartphones may also include at least one sensor 1550, such as a light sensor, a motion sensor, and other sensors. Other sensors that smartphones may also be equipped with, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be detailed here.
[0389] Audio circuit 1560, speaker 1561, and microphone 1562 provide an audio interface between the user and the smartphone. Audio circuit 1560 converts received audio data into electrical signals and transmits them to speaker 1561, where speaker 1561 converts them into sound signals for output. On the other hand, microphone 1562 converts collected sound signals into electrical signals, which are received by audio circuit 1560, converted into audio data, and then processed by processor 1580 before being transmitted via RF circuit 1510 to, for example, another smartphone, or the audio data can be output to memory 1520 for further processing.
[0390] The processor 1580 is the control center of the smartphone, connecting various parts of the smartphone through various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 1520, and by calling data stored in the memory 1520. Optionally, the processor 1580 may include one or more processing units.
[0391] The smartphone also includes a power supply 1590 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 1580 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0392] Although not shown, smartphones may also include a camera, Bluetooth module, etc., which will not be described in detail here.
[0393] In this embodiment of the application, the memory 1520 included in the smartphone can store computer programs and transmit the computer programs to the processor.
[0394] The processor 1580 included in the smartphone can execute the training method of the object detection model provided in the above embodiments according to the instructions in the computer program.
[0395] This application also provides a computer-readable storage medium for storing a computer program for executing the training method of the object detection model provided in the above embodiments.
[0396] On the other hand, embodiments of this application provide a computer program product including a computer program, which, when run on a computer device, causes the computer device to perform a training method for an object detection model provided in various optional implementations of the above aspects.
[0397] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium can be at least one of the following media: read-only memory (ROM), RAM, magnetic disk or optical disk, and other media that can store computer programs.
[0398] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “corresponding,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0399] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0400] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0401] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items. Depending on the context, the word “if,” as used herein, can be interpreted as “when,” “in response to a determination,” or “when…”.
[0402] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiments. The device and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of the solution in this embodiment according to actual needs. Those skilled in the art can understand and implement this without creative effort.
[0403] The above description is merely one specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in this application should be included within the scope of protection of this application. Based on the implementation methods provided in the above aspects, this application can also be further combined to provide more implementation methods. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A training method for an object detection model, characterized in that, The current object detection model includes the current text encoder, the current image encoder, and the current recognizer, and the method includes: Acquire a first image sample and a target location, wherein the first image sample includes at least one target object, and the target location indicates a preset position of the target object in the first image sample; Multiple reference category text features are obtained. These multiple reference category text features are extracted from multiple reference category text samples by the current text encoder. Each of the multiple reference category text samples is used to describe one of the multiple reference categories. The multiple reference categories include the target category corresponding to the target object. The object image sample features of the target object are extracted from the first image sample by the current image encoder; The current recognizer determines the predicted position of the target object in the first image sample and the predicted category text feature based on the object image sample features, wherein the predicted category text feature refers to the predicted category of the target object. The current object detection model is trained by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted position and the target position satisfy a first matching condition, and / or, the predicted category text features and the reference category text features corresponding to the target category satisfy a second matching condition.
2. The method according to claim 1, characterized in that, The second matching condition is that the similarity between the reference category text features and the object image sample features from the same positive sample pair is greater than the first threshold, and the similarity between the reference category text sample features and the object image sample features from the same negative sample pair is less than the second threshold. Wherein, the second threshold is less than the first threshold, the positive sample pair includes an image region and a reference category text sample corresponding to the target category, the negative sample pair includes the image region and other reference category text samples, the other reference category text samples are reference category text samples other than the reference category text sample corresponding to the target category among the plurality of reference category text samples, the image region is a portion of the image identified by the reference recognition box in the first image sample, and the target position in the first image sample is identified by the reference recognition box.
3. The method according to claim 2, characterized in that, The method further includes: A detection dataset and an alignment dataset are obtained. The reference category text sample corresponding to the target category in the positive sample pair obtained based on the detection dataset is used to describe the target category. The reference category text sample corresponding to the target category in the positive sample pair obtained based on the alignment dataset is used to describe the attributes of the target object. If the positive sample pair comes from the detection dataset, then the negative sample pair and the plurality of reference category text samples are constructed based on the detection dataset; if the positive sample pair comes from the alignment dataset, then the negative sample pair and the plurality of reference category text samples are constructed based on the alignment dataset.
4. The method according to claim 3, characterized in that, The step of constructing the negative sample pair based on the aligned dataset includes: Obtain n categories of text from a vocabulary containing m categories of text, where m is a positive integer and n is a positive integer less than or equal to m; From the n categories of text and the reference category text samples corresponding to the target object, determine the other reference category text samples; The negative sample pair is obtained based on the other reference category text samples and the image region.
5. The method according to claim 3 or 4, characterized in that, The step of constructing the negative sample pairs based on the detection dataset includes: Obtain k reference category text samples from the plurality of reference category text samples included in the detection dataset, where k is a positive integer; The other reference category text samples are determined from the k reference category text samples and the reference category text samples corresponding to the target object; The negative sample pair is obtained based on the other reference category text samples and the image region.
6. The method according to any one of claims 1-5, characterized in that, If the number of target objects included in the first image sample is less than the number of the plurality of reference category text samples, and the first image sample includes a first sub-image sample and a second sub-image sample, then the method further includes: For the first sub-image sample, p category texts are sampled from the preset category texts. The p category texts and the reference category text samples corresponding to the target objects included in the first sub-image sample are determined as multiple reference category text samples of the first sub-image sample, where p is a positive integer. For the second sub-image sample, q category texts are sampled from the preset category texts. The q category texts and the reference category text samples corresponding to the target objects included in the second sub-image sample are determined as multiple reference category text samples of the second sub-image sample, where q is a positive integer. The number of multiple reference category text samples of the first sub-image sample is equal to the number of multiple reference category text samples of the second sub-image sample.
7. The method according to any one of claims 1-6, characterized in that, The acquisition of features from multiple reference category text samples includes: Obtain text samples from the multiple reference categories; The multiple reference category text samples are independently input into the current text encoder, and the features of the multiple reference category text samples are extracted by the current text encoder.
8. The method according to any one of claims 1-7, characterized in that, The step of determining the predicted position of the target object in the first image sample and the predicted category text features based on the object image sample features using the current recognizer includes: Using the current recognizer, the predicted position of the target object in the first image sample, the predicted category text features, and the predicted category of the target object are determined based on the object image sample features; The method further includes: Get the application image; Object image features are extracted from the objects included in the application image by a first image encoder, wherein the first image encoder is trained by the current image encoder; The object image features are identified by a recognizer to obtain the object's location in the application image and the category to which the object belongs. The recognizer is trained from the current recognizer.
9. The method according to any one of claims 1-8, characterized in that, The acquisition of the first image sample and target location includes: Obtain initial image samples; Based on the initial image sample, obtain a descriptive text sample to describe the initial image sample; Keywords are extracted from the descriptive text sample of the initial image sample; Multiple first initial reference category text samples and the initial image sample are detected to obtain reference recognition boxes in the initial image sample and reference category text samples corresponding to the target category. The multiple first initial reference category text samples include the keyword and preset category text. The reference recognition boxes are used to identify the target location in the first image sample. The initial image sample with the reference recognition box is determined as the first image sample.
10. The method according to claim 9, characterized in that, The step of detecting multiple first initial reference category text samples and the initial image samples to obtain reference recognition boxes in the initial image samples and reference category text samples corresponding to the target category includes: The second object detection model is used to detect the multiple first initial reference category text samples and the initial image samples to obtain reference recognition boxes in the initial image samples and reference category text samples corresponding to the target category. The second object detection model is trained with learnable parameters, which are used to increase the richness of the description of the target object corresponding to the reference recognition box.
11. The method according to claim 10, characterized in that, The method further includes: The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples. Multiple second text sample features are extracted from the multiple first input sequences by a second text encoder; Extract a partial image including the target object from the initial image sample; The second image sample features are extracted from the local image using a second image encoder. The local sample features of the target object included in the initial image sample are extracted from the initial image sample by the current classifier, as well as the classification sample features of the target object. The model parameters of the current classifier are adjusted so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model, which includes a classifier trained based on the current classifier and the second text encoder.
12. The method according to claim 10 or 11, characterized in that, The step of detecting the plurality of first initial reference category text samples and the initial image samples using a second object detection model to obtain reference recognition boxes in the initial image samples and reference category text samples corresponding to the target category includes: The second text encoder extracts multiple first text features from the multiple first initial reference category text samples; The classifier detects the initial image sample to obtain a reference bounding box and visual features of the image region identified by the reference bounding box in the initial image sample. The visual features are in the same feature space as the first text features. Calculate the similarity between the visual features and the plurality of first text features respectively; Based on multiple similarities, a reference category text sample corresponding to the target category is determined.
13. The method according to any one of claims 10-12, characterized in that, The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences, including: Based on the target domain to which the second initial reference category text sample belongs, target learnable parameters corresponding to the target domain are determined from multiple learnable parameters. Different domains correspond to different learnable parameters. The target learnable parameters are concatenated with multiple second initial reference category text samples to obtain the multiple first input sequences.
14. The method according to any one of claims 10-13, characterized in that, The method further includes: Acquire the currently learnable parameters, multiple third initial reference category text samples, and a second image sample including at least one of the target objects; The currently learnable parameters and the multiple third initial reference category text samples are concatenated to obtain multiple second input sequences; Multiple third text sample features are extracted from the multiple second input sequences by a third text encoder; The features of the third image sample are extracted from the second image sample using a third image encoder. The current learnable parameters are adjusted so that the similarity between the third image sample features and the third text sample features of the target object satisfies the fifth matching condition, thus obtaining the learnable parameters.
15. The method according to claim 14, characterized in that, The process of adjusting the current learnable parameters to ensure that the similarity between the third image sample features and the third text sample features of the target object satisfies the fifth matching condition, thereby obtaining the learnable parameters, includes: The current learnable parameters are adjusted so that the similarity between the third image sample features and the third text sample features of the target object is greater than a fifth difference threshold, and the similarity between the third image sample and other third text sample features is less than or equal to a sixth difference threshold, thus obtaining the learnable parameters. The other third text sample features are features other than the third text sample features of the target object among the plurality of third text sample features, and the sixth difference threshold is less than the fifth difference threshold.
16. A training method for an object detection model, characterized in that, The method includes: Obtain multiple second initial reference category text samples and initial image samples; The learnable parameters are concatenated with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples. Multiple second text sample features are extracted from the multiple first input sequences by a second text encoder; Extract a partial image including the target object from the initial image sample; The second image sample features are extracted from the local image using a second image encoder. The local sample features of the target object included in the initial image sample are extracted from the initial image sample by the current classifier, as well as the classification sample features of the target object. The model parameters of the current classifier are adjusted so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model, which includes a classifier trained based on the current classifier and the second text encoder.
17. A training device for an object detection model, characterized in that, The current object detection model includes the current text encoder, the current image encoder, and the current recognizer; the device includes: an acquisition unit, an extraction unit, a recognition unit, and a training unit. The acquisition unit is used to acquire a first image sample and a target location, wherein the first image sample includes at least one target object, and the target location indicates a preset position of the target object in the first image sample; The acquisition unit is further configured to acquire multiple reference category text sample features, which are obtained by the current text encoder from the multiple reference category text samples respectively. The multiple reference category text samples are used to describe one of the multiple reference categories, and the multiple reference categories include the target category corresponding to the target object. The extraction unit is used to extract object image sample features of the target object from the first image sample through the current image encoder; The recognition unit is used to determine the predicted position of the target object in the first image sample and the predicted category text feature based on the object image sample features using the current recognizer, wherein the predicted category text feature refers to the predicted category of the target object; The training unit is configured to train the current object detection model by adjusting the model parameters of the current text encoder, the current image encoder, and / or the current recognizer, so that the predicted position and the target position satisfy a first matching condition, and / or, the predicted category text features and the reference category text sample features corresponding to the target category satisfy a second matching condition.
18. A training device for an object detection model, characterized in that, The device includes: an acquisition unit, a splicing unit, an extraction unit, a truncating unit, and a training unit; The acquisition unit is used to acquire multiple second initial reference category text samples and initial image samples; The splicing unit is used to splice the learnable parameters with multiple second initial reference category text samples to obtain multiple first input sequences. The learnable parameters are used to increase the richness of the description of the target object corresponding to the real recognition box by the second initial reference category text samples. The extraction unit is used to extract multiple second text sample features from the multiple first input sequences through a second text encoder; The cropping unit is used to crop a partial image including the target object from the initial image sample; The extraction unit is further configured to extract second image sample features from the local image using a second image encoder; The extraction unit is further configured to extract local sample features of the target object included in the initial image sample and classification sample features of the target object from the initial image sample using the current classifier; The training unit is used to adjust the model parameters of the current classifier so that the local sample features and the second image sample features satisfy a third matching condition, and / or the classification sample features and the second text sample features of the target object satisfy a fourth matching condition, thereby obtaining the second object detection model. The second object detection model includes a classifier trained based on the current classifier and the second text encoder.
19. A computer device, characterized in that, The computer device includes a processor and memory: The memory is used to store computer programs and to transfer the computer programs to the processor; The processor is configured to perform the method according to any one of claims 1-15, or the method according to claim 16, according to the computer program.
20. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store a computer program for performing the method of any one of claims 1-15, or for performing the method of claim 16.
21. A computer program product comprising a computer program, characterized in that, When it is run on a computer device, it causes the computer device to perform the method of any one of claims 1-15, or to perform the method of claim 16.
