Image recognition method and device, electronic equipment and computer readable storage medium
Through the pre-trained image recognition model combined with the comparison learning method, the brand and model of the image shooting device is recognized, which solves the equipment recognition problem in image authenticity verification and achieves high accuracy and robust image recognition effect.
Patent Information
- Application Number
- CN202411338384.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-01-14
AI Technical Summary
With the development of artificial intelligence content generation technology, the authenticity verification of images has become increasingly important, but the existing technology is difficult to effectively identify the brand and model of image shooting equipment, affecting the authenticity verification of images.
By obtaining the image to be recognized and based on the pre-trained image recognition model, the brand and model of the device that captured the image are determined. Through feature extraction and feature recognition modules, combined with comparative learning technology, the model is trained to identify features of images captured by the same brand and model, different models of the same brand, and devices of different brands.
It realizes accurate identification of the brand and model of image equipment, improves the accuracy and robustness of image recognition, and provides important data support for the authenticity verification of images.
Smart Images

Figure CN119313951A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and more specifically, to an image recognition method, device, electronic device and computer-readable storage medium. Background Art
[0002] With the continuous development of science and technology, image processing technology, especially artificial intelligence generated content (AIGC) technology, has become more and more perfect. AI generated content technology has brought great convenience to users in creating images, but the development of this technology has undoubtedly reduced the cost of image forgery, so the authenticity verification of images has become more and more important. Summary of the invention
[0003] In view of this, embodiments of the present invention provide an image recognition method, device, electronic device and computer-readable storage medium to simultaneously identify the brand and model of the device that took the image based on the image to be identified and a pre-trained image recognition model, thereby providing important data support for image authenticity verification.
[0004] In a first aspect, an embodiment of the present invention provides an image recognition method, the method comprising:
[0005] Obtain an image to be recognized;
[0006] According to the image to be identified, based on a pre-trained image recognition model, the brand information and model information of the device to be identified are determined, the device to be identified is the device that photographed the image to be identified, the image recognition model is obtained through training based on a training sample set, the training sample set includes multiple sample images and sample brand information and sample model information of each sample image, and each sample image is photographed by a device of the same brand and model, a device of the same brand but different models, and a device of different brands.
[0007] Optionally, the image recognition model includes a feature extraction module and a feature recognition module, and the image recognition model is trained based on the following method:
[0008] Acquire a first image, a second image, a third image, and a fourth image from the training sample set, wherein the first image and the second image are taken by devices of the same brand and model, the first image and the third image are taken by devices of the same brand but different models, and the first image and the fourth image are taken by devices of different brands;
[0009] Acquire, based on the feature extraction module, image features of the first image, image features of the second image, image features of the third image, and image features of the fourth image;
[0010] The first image is combined with at least one of the second image, the third image and the fourth image into an image pair according to a recognition target of the image recognition model, wherein the recognition target is a device brand or a device model;
[0011] The image pair features of each of the image pairs are used as inputs of the contrast learning module, the image features of the first image, the image features of the second image, the image features of the third image and the image features of the fourth image are used as inputs of the feature recognition module, and the first device information, the second device information, the third device information and the fourth device information are used as outputs of the feature recognition module to train the contrast learning module and the image recognition model until the classification loss function of the image recognition model and the contrast loss function corresponding to the recognition target converge, the first device information is the sample brand information and the sample model information of the first image, the second device information is the sample brand information and the sample model information of the second image, the third device information is the sample brand information and the sample model information of the third image, and the fourth device information includes the sample brand information and the sample model information of the fourth image.
[0012] Optionally, forming an image pair with the first image and at least one of the second image, the third image, and the fourth image according to the recognition target of the image recognition model comprises:
[0013] In response to the recognition target being a device model, determining the second image as a positive sample image, and determining the third image as a negative sample image;
[0014] Determine the first image and the second image as a positive sample image pair;
[0015] The first image and the third image are determined as a negative sample image pair.
[0016] Optionally, forming an image pair with the first image and at least one of the second image, the third image and the fourth image according to the recognition target of the image recognition model comprises:
[0017] In response to the recognition target being a device brand, determining both the second image and the third image as positive sample images, and determining the fourth image as a negative sample image;
[0018] Determine the first image and the second image as a positive sample image pair;
[0019] Determine the first image and the third image as a positive sample image pair;
[0020] The first image and the fourth image are determined as a negative sample image pair.
[0021] Optionally, acquiring the first image, the second image, the third image and the fourth image from the training sample set includes:
[0022] Randomly processing at least part of the sample images in the training sample set to obtain the processed training sample set;
[0023] The first image, the second image, the third image and the fourth image are acquired from the processed training sample set.
[0024] Optionally, the random processing includes at least one of random rotation, random flipping, random scaling, random compression and random cropping.
[0025] Optionally, acquiring the image features of the first image, the image features of the second image, the image features of the third image, and the image features of the fourth image based on the feature extraction module includes:
[0026] Acquire metadata information of the first image, metadata information of the second image, metadata information of the third image, and metadata information of the fourth image;
[0027] Acquire, based on the feature extraction module, image features of the first image according to the first image and metadata information of the first image;
[0028] Acquire image features of the second image based on the feature extraction module according to the second image and metadata information of the second image;
[0029] Acquiring image features of the third image based on the feature extraction module according to the third image and metadata information of the third image;
[0030] According to the fourth image and metadata information of the fourth image, image features of the fourth image are acquired based on the feature extraction module.
[0031] Optionally, determining the brand information and model information of the device to be identified based on the image to be identified and a pre-trained image recognition model includes:
[0032] Acquire metadata information of the image to be identified;
[0033] The brand information and the model information are acquired based on the image recognition model according to the image to be recognized and the metadata information of the image to be recognized.
[0034] In a second aspect, an embodiment of the present invention provides an image recognition device, the device comprising:
[0035] An image acquisition unit, used for acquiring an image to be recognized;
[0036] An image recognition unit is used to determine the brand information and model information of a device to be identified according to the image to be identified and based on a pre-trained image recognition model. The device to be identified is a device that photographs the image to be identified. The image recognition model is obtained through training based on a training sample set. The training sample set includes multiple sample images and sample brand information and sample model information of each sample image. Each sample image is photographed by a device of the same brand and model, a device of the same brand but different models, and a device of different brands.
[0037] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement a method as described in any one of the first aspects.
[0038] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method as described in any one of the first aspects is implemented.
[0039] In a fifth aspect, an embodiment of the present invention provides a computer program product, wherein the computer program product comprises a computer program / instructions, and when the computer program / instructions are executed by a processor, the method as described in any one of the first aspects is implemented.
[0040] After acquiring the image to be identified, the embodiment of the present invention determines the brand and model of the device that photographed the image to be identified according to the pre-trained image recognition model. In the embodiment of the present invention, the training samples used to train the image recognition model include multiple sample images and the brand and model of each sample image, and some of the sample images are photographed by devices of the same brand and model, some are photographed by devices of the same brand but different models, and some are photographed by devices of different brands. Therefore, the image recognition model can accurately and simultaneously identify the brand and model of the device that photographed the image based on the image, providing important data support for image authenticity verification. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] The above and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings, in which:
[0042] Figure 1 is a flow chart of an image recognition method according to an embodiment of the present invention;
[0043] Figure 2 is a flowchart of training an image recognition model in the method of an embodiment of the present invention;
[0044] Figure 3 is a schematic diagram of the structure of an image recognition model according to an embodiment of the present invention;
[0045] Figure 4 is a schematic diagram of an image recognition device according to an embodiment of the present invention;
[0046] Figure 5 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0047] The present application is described below based on embodiments, but the present application is not limited to these embodiments. In the detailed description of the present application below, some specific details are described in detail. It is possible for those skilled in the art to fully understand the present application without the description of these details. In order to avoid confusing the essence of the present application, known methods, processes, flows, components and circuits are not described in detail.
[0048] In addition, persons of ordinary skill in the art will appreciate that the drawings provided herein are for illustration purposes and are not necessarily drawn to scale.
[0049] Unless the context clearly requires otherwise, the words "include", "comprising" and similar words throughout the application should be interpreted as including rather than exclusive or exhaustive; that is, the meaning is "including but not limited to".
[0050] In the description of this application, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" is two or more.
[0051] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0052] As social networks and media sharing platforms become more popular, people are increasingly using them to share images. AIGC technology means that users no longer need to take images with their devices, but can use AIGC software to generate AI images that suit their preferences. However, this also provides convenience for criminals to engage in illegal activities, such as posting AI character images on social networks and media sharing platforms to spread rumors and slander others, and using AI character images to engage in illegal activities such as telecommunications fraud. With the continuous development of AIGC technology, AI images are becoming more and more similar to real images taken by devices, so image authenticity verification is becoming more and more important.
[0053] In the embodiment of the present invention, the execution subject is a server as an example for description, but those skilled in the art can easily understand that the embodiment of the present invention is also applicable to other execution subjects, such as a mobile terminal, etc.
[0054] Figure 1 FIG. 1 is a flow chart of an image recognition method according to an embodiment of the present invention. Figure 1 As shown, the method of this embodiment includes the following steps:
[0055] Step S101, obtaining an image to be recognized.
[0056] In this step, the server may determine the acquired image as the image to be identified according to different application scenarios. For example, when the server is a server on a social network or media sharing platform, the server may, with the authorization of the user, use the image uploaded by the user terminal to the social network or media sharing platform as the image to be identified; for another example, when the server is a server on an e-commerce platform, the server may determine the image of the proof of delivery uploaded by the distribution terminal as the image to be identified.
[0057] Step S102: determining the brand information and model information of the device to be identified according to the image to be identified and based on a pre-trained image recognition model.
[0058] Different models of devices, such as mobile phones, tablets, cameras, and camcorders, often have differences in image sensors, lenses, or camera parameters, and these differences will eventually appear in the captured images. Therefore, in this step, the server can use the image to be recognized as the input of the pre-trained image recognition model to obtain the device that captured the image to be recognized, that is, the brand information and model information of the device to be recognized.
[0059] The image recognition model of the embodiment of the present invention is a multi-task learning model that can simultaneously recognize brand information and model information based on the image features of the image to be recognized. The image recognition model is trained by relying on sample images taken by devices of the same brand and model, devices of the same brand but different models, and devices of different brands. Therefore, it can fully learn the similarities and differences between devices in terms of image color, exposure, noise, etc., thereby improving the accuracy and robustness of image recognition.
[0060] The image recognition model mainly includes a feature extraction module and a feature recognition module. Among them, the feature extraction module is used to extract the features of the image to be recognized. In order to better realize feature extraction, the feature extraction module can be a deep neural network. According to actual needs, the feature extraction module can further be CNN (Convolutional Neural Networks), convnext_base.fb_in22k, EfficientNet and modules based on EfficientNet, ResNet and modules based on ResNet, ViT (Vision Transformer) and modules based on ViT, etc., which are not limited in this embodiment.
[0061] The feature recognition module is used to determine the brand information and model information of the device to be identified based on the features of the image to be identified. It is a dual-branch module. The feature recognition module mainly includes a convolutional layer and a fully connected layer. The number of convolutional layers and fully connected layers can be set according to actual needs, and this embodiment does not impose any restrictions. The two branch heads of the image recognition module are respectively used to determine the brand information or model information of the device to be identified. These two branch heads can share part of the convolutional layer and / or the fully connected layer, thereby reducing the training cost of the model.
[0062] According to actual needs, the image recognition model may also include other modules, such as a feature normalization layer, etc., which is not limited in this embodiment.
[0063] In order to improve the recognition ability of the image recognition model, this embodiment trains the image recognition model by contrastive learning. Contrastive learning is a method for optimizing the feature representation of the model by maximizing the similarity between similar samples or minimizing the distance between dissimilar samples. It can make images taken by devices of the same brand or model more compact in the feature space, and make images taken by devices of different brands or models more dispersed in the feature space, so it can effectively improve the representation ability of device fingerprints.
[0064] Furthermore, the contrastive learning in this embodiment is a multi-level contrastive strategy, that is, hierarchical contrastive learning is performed on images obtained after multiple random cropping of the same image, images taken by different devices of the same brand and model, images taken by devices of the same brand but different models, and images taken by devices of different brands.
[0065] Figure 2 FIG. 1 is a flowchart of the method for training an image recognition model in an embodiment of the present invention. Figure 2 As shown, the method of this embodiment includes the following steps:
[0066] Step S201: Acquire a first image, a second image, a third image, and a fourth image from a training sample set.
[0067] In this embodiment, the training sample set includes sample images taken by devices of the same brand and model, devices of the same brand but different models, and devices of different brands, and the brand information (also known as sample brand information) and model information (also known as sample model information) of each sample image.
[0068] In this step, the server can select any image from the training sample set as the first image. The first image is an anchor image, that is, a reference image of the image recognition model. After determining the first image, the server can obtain any image from the training sample set that is taken by a device of the same brand and model as the first image as the second image, obtain any image from the training sample set that is taken by a device of the same brand but different model as the first image as the third image, and obtain any image from the training sample set that is taken by a device of a different brand than the first image as the fourth image.
[0069] For example, the first image is taken by a device of brand A, model B. The server can obtain an image taken by a device of brand A, model B as the second image, an image taken by a device of brand A, model C as the third image, and an image taken by a device of brand B as the fourth image.
[0070] In order to enhance the recognition capability of the image recognition model, the second image and the first image may be two images obtained by randomly cropping the same sample image in the training sample set, or may be different sample images taken by different devices of the same brand and model.
[0071] Optionally, in order to enhance the diversity of the training sample set, after obtaining the training sample set, the server may select at least part of the sample images from the training sample set, and perform random processing on the at least part of the sample images to obtain a processed training sample set. Then, the first image, the second image, the third image, and the fourth image are obtained from the processed training sample set. Furthermore, in order to facilitate random processing of the sample images, the server may crop the sample images into images of the same pixels, such as 512*512, and then perform random processing on the sample images.
[0072] According to actual needs, the server can randomly process the sample image in various ways, such as randomly rotating the sample image by a certain angle (that is, random rotation), flipping the sample image vertically or horizontally (that is, random flipping), randomly enlarging or reducing the sample image (that is, random scaling), compressing the sample image based on a predetermined image compression algorithm (such as run-length coding, entropy coding, chroma sampling, transform coding, etc.) (that is, random compression), randomly cropping a sample image into multiple sample images (that is, random cropping), etc., which are not limited in this embodiment.
[0073] It is easy to understand that in this embodiment, the number of the first image, the second image, the third image and the fourth image can be one or more, and this embodiment does not limit it.
[0074] Step S202: acquiring image features of the first image, image features of the second image, image features of the third image, and image features of the fourth image based on a feature extraction module.
[0075] In this step, the server may input the first image, the second image, the third image, and the fourth image into a feature extraction module to obtain image features of the first image, the second image, the third image, and the fourth image.
[0076] Step S203: forming an image pair with the first image and at least one of the second image, the third image and the fourth image according to the recognition target of the image recognition model.
[0077] In this embodiment, the image recognition model is used to identify the device brand and device model, so the recognition target is the device brand or device model. Different recognition targets lead to differences between the positive samples and negative samples used to train the image recognition model. Specifically, if the recognition target of the image recognition model is the device model, the second image taken based on a device of the same brand and model as the first image as the anchor image is a positive sample, and the third sample taken based on a device of the same brand but different models as the first image is a negative sample; if the recognition target of the image recognition model is the device brand, the second image and the third image taken based on a device of the same brand as the first image as the anchor image are both positive samples, and the fourth sample taken based on a device of a different brand than the first image is a negative sample.
[0078] In contrastive learning, common contrastive loss functions include contrastive loss, triplet loss, structured loss, quadruple loss, N-pair loss, etc.
[0079] In this embodiment, contrast loss is used as an example for explanation. If the recognition target of the image recognition model is the device model, the server can form a positive sample image pair with the first image and the second image, and form a negative sample image pair with the first image and the third image; if the recognition target of the image recognition model is the device brand, the server can form a positive sample image pair with the first image and the second image, form a positive sample image pair with the first image and the third image, and form a negative sample image pair with the first image and the fourth image.
[0080] It is easy to understand that in this embodiment, step S202 and step S203 can be executed simultaneously or one after another, and this embodiment does not limit this.
[0081] Step S204, using the image pair features of each image pair as the input of the contrast learning module, using the image features of the first image, the image features of the second image, the image features of the third image and the image features of the fourth image as the input of the feature recognition module, and using the first device information, the second device information, the third device information and the fourth device information as the output of the feature recognition module to train the contrast learning module and the image recognition model until the classification loss function of the image recognition model and the contrast loss function corresponding to the recognition target converge.
[0082] In this embodiment, the sample model information and sample brand information of each sample image may be represented in a label sequence. Specifically, the server may set the element value corresponding to the sample model information of the sample image in the label sequence to 1, and set other elements in the label sequence to 0.
[0083] For example, the sample brand information of image P1 is brand F. The server can set the element value corresponding to brand F in the label sequence corresponding to the sample brand information, for example, the 6th element to 1, and set other elements to 0, so that the label sequence corresponding to the sample brand information of image P1 is (0, 0, 0, 0, 1, 0, …, 0), where the number of 0s is the total number of device brands in the training sample set - 1.
[0084] According to actual needs, during the training process of the image recognition model, one or two contrast learning modules can be set, that is, one contrast learning module uses both the device brand and the device model as the recognition target, or one contrast learning module uses the device brand as the recognition target, and the other contrast learning module uses the device model as the recognition target. In addition, the server can train the feature extraction module and the feature recognition module in the image recognition model at the same time, or they can be trained separately, that is, first train the feature extraction module and the contrast learning module until the contrast loss function of the recognition target, that is, the contrast loss function of the device brand and the contrast loss function of the device model converge, and then train the trained feature extraction module, the trained contrast learning module and the feature recognition module through transfer learning until the contrast loss function of the recognition target and the classification loss function of the image recognition model, that is, the classification loss function of the device brand and the classification loss function of the device model converge.
[0085] In this step, a comparative learning module is set up, and the feature extraction module and the feature recognition module are trained simultaneously as an example. The server can input the image features of the first image, the image features of the second image, the image features of the third image, and the image features of the fourth image into the feature recognition module at the same time, and use the sample brand information and sample model information of the first image (that is, the first device information), the sample brand information and sample model information of the second image (that is, the second device information), the sample brand information and sample model information of the third image (that is, the third device information), and the sample brand information and sample model information of the fourth image (that is, the fourth device information) as the output of the feature recognition module, and input the image pair features of each image pair into the comparative learning module, and train the image recognition model and the comparative learning module simultaneously until each loss function converges. Contrastive loss L c It can be expressed by the following formula:
[0086]
[0087] Among them, n represents the total number of sample pairs, y i,j Indicates whether the devices that captured image i and image j in the image pair are of the same model or brand, d i,jIt represents the distance between image i and image j in the feature space, which can be expressed by cosine distance, Euclidean distance, etc. m is the preset value of margin distance, max(0,md i,j ) means 0 and (md i,j ) is the maximum value among .
[0088] According to actual settings, the classification loss function of the image recognition model can be a cross-entropy loss function (Cross-Entropy Loss), a weighted cross-entropy loss function (Weighted Cross-Entropy Loss), a focal loss function (Focal Loss), etc., which is not limited in this embodiment.
[0089] Figure 3 Schematic diagram of the structure of the image recognition model of the embodiment of the present invention. Figure 3 As shown, in the training stage of the image recognition model, the server can input the images 30, namely the first image, the second image, the third image, and the fourth image, into the feature extraction module 32 of the image recognition model 31, and input the features of the image 30 output by the feature extraction module 32 into the feature recognition module 33, and use the sample brand information and the sample model information of the image 30 as the output of the feature recognition module 33, and determine the image pair 34 according to the device brand T1 and the device model T2 at the same time, and then input the image feature pair into the contrast learning module 35 according to the image pair 34, and train the feature extraction module 32, the feature recognition module 33 and the contrast learning module 35 simultaneously until the classification loss function of the device brand T1, the contrast loss function of the device brand T1, the classification loss function of the device model T2 and the classification loss function of the device model T2 converge.
[0090] Therefore, the embodiment of the present invention effectively reduces the training cost of the image recognition model through comparative learning and multi-task learning, and improves the recognition ability of the image recognition model, thereby more accurately identifying the brand information and model information of the image to be recognized.
[0091] According to the actual settings, after obtaining the brand information and model information of the image to be identified, the server can verify the authenticity of the image to be identified in various ways. For example, when the image to be identified is an image of a proof of delivery of an item, the server can obtain the brand and model of the delivery terminal that uploaded the image to be identified. If the brand of the delivery terminal is inconsistent with the brand information of the item delivery image and / or the model of the delivery terminal is inconsistent with the model information of the item delivery image, the server can determine that the image to be identified was not taken by the delivery terminal that uploaded the image to be identified, and therefore can determine that the authenticity of the image to be identified is low.
[0092] After acquiring the image to be identified, the embodiment of the present invention determines the brand and model of the device that photographed the image to be identified according to the pre-trained image recognition model. In the embodiment of the present invention, the training samples used to train the image recognition model include multiple sample images and the brand and model of each sample image, and some of the sample images are photographed by devices of the same brand and model, some are photographed by devices of the same brand but different models, and some are photographed by devices of different brands. Therefore, the image recognition model can accurately and simultaneously identify the brand and model of the device that photographed the image based on the image, providing important data support for image authenticity verification.
[0093] Figure 4 Schematic diagram of an image recognition device according to an embodiment of the present invention. Figure 4 As shown, the image recognition device of this embodiment includes an image acquisition unit 401 and an image recognition unit 402 .
[0094] Among them, the image acquisition unit 401 is used to acquire the image to be identified; the image recognition unit 402 is used to determine the brand information and model information of the device to be identified based on the image to be identified and a pre-trained image recognition model. The device to be identified is a device that shoots the image to be identified. The image recognition model is obtained by training based on a training sample set. The training sample set includes multiple sample images and sample brand information and sample model information of each sample image. Each sample image is shot by a device of the same brand and model, a device of the same brand but different models, and a device of different brands.
[0095] After acquiring the image to be identified, the embodiment of the present invention determines the brand and model of the device that photographed the image to be identified according to the pre-trained image recognition model. In the embodiment of the present invention, the training samples used to train the image recognition model include multiple sample images and the brand and model of each sample image, and some of the sample images are photographed by devices of the same brand and model, some are photographed by devices of the same brand but different models, and some are photographed by devices of different brands. Therefore, the image recognition model can accurately and simultaneously identify the brand and model of the device that photographed the image based on the image, providing important data support for image authenticity verification.
[0096] Figure 5 Schematic diagram of an electronic device according to an embodiment of the present invention. In this embodiment, the electronic device 5 includes a server, a terminal, etc. Figure 5As shown, the electronic device 5: includes at least one processor 501; and a memory 502 connected to the at least one processor 501 for communication; and a communication component 503 connected to the scanning device for communication, and the communication component 503 receives and sends data under the control of the processor 501; wherein the memory 502 stores instructions that can be executed by at least one processor 501, and the instructions are executed by at least one processor 501 to implement the above-mentioned image recognition method.
[0097] Specifically, the electronic device includes: one or more processors 501 and a memory 502, Figure 5 A processor 501 is taken as an example. The processor 501 and the memory 502 may be connected via a bus or other means. Figure 5 In the example, the bus connection is used. The memory 502 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The processor 501 executes various functional applications and data processing of the device by running the non-volatile software programs, instructions and modules stored in the memory 502, that is, realizing the above-mentioned image recognition method.
[0098] The memory 502 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store a list of options, etc. In addition, the memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 502 may optionally include a memory remotely arranged relative to the processor 501, and these remote memories may be connected to an external device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0099] One or more modules are stored in the memory 502 , and when executed by one or more processors 501 , the image recognition method in any of the above method embodiments is executed.
[0100] The above-mentioned product can execute the method provided in the embodiment of the present application, and has the functional modules and beneficial effects corresponding to the execution method. For technical details not fully described in this embodiment, please refer to the method provided in the embodiment of the present application.
[0101] After acquiring the image to be identified, the embodiment of the present invention determines the brand and model of the device that photographed the image to be identified according to the pre-trained image recognition model. In the embodiment of the present invention, the training samples used to train the image recognition model include multiple sample images and the brand and model of each sample image, and some of the sample images are photographed by devices of the same brand and model, some are photographed by devices of the same brand but different models, and some are photographed by devices of different brands. Therefore, the image recognition model can accurately and simultaneously identify the brand and model of the device that photographed the image based on the image, providing important data support for image authenticity verification.
[0102] Another embodiment of the present invention relates to a non-volatile storage medium for storing a computer-readable program, wherein the computer-readable program is used for a computer to execute part or all of the above method embodiments.
[0103] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0104] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. An image recognition method, characterized in that: The method comprises: Obtain an image to be recognized; According to the image to be identified, based on a pre-trained image recognition model, the brand information and model information of the device to be identified are determined, the device to be identified is the device that photographed the image to be identified, the image recognition model is obtained through training based on a training sample set, the training sample set includes multiple sample images and sample brand information and sample model information of each sample image, and each sample image is photographed by a device of the same brand and model, a device of the same brand but different models, and a device of different brands.
2. The method according to claim 1, characterized in that The image recognition model includes a feature extraction module and a feature recognition module, and the image recognition model is trained based on the following method: Acquire a first image, a second image, a third image, and a fourth image from the training sample set, wherein the first image and the second image are taken by devices of the same brand and model, the first image and the third image are taken by devices of the same brand but different models, and the first image and the fourth image are taken by devices of different brands; Acquire, based on the feature extraction module, image features of the first image, image features of the second image, image features of the third image, and image features of the fourth image; The first image is combined with at least one of the second image, the third image and the fourth image into an image pair according to a recognition target of the image recognition model, wherein the recognition target is a device brand or a device model; The image pair features of each of the image pairs are used as inputs of the contrast learning module, the image features of the first image, the image features of the second image, the image features of the third image and the image features of the fourth image are used as inputs of the feature recognition module, and the first device information, the second device information, the third device information and the fourth device information are used as outputs of the feature recognition module to train the contrast learning module and the image recognition model until the classification loss function of the image recognition model and the contrast loss function corresponding to the recognition target converge, the first device information is the sample brand information and the sample model information of the first image, the second device information is the sample brand information and the sample model information of the second image, the third device information is the sample brand information and the sample model information of the third image, and the fourth device information includes the sample brand information and the sample model information of the fourth image.
3. The method according to claim 2, characterized in that Combining the first image with at least one of the second image, the third image, and the fourth image into an image pair according to the recognition target of the image recognition model includes: In response to the recognition target being a device model, determining the second image as a positive sample image, and determining the third image as a negative sample image; Determine the first image and the second image as a positive sample image pair; The first image and the third image are determined as a negative sample image pair.
4. The method according to claim 2, characterized in that: The step of combining the first image with at least one of the second image, the third image, and the fourth image into an image pair according to the recognition target of the image recognition model comprises: In response to the recognition target being a device brand, determining both the second image and the third image as positive sample images, and determining the fourth image as a negative sample image; Determine the first image and the second image as a positive sample image pair; Determine the first image and the third image as a positive sample image pair; The first image and the fourth image are determined as a negative sample image pair.
5. The method according to claim 2, characterized in that: The acquiring the first image, the second image, the third image and the fourth image from the training sample set comprises: Randomly processing at least part of the sample images in the training sample set to obtain the processed training sample set; The first image, the second image, the third image and the fourth image are acquired from the processed training sample set.
6. The method according to claim 5, characterized in that The random processing includes at least one of random rotation, random flipping, random scaling, random compression and random cropping.
7. The method according to claim 2, characterized in that The acquiring, based on the feature extraction module, the image features of the first image, the image features of the second image, the image features of the third image, and the image features of the fourth image comprises: Acquire metadata information of the first image, metadata information of the second image, metadata information of the third image, and metadata information of the fourth image; Acquire, based on the feature extraction module, image features of the first image according to the first image and metadata information of the first image; Acquire image features of the second image based on the feature extraction module according to the second image and metadata information of the second image; Acquiring image features of the third image based on the feature extraction module according to the third image and metadata information of the third image; According to the fourth image and metadata information of the fourth image, image features of the fourth image are acquired based on the feature extraction module.
8. The method according to claim 1, characterized in that: Determining the brand information and model information of the device to be identified based on the image to be identified and a pre-trained image recognition model includes: Acquire metadata information of the image to be identified; The brand information and the model information are acquired based on the image recognition model according to the image to be recognized and the metadata information of the image to be recognized.
9. An image recognition device, characterized in that: The device comprises: An image acquisition unit, used for acquiring an image to be recognized; An image recognition unit is used to determine the brand information and model information of a device to be identified according to the image to be identified and based on a pre-trained image recognition model. The device to be identified is a device that photographs the image to be identified. The image recognition model is obtained through training based on a training sample set. The training sample set includes multiple sample images and sample brand information and sample model information of each sample image. Each sample image is photographed by a device of the same brand and model, a device of the same brand but different models, and a device of different brands.
10. An electronic device comprising a memory and a processor, characterized in that: The memory is used to store one or more computer program instructions, wherein the one or more computer program instructions are executed by the processor to implement the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
12. A computer program product, characterized in that The computer program product comprises a computer program / instructions, which implement the method according to any one of claims 1 to 8 when executed by a processor.