Image detection methods, devices, storage media, and electronic devices

By training the model using edge detection and contrast loss function, the accuracy of image integrity detection was improved, solving the problem of integrity detection when institutions review electronic materials and achieving efficient image content review.

CN117408979BActive Publication Date: 2026-11-17ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311433988.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-30
Publication Date
2026-11-17
Estimated Expiration
2043-10-30

AI Technical Summary

Technical Problem

In existing technologies, when reviewing electronic materials uploaded by clients, institutions often find it difficult to effectively detect the completeness of individual electronic materials, resulting in low review efficiency.

Method used

An edge detection method is adopted to obtain the location information of the main content and edge information in the target image, generate image feature vectors, and train the detection model using a contrastive loss function to improve the accuracy of image integrity detection.

Benefits of technology

It improves the accuracy of integrity detection for specified image categories, ensuring the reliability and efficiency of image content integrity review.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117408979B_ABST
    Figure CN117408979B_ABST
Patent Text Reader

Abstract

This specification discloses an image detection method, apparatus, storage medium, and electronic device. The method includes: firstly acquiring an image to be detected, acquiring a target image belonging to a target category in the image to be detected, then detecting the main content in the target image to obtain the position information of the main image corresponding to the main content in the target image, and finally using an edge detection method and performing integrity detection on the main image based on the position information to determine the integrity detection result of the target image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of image processing technology, and in particular to an image detection method, apparatus, storage medium, and electronic device. Background Technology

[0002] With the rapid development of internet technology, nowadays, most industries choose to record and store transaction information using computers, and use computers to process transactions, that is, to shift transactions from offline processing to online processing.

[0003] When processing transactions online, some organizations often need to review a large number of electronic documents to advance the process. For transactions that require clients to upload relevant electronic materials to the organization's system, the organization can use a combination of machine and manual review to examine the uploaded materials and move the process forward. During this process, the organization's review of the electronic materials may include checking their accuracy, compliance with requirements, and completeness. Summary of the Invention

[0004] This specification provides an image detection method, apparatus, storage medium, and electronic device that can detect whether images of a specified category contain complete content, thereby improving the accuracy of image integrity detection. The technical solution is as follows:

[0005] Firstly, this specification provides an image detection method, the method comprising:

[0006] Acquire the image to be detected, and then acquire the target image belonging to the target category from the image to be detected;

[0007] The main content in the target image is detected to obtain the position information of the main image corresponding to the main content in the target image.

[0008] An edge detection method is used, and the integrity of the subject image is detected based on the location information to determine the integrity detection result of the target image.

[0009] Secondly, this specification provides a method for training a detection model, the method comprising:

[0010] Obtain sample images of the target type, and generate positive sample images and negative sample images based on the sample images. The positive sample images are images with complete content, and the negative sample images are images with incomplete content.

[0011] An initial detection model is used to calculate the positive sample image and the negative sample image to obtain the first feature vector corresponding to the positive sample image and the second feature vector corresponding to the negative sample image.

[0012] Calculate the contrastive loss function based on the first feature vector and the second feature vector;

[0013] The initial detection model is adjusted based on the contrastive loss function to obtain the trained detection model.

[0014] Thirdly, this specification provides an image detection device, the device comprising:

[0015] An image acquisition module is used to acquire an image to be detected, and to acquire a target image belonging to the target category from the image to be detected.

[0016] The first detection module is used to detect the main content in the target image and obtain the position information of the main image corresponding to the main content in the target image;

[0017] The second acquisition module is used to perform integrity detection on the subject image using an edge detection method and based on the location information, and to determine the integrity detection result of the target image.

[0018] Fourthly, this specification provides a detection model training device, the device comprising:

[0019] The image acquisition module is used to acquire sample images of the target type, and generate positive sample images and negative sample images based on the sample images. The positive sample images are images with complete content, and the negative sample images are images with incomplete content.

[0020] The vector calculation module is used to calculate the positive sample image and the negative sample image using the initial detection model to obtain the first feature vector corresponding to the positive sample image and the second feature vector corresponding to the negative sample image;

[0021] The loss calculation module is used to calculate a contrastive loss function based on the first feature vector and the second feature vector;

[0022] The model adjustment module is used to adjust the initial detection model based on the contrast loss function to obtain the trained detection model.

[0023] Fifthly, this specification provides a computer storage medium having multiple instructions adapted for loading by a processor and executing the above-described method steps.

[0024] Sixthly, this specification provides a computer program product that stores at least one instruction, which is loaded by a processor and executed as described above in the method steps.

[0025] In a seventh aspect, this specification provides an electronic device that may include: a memory and a processor; wherein the memory stores a computer program adapted to be loaded by the memory and to execute the above-described method steps.

[0026] The beneficial effects of the technical solutions provided in this specification include at least the following:

[0027] In this embodiment, the method first acquires the image to be detected, then obtains the target image belonging to the target category within that image. Next, the main content of the target image is detected to obtain the position information of the corresponding main image within the target image. Finally, edge detection is applied, and based on this position information, the integrity of the main image is detected to determine the integrity detection result of the target image. This embodiment first detects the main content of the target image belonging to the target category to obtain the position information of the corresponding main image within the target image. Then, it performs integrity detection on the main image based on edge detection and the position information to obtain the integrity detection result of the target image. This embodiment can detect whether an image of a specified category contains complete content, improving the accuracy of image integrity detection. Attached Figure Description

[0028] To more clearly illustrate the technical solutions in the embodiments of the present invention 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 the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is a schematic flowchart of an image detection method provided in the embodiments of this specification;

[0030] Figure 2 This is a schematic diagram of an embodiment provided in this specification;

[0031] Figure 3 This is a schematic flowchart of another image detection method provided in the embodiments of this specification;

[0032] Figure 4 This is a flowchart illustrating a detection model training method provided in the embodiments of this specification;

[0033] Figure 5This is a flowchart illustrating another detection model training method provided in the embodiments of this specification;

[0034] Figure 6 This is a schematic diagram of the structure of an image detection device provided in the embodiments of this specification;

[0035] Figure 7 This is a schematic diagram of the structure of a detection model training device provided in the embodiments of this specification;

[0036] Figure 8 This is a schematic diagram of the structure of an electronic device provided in the embodiments of this specification. Detailed Implementation

[0037] To make the inventive objectives, features, and advantages of the embodiments in this specification more apparent and understandable, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments in this specification, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this specification.

[0038] In the description of this specification, it should be understood that the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. In the description of this specification, it should be noted that, unless otherwise expressly specified and limited, "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices. Those skilled in the art can understand the specific meaning of the above terms in this specification based on the specific circumstances. Furthermore, in the description of this specification, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship.

[0039] In related technologies, for scenarios where clients need to upload relevant materials to an organization for review to advance the relevant transactions, the organization needs to review each electronic material individually to check whether each piece of material has complete content. How to detect the completeness of individual electronic materials is a technical problem that urgently needs to be solved.

[0040] In the following method embodiments, for ease of explanation, only electronic devices are described as the subjects performing each step.

[0041] Please see Figure 1 This is a schematic flowchart of an image detection method provided in an embodiment of this specification. Figure 1 As shown, the method described in the embodiments of this specification may include the following steps:

[0042] S102, Obtain the image to be detected, and obtain the target image belonging to the target category from the image to be detected.

[0043] It is easy to understand that the target category can be one of the multiple categories obtained by classifying images according to image classification criteria. In this illustrative embodiment, the image classification criteria can be set according to actual application scenarios or prior experience, and do not specifically refer to a certain image classification criteria. Similarly, the target category can also be set according to actual application scenarios or prior experience, and does not specifically refer to a certain image category.

[0044] In one or more embodiments of this specification, in some application scenarios, the image to be detected can be obtained from a specified database; in other application scenarios, the image to be detected can be obtained by receiving images sent by other terminals. Furthermore, one or more images to be detected can be classified and identified, that is, the image category to which each image to be detected belongs can be identified. When an image category is the target category, the images to be detected belonging to that image category can be determined as the target images.

[0045] For example, one application scenario of this specification embodiment is the identification of expense invoices in insurance claim materials. In this scenario, a user can upload insurance claim materials to the insurance company's claim system. The user can upload the insurance claim materials using a user terminal. The insurance company's claim system is deployed on a server, which can be the electronic device described in this specification embodiment. The insurance claim materials uploaded by the user terminal can be multiple images, i.e., images to be detected. If it is medical insurance, these images can include the user's ID photo, inpatient medical records, medical expense invoices, medical expense lists, etc. The user's electronic device can receive the images to be detected transmitted by the user terminal to obtain the images to be detected. The electronic device can identify the image category to which each image belongs. It can identify that the image category of the ID photo is user ID, the image category of the inpatient medical records is medical records, the image category of the medical expense invoices is expense invoices, and the image category of the medical expense lists is expense lists. When the set target category is expense invoices, the image of the medical expense invoice is the target image.

[0046] S104, detect the main content in the target image and obtain the position information of the main image corresponding to the main content in the target image.

[0047] As is easily understood, the main content refers to the information presented in an image. The main content can be text, portraits, animals, plants, landscapes, etc. Some images may have only text as the main content, some may have a combination of text and portraits, and some may have a combination of portraits and landscapes.

[0048] In some embodiments, the main content in the target image can be detected, the target region of the main content in the target image can be detected, and the position information of the target image corresponding to the main content in the target image can be determined based on the position of the target region in the target image.

[0049] The target region can refer to the area indicated by the bounding box. Specifically, the target region can be a single bounding box or a larger bounding box composed of multiple smaller bounding boxes. Since the main content of an image can include various types of content, and these contents can be located anywhere in the target image, the process of identifying the main content in the target image can identify content located at different positions. Each time a type of content is identified, a bounding box can be used to select that type of content. When the identification of a target image is complete, the target image may contain multiple smaller bounding boxes. A larger bounding box can be generated from these smaller bounding boxes, and this larger bounding box can then be considered the target region.

[0050] Specifically, after determining the target area, a coordinate system can be established using the target image, that is, the adjacent edges of the target image can be used as the X-axis and Y-axis of the coordinate system to determine the coordinate position of the target area in the target image. Furthermore, the coordinate position of the target area in the target image can be determined as the position information of the main content in the main image.

[0051] S106. An edge detection method is used, and the integrity of the main image is detected based on the location information to determine the integrity detection result of the target image.

[0052] It is easy to understand that the completeness detection result can include both complete and incomplete results. Specifically, when the completeness detection result is complete, it can be said that the target image is an image with complete content; when the completeness detection result is incomplete, it can be said that the target image is an image with incomplete content.

[0053] Edge detection refers to the detection of edges in an image. By detecting the edges of an image, edge information can be obtained.

[0054] In some embodiments, edge information of the subject image can be detected, and the integrity of the subject image can be detected based on the edge information and the position information of the subject image in the target image. That is, the integrity of the subject image can be detected based on the edge information and the position information to determine whether the subject image is an image with complete content or an image with incomplete content.

[0055] For example, see Figure 2 The schematic diagrams shown illustrate this. Image A represents a complete main image, containing complete user information (name, sexual characteristics, age) and complete cost information (surgery name and cost). Image B represents an incomplete image. While the complete content of Image B is the same as that shown in Image A, the user name, sexual characteristics, age, surgery name, and cost are missing. Therefore, this embodiment of the specification determines that the completeness detection result for Image A is complete, and the completeness detection result for Image B is incomplete.

[0056] In this embodiment, the method first acquires the image to be detected, then obtains the target image belonging to the target category within that image. Next, the main content of the target image is detected to obtain the position information of the corresponding main image within the target image. Finally, edge detection is applied, and based on this position information, the integrity of the main image is detected to determine the integrity detection result of the target image. This embodiment first detects the main content of the target image belonging to the target category to obtain the position information of the corresponding main image within the target image. Then, it performs integrity detection on the main image based on edge detection and the position information to obtain the integrity detection result of the target image. This embodiment can detect whether an image of a specified category contains complete content, improving the accuracy of image integrity detection.

[0057] Please see Figure 3 This is a flowchart illustrating a method provided in an embodiment of this specification. Figure 3 As shown, the method described in the embodiments of this specification may include the following steps:

[0058] S302, acquire the image to be detected, classify and identify the image to be detected, and obtain the target image that belongs to the target category in the image to be detected.

[0059] Understandably, an explanation of the target category can be found here. Figure 1 The description in S102 of the illustrated embodiment will not be repeated here.

[0060] In some embodiments, the image to be detected can be obtained from a specified database, or the image to be detected can be received from other terminals; the image to be detected is classified and identified to obtain the target image belonging to the target category. This can be understood as identifying the image to be detected to obtain the probability that the image to be detected belongs to multiple reference categories; the probabilities are arranged in descending order, and the probability that is ranked first is taken as the target probability. The reference category corresponding to the target probability is determined as the image category of the image to be detected. If the image category is the target category, the image to be detected belonging to the target category is determined as the target image.

[0061] Specifically, a pre-trained classification model can be used to identify the image to be detected, obtaining the probability that the image belongs to multiple reference categories. The classification model can be trained using convolutional neural networks such as AlexNet, deep learning models like VGG, deep learning structures like GoogLeNet, deep residual neural networks like ResNet, and lightweight convolutional neural networks like MobileOne. During the training of the classification model, pseudo-labeling technology can be used. Pseudo-labeling technology involves training the model using both labeled and unlabeled image data. The process of training the model using pseudo-labeling technology is as follows: first, a classification model is trained using labeled image data to obtain an initial model; then, this initial model is used to predict the classification of unlabeled image data; the classification information of the unlabeled image data can be judged, and images with accurate classification predictions can be selected from the unlabeled image data; these images with accurate classification predictions can be used as new training data. These new training data, which have accurate classification information (i.e., labeled image data), can be input into the initial model for further training to obtain the trained classification model. The embodiments in this specification use pseudo-labeling technology to train the model, which can save manpower for labeling training data and improve the training speed of the model.

[0062] Optionally, in this embodiment, when training a classification model using the lightweight convolutional neural network MobileOne model, the serial computation of depthwise and pointwise features in the MobileOne model can be changed to parallel computation of depthwise and pointwise features. Correspondingly, the corresponding block structure is also modified from a serial structure to a parallel structure. By performing parallel computation of depthwise and pointwise features, feature fusion is achieved in parallel. That is, depthwise and pointwise branches exist in parallel within the model, and these two branches compute two different features in parallel, improving the accuracy of identifying target images belonging to the target category.

[0063] In another embodiment of this specification, the image to be detected is classified and identified to obtain a target image belonging to the target category. This can be understood as identifying the content in the image to be detected, determining the image category to which the image to be detected belongs based on the identified content, and if the image category is the target category, then the image to be detected belonging to that image category is determined as the target image. For example, some images to be detected contain a large amount of text content, so this text content can be identified to determine the image category to which the image to be detected belongs; some images to be detected may contain images of people, objects, or landscapes, so this content can be identified to determine the image category to which the image to be detected belongs.

[0064] S304, obtain the time information, the identity information of the transaction object, and the detailed information of the transaction item in the target image, and determine the time information, the identity information of the transaction object, and the detailed information of the transaction item as the main content in the target image.

[0065] It is easy to understand that the main content can refer to the content used to represent the information of the image.

[0066] In the embodiments of this specification, the target category can refer to a cost category. A specific application scenario could be an image identification scenario for cost categories. Correspondingly, for a target image belonging to a cost category, its content can be cost-related content, specifically including the time the cost was consumed, the identity of the transaction object using the cost, and the cost details. Therefore, the time information, the identity information of the transaction object, and the detailed information of the transaction item in the target image can be obtained, and these information can be determined as the main content of the target image. The time information can refer to the time when the cost was generated, specifically a specific natural day or several natural days. The transaction object can refer to the object using the cost, specifically an individual, unit, smart device, appliance, vehicle, etc. When the transaction object is an individual, the transaction object's identity information can refer to the individual's name, age, and gender; when the transaction object is a smart device, appliance, or vehicle, the transaction object's identity information can refer to its name, model, color, etc. The transaction item can refer to all sub-items that consume costs, and the detailed information of the transaction item can refer to the name of the sub-item, the number of sub-items, and the cost amount consumed by the sub-item, etc.

[0067] S306, Detect the position information of the subject image corresponding to the subject content in the target image.

[0068] In some embodiments, the main content contained in a target image can be distributed in different positions in the target image. The main image corresponding to the main content can be determined first based on the main content, and then the position information of the main image in the target image can be detected.

[0069] Specifically, the main image corresponding to the main content is determined based on the main content. When the main content is determined to be an indivisible part, the area of ​​the main content in the target image can be determined as the area where the main image is located, and the image corresponding to the area can be determined as the main image. When the main content is determined to be composed of multiple contents, a target area that contains multiple contents can be generated based on the areas where these contents are located in the target image, and the image corresponding to the target area can be determined as the main image.

[0070] Furthermore, the position of the subject image in the target image is detected. Specifically, the position of each vertex of the subject image in the target image can be determined. The image formed by connecting adjacent vertices is the subject image. Therefore, the position information of the subject image in the target image can be represented by the position of each vertex of the subject image in the target image.

[0071] S308, acquire the edge information of the main image, and determine the image feature vector of the main image based on the edge information and position information.

[0072] It is easy to understand that edge information can refer to information obtained from image features that exhibit local discontinuous changes. Edges in an image are image features that exhibit local discontinuous changes. Edges can be the parts with the most significant changes, such as changes in grayscale values, abrupt changes in color components, or abrupt changes in texture structure.

[0073] In some embodiments, edge information of the subject image can be obtained; image features of the subject image can be determined based on the edge information and position information; and image feature vector of the subject image can be calculated based on the image features.

[0074] Specifically, edge detection algorithms can be used to calculate the edge information of the subject image. A single edge image obtained from edge detection can be used to represent the edge information of the subject image. Image features of the subject image can be determined based on the edge and position information, and an encoder can be used to encode these image features to obtain the image feature vector of the subject image.

[0075] S310, obtain the similarity between the image feature vector and the first reference feature vector and the second reference feature vector respectively.

[0076] It is easy to understand that the completeness result indicated by the first reference feature vector is complete, while the completeness result indicated by the second reference feature vector is incomplete.

[0077] In some embodiments, the similarity between the image feature vector and the first reference feature vector can be calculated, as well as the similarity between the image feature vector and the second reference vector.

[0078] Specifically, the similarity calculation method selected in this application embodiment can be cosine similarity. Cosine similarity represents the degree of similarity between users by the cosine value of the angle between the vectors, that is, by dividing the inner product of the vectors by the product of the magnitudes of the vectors.

[0079] S312, arrange the similarities in descending order, determine the first similarity as the target similarity, and determine the target reference feature vector corresponding to the target similarity from the first reference feature vector and the second reference feature vector.

[0080] In some embodiments, the similarity between the image feature vector and the first reference feature vector can be denoted as the first similarity, and the similarity between the image feature vector and the second reference feature vector can be denoted as the second similarity. The first and second similarities can be arranged in descending order. The first similarity ranked first can be determined as the target similarity, and the first reference feature vector is the target feature vector. Alternatively, the second similarity ranked first can be determined as the target similarity, and the second reference feature vector is the target feature vector.

[0081] S314, determine the integrity result indicated by the target feature vector as the integrity detection result of the target image.

[0082] In some embodiments, when the target feature vector is a first reference feature vector, since the completeness result indicated by the first reference feature vector is complete, the completeness detection result of the target image can be determined to be complete, and this completeness detection result can indicate that the target image is an image with complete content. When the target feature vector is a second reference feature vector, since the completeness result indicated by the second feature vector is incomplete, the completeness detection result of the target image can be determined to be incomplete, and this completeness detection result can indicate that the target image is an image without complete content.

[0083] In this embodiment, the process begins by acquiring an image to be detected, then identifying a target image belonging to the target category within that image. Next, the main content of the target image is determined, and the positional information of the main image corresponding to the main content within the target image is detected. Then, edge information of the main image is acquired. Based on the edge and positional information, an image feature vector of the main image is determined. The similarity between the image feature vector and a first and second reference feature vector is obtained, and these similarities are arranged in descending order. The similarity at the top of the list is determined as the target similarity. A target reference feature vector corresponding to the target similarity is then determined from the first and second reference feature vectors. Finally, the completeness result indicated by the target feature vector is determined as the completeness detection result of the target image. This embodiment detects the positional and edge information of the main content of a target image belonging to the target category, and then generates an image feature vector based on the position and edge information to detect the completeness of the target image, thus improving the accuracy of the detected image completeness.

[0084] Please see Figure 4 This is a flowchart illustrating a detection model training method provided in an embodiment of this specification. Figure 4 As shown, the method described in the embodiments of this specification may include the following steps:

[0085] S402, Obtain sample images of the target category, and generate positive and negative sample images based on the sample images.

[0086] It is easy to understand that the target category can be one of several categories obtained by classifying images according to image classification criteria. In this illustrative embodiment, the image classification criteria can be set based on actual application scenarios or prior experience, and do not specifically refer to a particular image classification criterion. Similarly, the target category can also be set based on actual application scenarios or prior experience, and does not specifically refer to a particular image category. The target category in this embodiment and the above... Figure 1 and Figure 3 The target category in the illustrated embodiments refers to the same category.

[0087] Sample images can refer to images used to generate training data for training models.

[0088] Positive sample images can be images with complete content, while negative sample images can be images with incomplete content.

[0089] In some embodiments, a set of sample images for the target category can be obtained from an image database. For each sample image in this set, a cropping operation can be performed to obtain some positive sample images and some negative sample images. That is, cropping the sample images can yield some complete positive sample images and some incomplete negative sample images.

[0090] S404: The initial detection model is used to calculate the positive and negative sample images to obtain the first feature vector corresponding to the positive sample image and the second feature vector corresponding to the negative sample image.

[0091] It's easy to understand that the initial model is trained using contrastive learning. The idea behind contrastive learning is to learn a representation model that can map images to a projection space, and within this space, bring positive examples closer together and push negative examples further apart. Here, the distance to positive examples can refer to the distance between the vectors of two positive sample images; the distance to negative examples can refer to the distance between the vectors of a positive sample image and a negative sample image.

[0092] In this embodiment, the initial detection model may include a feature encoder and a nonlinear transformation structure. The feature encoder converts positive and negative sample images into corresponding feature representations, and the nonlinear transformation structure maps these feature representations into vectors in another space. In this space, it is desirable for positive examples to be closer together and negative examples to be farther apart.

[0093] In the embodiments of this specification, during the process of converting a positive sample image into a corresponding feature representation, the feature encoder first detects the main content in the positive sample image to obtain the position information of the first main image corresponding to the main content in the positive sample image. Then, it uses edge detection and converts the first main image into a corresponding feature representation based on the position information. During the process of converting a negative sample image into a corresponding feature representation, the feature encoder first detects the main content in the negative sample image to obtain the position information of the second main image corresponding to the main content in the negative sample image. Then, it uses edge detection and converts the second main image into a corresponding feature representation based on the position information.

[0094] In one or more embodiments of this specification, the initial detection model may have symmetrical upper and lower branch structures, each branch structure may consist of the same feature encoder and the same nonlinear transformation structure. Positive sample images enter the upper branch structure, and after processing by the feature encoder and nonlinear transformation structure, a first feature vector of the positive sample image can be obtained. Simultaneously, negative sample images can enter the lower branch structure, and after processing by the feature encoder and nonlinear transformation structure, a second feature vector corresponding to the negative sample image can be obtained.

[0095] S406, calculate the contrastive loss function based on the first feature vector and the second feature vector.

[0096] S408, the initial detection model is adjusted based on the contrastive loss function to obtain the trained detection model.

[0097] The following explains S406-S408.

[0098] In the embodiments of this specification, the contrast loss function can be the Normalized Temperature-scaled Cross Entropy Loss (NT-Xent loss). The formula for this loss function is as follows:

[0099]

[0100] Where N represents the number of sample images in a set of sample images. Preprocessing N sample images yields N pairs of samples, resulting in a total of 2N samples. For a given positive sample pair (i.e., two positive samples), the remaining 2(N-1) samples are all negative samples; i Let z represent the first eigenvector. j sim(z) represents the second eigenvector. i ,z j ) represents the formula for calculating cosine similarity; 1[k≠i] It can be 0 or 1. When k is not equal to i, the result is 1, otherwise it is 0; τ is the temperature coefficient.

[0101] As can be seen from the formula above, only the distance between positive sample pairs is calculated in the numerator, while negative sample pairs only appear in the denominator. The smaller the distance between positive sample pairs and the larger the distance between negative sample pairs, the smaller the value of the contrastive loss function. Therefore, the relevant parameters in the initial detection model can be adjusted according to the above theory until the value of the contrastive loss function reaches its minimum, thus obtaining the trained detection model.

[0102] In the embodiments of this specification, sample images of the target category are acquired, and positive and negative sample images are generated based on these sample images. An initial detection model is used to calculate the positive and negative sample images to obtain a first feature vector corresponding to the positive sample image and a second feature vector corresponding to the negative sample image. A contrastive loss function is calculated based on the first and second feature vectors, and the initial detection model is adjusted based on the contrastive loss function to obtain a trained detection model. The embodiments of this specification employ a contrastive learning approach to train the model. The contrastive loss function makes similar samples closer in the projection space and opposite samples farther apart, thereby improving model performance.

[0103] Please see Figure 5 This is a flowchart illustrating a detection model training method provided in an embodiment of this specification. Figure 5 As shown, the method described in the embodiments of this specification may include the following steps:

[0104] S502, acquire sample images of the target category, perform enhancement processing on the sample images to obtain positive sample images and negative sample images.

[0105] In some embodiments, a set of sample images for the target category can be obtained from an image database. For each sample image in the set, enhancement processing can be performed on the sample image, which may include one or more operations such as cropping, rotating, cutting, flipping, color changing, and blurring, to obtain some positive sample images and some negative sample images. That is, some positive sample images with complete content and some negative sample images with incomplete content can be obtained.

[0106] S504, the initial detection model is used to detect the positive subject content in the positive sample image, and the first position information of the positive subject image corresponding to the positive subject content in the positive sample image is obtained.

[0107] S506, Calculate the first feature vector corresponding to the positive sample image based on the first position information.

[0108] The following explains S504 and S506.

[0109] In the embodiments of this specification, an initial detection model can be used to obtain time information, identity information of transaction objects, and detailed information of transaction items in the positive sample image, and the time information, identity information of transaction objects, and detailed information of transaction items can be determined as the positive main content in the positive sample image. Further, the first position information of the positive main image corresponding to the positive main content in the positive sample image is detected. Further, the first edge information of the positive main image is obtained, and the first feature vector of the positive main image is determined based on the first edge information and the first position information.

[0110] Specifically, the application scenario of this specification embodiment can be a scenario of identifying image categories of expenses, in which case the target category can be the expense category. Correspondingly, for a positive sample image belonging to the expense category, its content can be expense-related content, specifically including the time the expense was incurred, the identity of the transaction object using the expense, and the expense details. Therefore, the time information, the identity information of the transaction object, and the detailed information of the transaction item in the positive sample image can be obtained, and these information can be determined as the positive main content in the positive sample image. The time information can refer to the time when the expense was incurred, specifically a specific natural day or several natural days. The transaction object can refer to the object using the expense, specifically an individual, unit, smart device, appliance, vehicle, etc. When the transaction object is an individual, the identity information can refer to the individual's name, age, and gender; when the transaction object is a smart device, appliance, or vehicle, the identity information can refer to its name, model, color, etc. A transaction item can refer to all sub-items that consume expenses. The detailed information of a transaction item can include the name of the sub-item, the number of sub-items, the amount of expenses consumed by the sub-item, and so on.

[0111] Specifically, the positive subject image corresponding to the positive subject content is determined based on the positive subject content. When the positive subject content is determined to be a single, indivisible component, the region of that positive subject content in the positive sample image can be defined as the region where the positive subject image is located, and the image corresponding to that region can be defined as the positive subject image. When the positive subject content is determined to be composed of multiple components, a target region containing all these components can be generated based on their respective regions in the positive sample image, and the image corresponding to that target region can be defined as the positive subject image. Furthermore, the position of each vertex of the positive subject image in the positive sample image can be determined. The image formed by connecting adjacent vertices is the positive subject image. Therefore, the position of each vertex of the positive subject image in the positive sample image can represent the first position information of the positive subject image in the positive sample image.

[0112] Specifically, an edge detection algorithm can be used to calculate the first edge information of the frontal subject image. The first edge information of the frontal subject image can be represented by an edge image obtained from edge detection. Image features of the frontal subject image can be determined based on the first edge information and the first position information, and a feature encoder can be used to encode the image features to obtain the first feature vector of the frontal subject image.

[0113] S508, the initial detection model is used to detect the negative subject content in the negative sample image, and the second position information of the negative subject image corresponding to the negative subject content in the negative sample image is obtained.

[0114] S510, calculate the negative subject image based on the second position information to obtain the second feature vector corresponding to the negative sample image.

[0115] The following is an explanation of S508 and S510.

[0116] In the embodiments of this specification, an initial detection model can be used to obtain time information, identity information of transaction objects, and detailed information of transaction items in the negative sample image, and the time information, identity information of transaction objects, and detailed information of transaction items are determined as the negative subject content in the negative sample image. Further, the second position information of the negative subject image corresponding to the negative subject content in the negative sample image is detected. Further, the second edge information of the negative subject image is obtained, and the second feature vector of the negative subject image is determined based on the second edge information and the second position information.

[0117] Specifically, the application scenario of this specification embodiment can be a scenario of identifying image categories of expenses, in which case the target category can be the expense category. Correspondingly, for a negative sample image belonging to the expense category, its content can be expense-related content, specifically including the time the expense was incurred, the identity of the transaction object using the expense, and the expense details. Therefore, the time information, the identity information of the transaction object, and the detailed information of the transaction item in the negative sample image can be obtained, and these information can be determined as the negative main content in the negative sample image. The time information can refer to the time when the expense was incurred, specifically a specific natural day or several natural days. The transaction object can refer to the object using the expense, specifically an individual, unit, smart device, appliance, vehicle, etc. When the transaction object is an individual, the identity information can refer to the individual's name, age, and gender; when the transaction object is a smart device, appliance, or vehicle, the identity information can refer to its name, model, color, etc. A transaction item can refer to all sub-items that consume expenses. The detailed information of a transaction item can include the name of the sub-item, the number of sub-items, the amount of expenses consumed by the sub-item, and so on.

[0118] Specifically, the negative subject image is determined based on the negative subject content. When the negative subject content is determined to be a single, indivisible component, the region of that negative subject content in the negative sample image can be defined as the region where the negative subject image is located, and the image corresponding to that region can be defined as the negative subject image. When the negative subject content is determined to be composed of multiple components, a target region containing all these components can be generated based on their respective regions in the negative sample image, and the image corresponding to that target region can be defined as the negative subject image. Furthermore, the position of each vertex of the negative subject image in the negative sample image can be determined. The image formed by connecting adjacent vertices is the negative subject image. Therefore, the position of each vertex of the negative subject image in the negative sample image can represent the first position information of the negative subject image in the negative sample image.

[0119] Specifically, an edge detection algorithm can be used to calculate the second edge information of the negative subject image. The second edge information of the negative subject image can be represented by an edge image obtained from edge detection. Image features of the negative subject image can be determined based on the second edge information and the second position information, and a feature encoder can be used to encode these image features to obtain the second feature vector of the negative subject image.

[0120] S512, calculates the contrastive loss function based on the first feature vector and the second feature vector.

[0121] S514, adjust the initial detection model based on the contrastive loss function to obtain the trained detection model.

[0122] Specifically, see S512 and S514. Figure 4 The descriptions of S406 and S408 in the illustrated embodiment will not be repeated here.

[0123] In the embodiments of this specification, sample images of the target category are acquired. An initial detection model is used to detect the positive main content in the positive sample images, obtaining the first position information of the positive main image corresponding to the positive main content in the positive sample images. Based on the first position information, the positive main image is calculated to obtain the first feature vector corresponding to the positive sample image. The initial detection model is then used to detect the negative main content in the negative sample images, obtaining the second position information of the negative main image corresponding to the negative main content in the negative sample images. Based on the second position information, the negative main image is calculated to obtain the second feature vector corresponding to the negative sample image. A contrastive loss function is calculated based on the first and second feature vectors. The initial detection model is adjusted based on the contrastive loss function to obtain the trained detection model. The embodiments of this specification employ a contrastive learning approach to train the model. The contrastive loss function makes similar samples closer in the projection space and opposite samples farther apart in the projection space, improving model performance. In the embodiments of this specification, the encoder in the model also detects the position information of the input sample images and generates feature vectors of the images based on the position information, improving the accuracy of feature vector calculation and thus improving model performance.

[0124] Please see Figure 6 This is a schematic diagram of the structure of an image detection device provided in an embodiment of this specification. The image detection device 600 can be implemented as all or part of a terminal through software, hardware, or a combination of both. The device 600 includes:

[0125] Image acquisition module 610 is used to acquire an image to be detected, and to acquire a target image belonging to a target category from the image to be detected;

[0126] The first detection module 620 is used to detect the main content in the target image and obtain the position information of the main image corresponding to the main content in the target image;

[0127] The second acquisition module 630 is used to perform integrity detection on the subject image using an edge detection method and based on the location information, and determine the integrity detection result of the target image.

[0128] Optionally, the image acquisition module includes:

[0129] The image acquisition unit is used to classify and identify the image to be detected, and obtain the target image that belongs to the target category in the image to be detected.

[0130] Optionally, the image acquisition unit includes:

[0131] The first recognition unit is used to recognize the image to be detected and obtain the probability that the image to be detected belongs to multiple reference categories respectively;

[0132] The second identification unit is used to arrange the probabilities in descending order, take the probability at the top as the target probability, and determine the reference category corresponding to the target probability as the image category of the image to be detected.

[0133] The third identification unit is used to identify the image to be detected belonging to the target category as the target image if the image category is the target category.

[0134] Optionally, the first detection module 620 includes:

[0135] The first detection unit is used to acquire time information, identity information of transaction objects, and detailed information of transaction items in the target image, and to determine the time information, identity information of transaction objects, and detailed information of transaction items as the main content in the image.

[0136] The second detection unit is used to detect the position information of the subject image corresponding to the subject content in the target image.

[0137] Optionally, the second acquisition module 630 includes:

[0138] The first acquisition unit is used to acquire edge information of the main image and determine the image feature vector of the main image based on the edge information and the position information;

[0139] The second acquisition unit is used to acquire the similarity between the image feature vector and the first reference feature vector and the second reference feature vector, respectively, wherein the completeness result indicated by the first reference feature vector is complete, and the completeness result indicated by the second reference feature vector is incomplete;

[0140] The third acquisition unit is used to arrange the similarities in descending order, determine the first similarity as the target similarity, and determine the target reference feature vector corresponding to the target similarity from the first reference feature vector and the second reference feature vector;

[0141] The fourth acquisition unit is used to determine the integrity result indicated by the target feature vector as the integrity detection result of the target image.

[0142] Optionally, the first acquisition unit includes:

[0143] The first subunit is used to determine the image features of the main image based on the edge information and the position information;

[0144] The second subunit is used to calculate the image feature vector of the subject image based on the image features.

[0145] Please see Figure 7 This is a schematic diagram of a training device for a detection model provided in an embodiment of this specification. The training device 700 for the detection model can be implemented as all or part of a terminal through software, hardware, or a combination of both. The device 700 includes:

[0146] The image acquisition module 710 is used to acquire sample images of the target type, and generate positive sample images and negative sample images based on the sample images. The positive sample images are images with complete content, and the negative sample images are images with incomplete content.

[0147] The vector calculation module 720 is used to calculate the positive sample image and the negative sample image using the initial detection model to obtain the first feature vector corresponding to the positive sample image and the second feature vector corresponding to the negative sample image;

[0148] The loss calculation module 730 is used to calculate a contrastive loss function based on the first feature vector and the second feature vector;

[0149] The model adjustment module 740 is used to adjust the initial detection model based on the contrastive loss function to obtain the trained detection model.

[0150] Optionally, the image acquisition module includes:

[0151] The image acquisition unit is used to enhance the sample image to obtain a positive sample image and a negative sample image.

[0152] Optionally, the vector computation module includes:

[0153] The first calculation module is used to detect the positive subject content in the positive sample image using the initial detection model, and obtain the first position information of the positive subject image corresponding to the positive subject content in the positive sample image;

[0154] The second calculation module is used to calculate the positive subject image based on the first position information to obtain the first feature vector corresponding to the positive sample image;

[0155] The third calculation module is used to detect the negative subject content in the negative sample image using the initial detection model, and to obtain the second position information of the negative subject image corresponding to the negative subject content in the negative sample image;

[0156] The fourth calculation module is used to calculate the negative subject image based on the second location information to obtain the second feature vector corresponding to the negative sample image.

[0157] Please refer to Figure 8 This diagram illustrates the structure of an electronic device provided in an exemplary embodiment of this specification. The electronic device in this specification may include one or more components such as a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, memory 120, input device 130, and output device 140 may be connected via the bus 150.

[0158] Processor 110 may include one or more processing cores. Processor 110 connects to various parts of the terminal using various interfaces and lines, and performs various functions and processes data of terminal 100 by running or executing instructions, programs, code sets, or instruction sets stored in memory 120, and by calling data stored in memory 120. Optionally, processor 110 may be implemented using at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), or programmable logic array (PLA). Processor 110 may integrate one or more of the following: central processing unit (CPU), graphics processing unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the displayed content; and the modem handles wireless communication. It is understood that the modem may also not be integrated into processor 110 and may be implemented separately using a communication chip.

[0159] The memory 120 may include random access memory (RAM) or read-only memory (ROM). Optionally, the memory 120 may include non-transitory computer-readable storage medium. The memory 120 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (e.g., touch function, sound playback function, image playback function, etc.), instructions for implementing the various method embodiments described below, etc. The operating system may be the Android system, including systems deeply developed based on the Android system, the iOS system developed by Apple Inc., including systems deeply developed based on the iOS system, or other systems.

[0160] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to establish data communication between the third-party applications and the operating system. This would allow the operating system to obtain the current scenario information of the third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.

[0161] The input device 130 is used to receive input instructions or data, and includes, but is not limited to, a keyboard, mouse, camera, microphone, or touch device. The output device 140 is used to output instructions or data, and includes, but is not limited to, a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 can be a touch display screen.

[0162] The touch display screen can be designed as a full-screen, curved screen, or irregularly shaped screen. It can also be designed as a combination of a full-screen and a curved screen, or a combination of an irregularly shaped screen and a curved screen; however, this specification does not limit the specific design of the embodiments described herein.

[0163] In addition, those skilled in the art will understand that the structure of the electronic device shown in the above figures does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. For example, the electronic device may also include radio frequency circuits, input units, sensors, audio circuits, Wireless Fidelity (WiFi) modules, power supplies, Bluetooth modules, etc., which will not be described in detail here.

[0164] exist Figure 8In the illustrated electronic device, the processor 110 can be used to call the image detection method program stored in the memory 120, and specifically perform the following operations:

[0165] Acquire the image to be detected, and then acquire the target image belonging to the target category from the image to be detected;

[0166] The main content in the target image is detected to obtain the position information of the main image corresponding to the main content in the target image.

[0167] An edge detection method is used, and the integrity of the subject image is detected based on the location information to determine the integrity detection result of the target image.

[0168] In one embodiment, when the processor 110 performs the step of acquiring a target image belonging to a target category in the image to be detected, it specifically performs the following operations:

[0169] The image to be detected is classified and identified to obtain the target image belonging to the target category in the image to be detected.

[0170] In one embodiment, when the processor 110 performs the classification and recognition of the image to be detected to obtain target images belonging to the target category in the image to be detected, it specifically performs the following operations:

[0171] The image to be detected is identified to obtain the probability that the image to be detected belongs to multiple reference categories.

[0172] The probabilities are arranged in descending order, and the probability at the top is taken as the target probability. The reference category corresponding to the target probability is determined as the image category of the image to be detected.

[0173] If the image category is the target category, then the images to be detected that belong to the target category are determined as target images.

[0174] In one embodiment, when the processor 110 performs the detection of the main content in the target image to obtain the position information of the main image corresponding to the main content in the target image, it specifically performs the following operations:

[0175] Obtain time information, identity information of transaction objects, and detailed information of transaction items from the target image, and determine the time information, identity information of transaction objects, and detailed information of transaction items as the main content of the image;

[0176] Detect the position information of the subject image corresponding to the main content in the target image.

[0177] In one embodiment, when the processor 110 performs edge detection and integrity detection on the subject image based on the location information to determine the integrity detection result of the target image, it specifically performs the following operations:

[0178] Obtain edge information of the main image, and determine the image feature vector of the main image based on the edge information and the position information;

[0179] The similarity between the image feature vector and the first reference feature vector and the second reference feature vector is obtained respectively. The completeness result indicated by the first reference feature vector is complete, and the completeness result indicated by the second reference feature vector is incomplete.

[0180] The similarities are arranged in descending order, and the similarity at the top of the list is determined as the target similarity. The target reference feature vector corresponding to the target similarity is determined from the first reference feature vector and the second reference feature vector.

[0181] The integrity result indicated by the target feature vector is determined as the integrity detection result of the target image.

[0182] In one embodiment, when the processor 110 performs the operation of determining the image feature vector of the subject image based on the edge information and the position information, it specifically performs the following operations:

[0183] The image features of the main image are determined based on the edge information and the location information;

[0184] The image feature vector of the subject image is calculated based on the image features.

[0185] This specification also provides a computer program product that stores at least one instruction, which is loaded and executed by the processor to implement the image detection method described in the above embodiments.

[0186] Those skilled in the art will recognize that the functions described in the embodiments of this specification in one or more of the above examples can be implemented using hardware, software, firmware, or any combination thereof. When implemented in software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein communication media include any medium that facilitates the transfer of a computer program from one place to another. Storage media can be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0187] The above description is merely an optional embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification shall be included within the protection scope of this specification.

[0188] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

Claims

1. An image detection method, the method comprising: Acquire the image to be detected, and then acquire the target image belonging to the target category from the image to be detected; The main content in the target image is detected to obtain the position information of the main image corresponding to the main content in the target image; Obtain edge information of the main image, and determine the image feature vector of the main image based on the edge information and the position information; The similarity between the image feature vector and the first reference feature vector and the second reference feature vector is obtained respectively. The completeness result indicated by the first reference feature vector is complete, and the completeness result indicated by the second reference feature vector is incomplete. The similarities are arranged in descending order, and the similarity at the top of the list is determined as the target similarity. The target reference feature vector corresponding to the target similarity is determined from the first reference feature vector and the second reference feature vector. The integrity result indicated by the target reference feature vector is determined as the integrity detection result of the target image.

2. The method according to claim 1, wherein obtaining the target image belonging to the target category in the image to be detected comprises: The image to be detected is classified and identified to obtain the target image belonging to the target category in the image to be detected.

3. The method according to claim 2, wherein classifying and recognizing the image to be detected to obtain a target image belonging to the target category in the image to be detected includes: The image to be detected is identified to obtain the probability that the image to be detected belongs to multiple reference categories. The probabilities are arranged in descending order, and the probability at the top is taken as the target probability. The reference category corresponding to the target probability is determined as the image category of the image to be detected. If the image category is the target category, then the images to be detected that belong to the target category are determined as target images.

4. The method according to claim 1, wherein detecting the main content in the target image to obtain the position information of the main image corresponding to the main content in the target image includes: Obtain time information, identity information of transaction objects, and detailed information of transaction items from the target image, and determine the time information, identity information of transaction objects, and detailed information of transaction items as the main content of the image; Detect the position information of the subject image corresponding to the main content in the target image.

5. The method according to claim 1, wherein determining the image feature vector of the subject image based on the edge information and the position information comprises: The image features of the main image are determined based on the edge information and the location information; The image feature vector of the subject image is calculated based on the image features.

6. A method for training a detection model, the method comprising: Obtain sample images of the target category, and generate positive sample images and negative sample images based on the sample images. The positive sample images are images with complete content, and the negative sample images are images with incomplete content. An initial detection model is used to calculate the positive sample image and the negative sample image to obtain the first feature vector corresponding to the positive sample image and the second feature vector corresponding to the negative sample image. Calculate the contrastive loss function based on the first feature vector and the second feature vector; The initial detection model is adjusted based on the contrast loss function to obtain the trained detection model; The detection model is applied to an image detection method, which includes: acquiring an image to be detected; acquiring a target image belonging to a target category in the image to be detected; using the detection model to detect the main content in the target image, obtaining the position information of the main image corresponding to the main content in the target image, acquiring the edge information of the main image, and determining the image feature vector of the main image based on the edge information and the position information; acquiring the similarity between the image feature vector and a first reference feature vector and a second reference feature vector, wherein the first reference feature vector indicates a completeness result and the second reference feature vector indicates an incompleteness result; arranging the similarities in descending order, determining the first similarity as the target similarity, and determining the target reference feature vector corresponding to the target similarity among the first reference feature vector and the second reference feature vector; and determining the completeness result indicated by the target reference feature vector as the completeness detection result of the target image.

7. The method according to claim 6, wherein generating positive sample images and negative sample images based on the sample images comprises: The sample images are enhanced to obtain positive and negative sample images.

8. The method according to claim 6, wherein the step of using an initial detection model to calculate the positive sample image and the negative sample image to obtain a first feature vector corresponding to the positive sample image and a second feature vector corresponding to the negative sample image comprises: The initial detection model is used to detect the positive subject content in the positive sample image to obtain the first position information of the positive subject image corresponding to the positive subject content in the positive sample image; The first feature vector corresponding to the positive sample image is obtained by calculating the positive subject image based on the first location information; The initial detection model is used to detect the negative subject content in the negative sample image to obtain the second position information of the negative subject image corresponding to the negative subject content in the negative sample image; The negative subject image is calculated based on the second location information to obtain the second feature vector corresponding to the negative sample image.

9. An image detection apparatus, the apparatus comprising: An image acquisition module is used to acquire an image to be detected, and to acquire a target image belonging to the target category from the image to be detected. The first detection module is used to detect the main content in the target image and obtain the position information of the main image corresponding to the main content in the target image; The second acquisition module is used to acquire edge information of the main image and determine the image feature vector of the main image based on the edge information and the position information. The similarity between the image feature vector and the first reference feature vector and the second reference feature vector is obtained respectively. The completeness result indicated by the first reference feature vector is complete, and the completeness result indicated by the second reference feature vector is incomplete. The similarities are arranged in descending order, and the similarity at the top of the list is determined as the target similarity. The target reference feature vector corresponding to the target similarity is determined from the first reference feature vector and the second reference feature vector. The integrity result indicated by the target reference feature vector is determined as the integrity detection result of the target image.

10. A detection model training device, the device comprising: The image acquisition module is used to acquire sample images of the target type, and generate positive sample images and negative sample images based on the sample images. The positive sample images are images with complete content, and the negative sample images are images with incomplete content. The vector calculation module is used to calculate the positive sample image and the negative sample image using the initial detection model to obtain the first feature vector corresponding to the positive sample image and the second feature vector corresponding to the negative sample image; The loss calculation module is used to calculate a contrastive loss function based on the first feature vector and the second feature vector; The model adjustment module is used to adjust the initial detection model based on the contrast loss function to obtain the trained detection model; The detection model is applied to an image detection method, which includes: acquiring an image to be detected; acquiring a target image belonging to a target category in the image to be detected; using the detection model to detect the main content in the target image, obtaining the position information of the main image corresponding to the main content in the target image, acquiring the edge information of the main image, and determining the image feature vector of the main image based on the edge information and the position information; acquiring the similarity between the image feature vector and a first reference feature vector and a second reference feature vector, wherein the first reference feature vector indicates a completeness result and the second reference feature vector indicates an incompleteness result; arranging the similarities in descending order, determining the first similarity as the target similarity, and determining the target reference feature vector corresponding to the target similarity among the first reference feature vector and the second reference feature vector; and determining the completeness result indicated by the target reference feature vector as the completeness detection result of the target image.

11. A computer storage medium storing a plurality of instructions adapted for loading by a processor and executing the method steps of any one of claims 1 to 5 or 6 to 8.

12. A computer program product storing at least one instruction, the at least one instruction being loaded by a processor and executing the method steps as claimed in any one of claims 1 to 5 or 6 to 8.

13. An electronic device comprising: A processor and a memory; wherein the memory stores a computer program adapted to be loaded by the processor and executed the method steps as claimed in any one of claims 1 to 5 or 6 to 8.

Citation Information

Patent Citations

  • Image shooting integrity judgment method and device

    CN115019152A

  • Industrial defect sample detection method and system based on image representation

    CN115713484A