Model training method, image classification method and related device

Through the feature extraction and deep clustering methods of the image processing model, combined with the self-supervised contrastive learning framework, the problem of difficult mining of sample feature correlations in image classification is solved, and the accuracy of image classification and the stability of the model are improved.

CN118657970APending Publication Date: 2024-09-17MASHANG CONSUMER FINANCE CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410347300.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-25
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

It is difficult for existing technologies to effectively mine the complex correlations between sample features in image classification, resulting in high model training costs and low accuracy, especially under unsupervised learning conditions.

Method used

Features are extracted from the image through the image processing model, model parameters are updated based on pairwise similarity and contextual similarity, the similarity between sample features and the association between different samples are considered, and a deep clustering method and a self-supervised contrastive learning framework are used Extract discriminative representation features.

Benefits of technology

It improves the accuracy of image classification and the model's ability to extract features from unlabeled samples, reduces training costs, and enhances the model's stability and ability to understand semantic information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118657970A
    Figure CN118657970A
Patent Text Reader

Abstract

The invention provides a model training method, an image classification method and a related device. The method comprises the following steps: performing feature extraction on a first image and a second image through an image processing model to obtain a first image feature of the first image and a second image feature of the second image; determining the pairwise similarity between the first image and the second image based on the similarity between the first image feature and the second image feature; determining context similarity between the first image and the second image based on the neighbor image set of the first image and the neighbor image set of the second image; and updating parameters of the image processing model based on the pairwise similarity and the contextual similarity. According to the invention, the accuracy of image classification can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to artificial intelligence technology, and in particular to a model training method, an image classification method and related devices. Background Art

[0002] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Machine Learning (ML) is the core of artificial intelligence, and mainly studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance.

[0003] Image classification is an important application direction of machine learning, which specifically involves multiple technologies such as image processing, feature extraction, deep clustering, and graph neural networks. For example, it can predict whether an image contains a face. When classifying images, images are usually processed accordingly through unsupervised learning methods. In order to improve the generalization ability of the model, clustering is a common method in traditional unsupervised methods to divide data sets into several categories. In the solutions provided by related technologies, image classification models are usually used to classify images. Therefore, training more accurate image classification models is a hot topic of research. Summary of the invention

[0004] The embodiments of the present application provide a model training method, an image classification method and related devices, which can train a more accurate image classification model to improve the accuracy of image classification.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] The present application provides a model training method, the method comprising:

[0007] Extracting features from the first image and the second image using an image processing model to obtain first image features of the first image and second image features of the second image;

[0008] determining a pairwise similarity between the first image and the second image based on a similarity between the first image feature and the second image feature;

[0009] determining contextual similarity between the first image and the second image based on a neighbor image set of the first image and a neighbor image set of the second image;

[0010] Parameters of the image processing model are updated based on the pairwise similarity and the contextual similarity.

[0011] The present application provides an image classification method, the method comprising:

[0012] Extract features of the input image through an image processing model to obtain image features corresponding to the input image, wherein the image processing model is trained by the model training method provided in an embodiment of the present application;

[0013] The image features are classified by a classifier to obtain the category to which the input image belongs.

[0014] The present application provides a model training device, including:

[0015] A feature extraction module, used to extract features from the first image and the second image through an image processing model to obtain a first image feature of the first image and a second image feature of the second image;

[0016] an acquisition module, which determines the pairwise similarity between the first image and the second image based on the similarity between the first image feature and the second image feature; and determines the contextual similarity between the first image and the second image based on the neighbor image set of the first image and the neighbor image set of the second image;

[0017] An updating module is used to update the parameters of the image processing model based on the pairwise similarity and the contextual similarity.

[0018] The present application provides an image classification device, including:

[0019] A feature extraction module, used to extract features of an input image through an image processing model to obtain image features corresponding to the input image, wherein the image processing model is trained by the model training method provided in an embodiment of the present application;

[0020] The image classification module is used to classify the image features through a classifier to obtain the category to which the input image belongs.

[0021] An embodiment of the present application provides an electronic device, including:

[0022] A memory for storing computer executable instructions;

[0023] The processor is used to implement the model training method provided in the embodiment of the present application or the image classification method provided in the embodiment of the present application when executing the computer executable instructions stored in the memory.

[0024] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions, which are used to implement the model training method provided by the embodiment of the present application or the image classification method provided by the embodiment of the present application when executed by a processor.

[0025] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the model training method provided by the embodiment of the present application or the image classification method provided by the embodiment of the present application is implemented.

[0026] The embodiments of the present application have the following beneficial effects:

[0027] The first image and the second image are subjected to feature extraction through an image processing model to obtain first image features corresponding to the first image and second image features corresponding to the second image, and based on the similarity between the first image features and the second image features, the pairwise similarity between the first image and the second image is determined, and based on the neighbor image set of the first image and the neighbor image set of the second image, the contextual similarity between the first image and the second image is determined, and then the parameters of the image processing model are updated based on the pairwise similarity and the contextual similarity, while considering the similarity between sample features and the association between different samples, so as to more effectively mine the association between sample features, and learn the contextual similarity through the image processing model, thereby further improving the accuracy of image classification using the image processing model. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a structural diagram of the model training system architecture provided in an embodiment of the present application;

[0029] Figure 2A is a first structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0030] Figure 2B is a second structural schematic diagram of an electronic device provided in an embodiment of the present application;

[0031] Figure 3A It is a first flow chart of the model training method provided in the embodiment of the present application;

[0032] Figure 3B It is a second flow chart of the model training method provided in the embodiment of the present application;

[0033] Figure 3C It is a third flow chart of the model training method provided in the embodiment of the present application;

[0034] Figure 3D It is a fourth flow chart of the model training method provided in the embodiment of the present application;

[0035] Figure 3E It is a fifth flow chart of the model training method provided in the embodiment of the present application;

[0036] Figure 3F It is a sixth flow chart of the model training method provided in the embodiment of the present application;

[0037] Figure 3G It is a seventh flow chart of the model training method provided in the embodiment of the present application;

[0038] Figure 3H It is an eighth flow chart of the model training method provided in the embodiment of the present application;

[0039] Fig. 3I It is a ninth flow chart of the model training method provided in the embodiment of the present application;

[0040] Figure 3J It is a tenth flow chart of the model training method provided in the embodiment of the present application;

[0041] Figure 3K This is the eleventh flow chart of the model training method provided in the embodiment of the present application;

[0042] Figure 4 It is a flowchart of the image classification method provided in the embodiment of the present application;

[0043] Figure 5 It is a schematic diagram of the model training principle provided in the embodiment of the present application;

[0044] Figure 6 This is a schematic diagram of the image classification principle provided in an embodiment of the present application. DETAILED DESCRIPTION

[0045] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0046] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0047] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described here can be implemented in an order other than that illustrated or described here.

[0048] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0049] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant national laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.

[0050] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0051] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0052] 1) The teacher model, also known as the image processing model, is used to extract image features so that the extracted image features include contextual semantic information.

[0053] 2) The student model is used to extract image features and update the parameters of the teacher model, and to update the parameters of the teacher model based on the updated student model to ensure the stability of model training.

[0054] 3) The first similarity is based on the asymmetric Jaccard similarity determined by the two reciprocal neighbor image sets, which is used to measure whether the common features of the intersection of the two reciprocal neighbor image sets are consistent with those of the first reciprocal neighbor image set.

[0055] 4) The second similarity is based on the asymmetric Jaccard similarity determined by the two reciprocal neighbor image sets, which is used to measure whether the common features of the intersection of the two reciprocal neighbor image sets are consistent with those of the second reciprocal neighbor image set.

[0056] 5) Neighbor image set: the nearest neighbor set of an image, that is, the neighbor image set contains images whose similarity with the image is greater than a similarity threshold.

[0057] 6) A reciprocal neighbor image set, which includes images that are neighbors of images in the neighbor image set of the image.

[0058] In the related art, the simple association between samples is learned based on the nearest neighbor, and the compactness within the category is learned, but the differences and complex associations between categories and subcategories are not learned, and it is difficult to mine the complex associations between samples. The contextual semantic similarity of the embodiment of the present application considers the similarity between sample features and the association between different samples at the same time, and can more effectively mine the association between sample features of the data set.

[0059] Based on the above analysis, the applicant found that the related art method of model training based on nearest neighbor learning of simple associations between samples cannot improve the accuracy of image classification. To address the above problem, the embodiments of the present application provide a model training method, an image classification method and related devices that can improve the accuracy of image classification.

[0060] The following describes an exemplary application of the electronic device provided in the embodiment of the present application. The device provided in the embodiment of the present application can be implemented as a terminal or a server. The following describes an exemplary application when the device is implemented as a server.

[0061] See also Figure 1 , Figure 1 It is a schematic diagram of the model training system architecture provided in an embodiment of the present application. To support a model training application, a terminal (terminal 400 is shown as an example) is connected to a server 200 via a network 300. The network 300 may be a wide area network or a local area network, or a combination of the two.

[0062] The terminal 400 is used to send the first image and the second image to the server 200 through the network 300. The server 200 is used to extract features of the first image and the second image through the image processing model to obtain first image features corresponding to the first image and second image features corresponding to the second image. Based on the similarity between the first image features and the second image features, the pairwise similarity between the first image and the second image is determined. Based on the neighbor image set of the first image and the neighbor image set of the second image, the contextual similarity between the first image and the second image is determined. The parameters of the image processing model are updated based on the pairwise similarity and the contextual similarity to obtain an updated image processing model. Then, the server 200 can receive the input image sent by the terminal 400, and extract features of the input image according to the image processing model to obtain image features corresponding to the input image, and classify the image features through a classifier, and send the category to which the obtained input image belongs to the terminal 400. The terminal 400 displays the category to which the obtained image belongs through a graphical interface 410.

[0063] The following describes an example in which the terminal 400 performs model training and extracts features of an input image according to an updated teacher model, and classifies the extracted image features by a classifier.

[0064] In some embodiments, terminal 400 can independently complete the model training task. For example, terminal 400 is used to obtain a first image and a second image, perform feature extraction on the first image and the second image through an image processing model to obtain first image features corresponding to the first image and second image features corresponding to the second image, determine the pairwise similarity between the first image and the second image based on the similarity between the first image features and the second image features, determine the contextual similarity between the first image and the second image based on the neighbor image set of the first image and the neighbor image set of the second image, update the parameters of the image processing model based on the pairwise similarity and the contextual similarity to obtain an updated image processing model, then, terminal 400 obtains an input image, and performs feature extraction on the input image according to the image processing model to obtain image features corresponding to the input image, and classifies the image features through a classifier to obtain the category to which the input image belongs, and displays the obtained category to which the input image belongs through a graphical interface 410.

[0065] In one implementation scenario, an image processing model is used to predict whether a face image is a frontal face image. The server or terminal may use the image processing model to extract features of the frontal face image and the side face image to obtain frontal face features and side face features. Based on the similarity between the frontal face features and the side face features, the pairwise similarity between the frontal face image and the side face image is determined. Based on the neighbor face set of the frontal face image and the neighbor face set of the side face image, the contextual similarity between the frontal face image and the side face image is determined. Since the neighbor face set of the frontal face image includes a frontal face image whose similarity to the frontal face image is greater than a similarity threshold, the side face image is The neighbor face set of the face image includes side face images whose similarity with the side face image is greater than a similarity threshold, so the context similarity includes global semantic face information for distinguishing whether the face image is a frontal face image or a side face image. The parameters of the image processing model are updated based on the pairwise similarity and the context similarity to obtain an updated image processing model. Then, an input image (for example, a frontal face image) is obtained, and features are extracted from the input image according to the image processing model to obtain facial features corresponding to the input image, and the facial features are classified by a classifier to obtain the category to which the input image belongs, which is a frontal face.

[0066] In an implementation scenario, an image processing model is used to predict whether a pedestrian image is a boy's image. The server or terminal can use the image processing model to extract features from the boy's image and the girl's image respectively to obtain boy's features and girl's features. Based on the similarity between the boy's features and the girl's features, the pairwise similarity between the boy's image and the girl's image is determined. Based on the boy's image neighboring boy image set and the girl's image neighboring girl image set, the contextual similarity between the boy's image and the girl's image is determined. Since the boy's image neighboring boy image set contains boy's images whose similarity to the boy's image is greater than a similarity threshold, and the girl's image neighboring girl image set contains girl's images whose similarity to the girl's image is greater than a similarity threshold, the contextual similarity contains global semantic gender information for distinguishing whether the pedestrian image is a boy's image or a girl's image. Based on the pairwise similarity and the contextual similarity, the parameters of the image processing model are updated to obtain an updated image processing model. Then, an input image (for example, a boy's image) is obtained, and feature extraction is performed on the input image according to the image processing model to obtain pedestrian features corresponding to the input image. The pedestrian features are classified by a classifier to obtain the category to which the input image belongs, which is a boy.

[0067] In some embodiments, server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.

[0068] The terminal 400 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, an intelligent voice interaction device, a smart home appliance, a vehicle terminal, an aircraft, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in the embodiments of the present application.

[0069] The embodiments of the present application can also be implemented through cloud technology. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model application. It can form a resource pool, which is used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, as well as the promotion of search services, social networks, mobile commerce and open collaboration, each item may have its own hash code identification mark in the future, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately, and all kinds of industry data require strong system backing support, which can only be achieved through cloud computing.

[0070] See also Figure 2A , Figure 2A is a first structural diagram of an electronic device provided in an embodiment of the present application, Figure 2A The electronic device 500 shown may be Figure 1 In the terminal 400 or server 200, the electronic device 500 includes: at least one processor 510, a memory 550, and at least one network interface 520. The various components in the server 200 are coupled together through a bus system 540. It can be understood that the bus system 440 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 540 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Figure 2A Various buses are labeled as bus system 540 .

[0071] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc., where the general-purpose processor can be a microprocessor or any conventional processor, etc.

[0072] The user interface 530 includes one or more output devices 531 that enable presentation of media content, including one or more speakers and / or one or more visual display screens. The user interface 530 also includes one or more input devices 532, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls;

[0073] In some embodiments, when the terminal 400 independently completes the model training task, the server 200 provided in the embodiment of the present application does not include the user interface 530.

[0074] The memory 550 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, a hard disk drive, an optical disk drive, etc. The memory 550 may optionally include one or more storage devices that are physically located away from the processor 510.

[0075] The memory 550 includes a volatile memory or a non-volatile memory, and may also include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), and the volatile memory may be a random access memory (RAM). The memory 550 described in the embodiments of the present application is intended to include any suitable type of memory.

[0076] In some embodiments, the memory 550 can store data to support various operations, examples of which include programs, modules, and data structures, or a subset or superset thereof, as exemplarily described below.

[0077] Operating system 551, including system programs for processing various basic system services and performing hardware-related tasks, such as framework layer, core library layer, driver layer, etc., for implementing various basic services and processing hardware-based tasks;

[0078] A network communication module 552, for reaching other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 include: Bluetooth, Wireless Compatibility Certification (WiFi), and Universal Serial Bus (USB);

[0079] a presentation module 553 for enabling presentation of information via one or more output devices 531 (e.g., display screen, speaker, etc.) associated with the user interface 530 (e.g., a user interface for operating peripherals and displaying content and information);

[0080] In some embodiments, when the model training task is completed independently by the terminal 400, the server 200 provided in the embodiment of the present application may not include the presentation module 553.

[0081] The input processing module 554 is used to detect one or more user inputs or interactions from one of the one or more input devices 532 and translate the detected inputs or interactions; in some embodiments, when the embodiment independently completes the model training task by the terminal 400, the server 200 provided in the embodiment of the present application may not include the presentation module 553.

[0082] In some embodiments, the device provided in the embodiments of the present application can be implemented in software. Figure 2A The model training device 555 stored in the memory 550 is shown, which can be software in the form of a program and a plug-in, etc., including the following software modules: a feature extraction module 5551, an acquisition module 5552, and an update module 5553. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be explained below.

[0083] In some embodiments, the image classification device provided in the embodiments of the present application can also be implemented in software, see Figure 2B , Figure 2B is a second structural diagram of an electronic device provided in an embodiment of the present application, Figure 2B Except for the image classification device 556 shown, the rest can be the same as Figure 2A The same is not repeated here. The image classification device 556 stored in the memory 550 can be software in the form of a program and a plug-in, including the following software modules: a feature extraction module 5561 and an image classification module 5562. These modules are logical, so they can be arbitrarily combined or further split according to the functions implemented. The functions of each module will be described below.

[0084] In other embodiments, the device provided in the embodiments of the present application can be implemented in hardware. As an example, the device provided in the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the image processing method provided in the embodiments of the present application. For example, the processor in the form of a hardware decoding processor can adopt one or more application specific integrated circuits (Application Specific Integrated Circuit, ASIC), digital signal processors (Digital Signal Processor, DSP), programmable logic devices (Programmable Logic Device, PLD), complex programmable logic devices (Complex Programmable Logic Device, CPLD), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other electronic components.

[0085] It should be noted that in the model training example below, those skilled in the art can apply the model training method provided in the embodiment of the present application to the model training process of image classification based on their understanding of the following text.

[0086] See also Figure 3A , Figure 3A This is a first flow chart of the model training method provided in the embodiment of the present application, which will be combined with Figure 3A The steps shown are used to illustrate that the model training method provided in the embodiments of the present application can be implemented by a server or a terminal alone, or by a server and a terminal in collaboration. The following will illustrate the collaborative implementation by a server and a terminal as an example.

[0087] In step 101, feature extraction is performed on a first image and a second image through an image processing model to obtain first image features corresponding to the first image and second image features corresponding to the second image.

[0088] Here, the first image and the second image are images that are simultaneously input to the model during the training process.

[0089] In some embodiments, see Figure 3B , Figure 3B It is a second flow chart of the model training method provided in an embodiment of the present application. Figure 3A Step 101 shown may be performed by Figure 3B Steps 1011 to 1014 are implemented as described in detail below.

[0090] In step 1011, feature extraction is performed on a first enhanced image of the first image through an image processing model to obtain a first enhancement of the first enhanced image.

[0091] Here, the first enhanced image may be obtained by performing image enhancement on the first image using at least one image enhancement method, wherein the number of the first enhanced image is at least one.

[0092] In some embodiments, taking the example of obtaining a first enhanced image after performing image enhancement on a first image by two image enhancement methods, feature extraction is performed on enhanced image A and enhanced image B respectively through an image processing model to obtain a first feature corresponding to enhanced image A and a second feature corresponding to enhanced image B, wherein enhanced image A is obtained by performing first data enhancement on the first image, and enhanced image B is obtained by performing second data enhancement on the first image, and enhanced image A and enhanced image B are both first enhanced images.

[0093] Continuing from the above embodiment, a first data enhancement is performed on the first image through an image processing model to obtain an enhanced image A, and a second data enhancement is performed on the first image to obtain an enhanced image B. The first data enhancement and the second data enhancement are different data enhancement methods. The image enhancement method is to process certain image features, such as edges, contours, contrast, etc., to improve the visual effect of the image and enhance the clarity of the image. The embodiment of the present application does not limit the selection of the image enhancement method. The image enhancement method can be grayscale transformation, image sharpening, etc.

[0094] Continuing with the above embodiment, the enhanced image A is encoded through the encoding layer of the image processing model, and the encoded feature is obtained as the first feature. The enhanced image B is encoded through the encoding layer of the image processing model, and the encoded feature is obtained as the second feature.

[0095] In step 1012, data processing is performed on the first enhanced feature to obtain a first image feature of the first image.

[0096] In some embodiments, taking the example that the first enhanced feature includes the first feature and the second feature, data processing is performed on the first feature and the second feature to obtain the first image feature corresponding to the first image.

[0097] Following the above embodiment, a weighted sum is performed on the first feature and the second feature to obtain a first image feature corresponding to the first image.

[0098] For example, the first feature is x and the second feature is y, where x and y have the same dimension. When the first feature and the second feature have the same weight, that is, the weights of the first feature and the second feature are both 0.5, the value of the first image feature is 0.5*x+0.5*y.

[0099] Continuing with the above example, the first feature is x and the second feature is y, where x and y have the same dimension. When the first feature and the second feature have different weights, the weight of the first feature is 0.4 and the weight of the second feature is 0.6, so the value of the first image feature is 0.4*x+0.6*y.

[0100] In step 1013, feature extraction is performed on the second enhanced image of the second image through the image processing model to obtain second enhanced features of the second enhanced image.

[0101] Here, the second enhanced image may be obtained by performing image enhancement on the second image by using at least one image enhancement method, wherein the number of the second enhanced image is at least one.

[0102] In some embodiments, taking the example of obtaining a second enhanced image after performing image enhancement on the second image through two image enhancement methods, feature extraction is performed on enhanced image C and enhanced image D respectively through an image processing model to obtain a third feature corresponding to enhanced image C and a fourth feature corresponding to enhanced image D, wherein enhanced image C is obtained by performing first data enhancement on the second image, and enhanced image D is obtained by performing second data enhancement on the second image, and enhanced image C and enhanced image D are both first enhanced images.

[0103] Continuing from the above embodiment, a first data enhancement is performed on the second image through an image processing model to obtain an enhanced image C, and a second data enhancement is performed on the second image to obtain an enhanced image D. The first data enhancement and the second data enhancement are different data enhancement methods. The image enhancement method is to process certain image features, such as edges, contours, contrast, etc., to improve the visual effect of the image and enhance the clarity of the image. The embodiment of the present application does not limit the selection of the image enhancement method. The image enhancement method can be grayscale transformation, image sharpening, etc.

[0104] Continuing with the above embodiment, the enhanced image C is encoded through the encoding layer of the image processing model, and the encoded feature is the third feature. The enhanced image D is encoded through the encoding layer of the image processing model, and the encoded feature is the fourth feature.

[0105] In step 1014, data processing is performed on the second enhanced feature to obtain a second image feature of the second image.

[0106] In some embodiments, taking the example that the second enhanced feature includes the third feature and the fourth feature, data processing is performed on the third feature and the fourth feature to obtain the second image feature corresponding to the second image.

[0107] Following the above embodiment, a weighted sum is performed on the third feature and the fourth feature to obtain a second image feature corresponding to the second image.

[0108] For example, the third feature is x and the fourth feature is y, where x and y have the same dimension. When the third feature and the fourth feature have the same weight, that is, the weights of the third feature and the fourth feature are both 0.5, the value of the second image feature is 0.5*x+0.5*y.

[0109] Continuing with the above example, the third feature is x and the fourth feature is y, where x and y have the same dimension. When the third feature and the fourth feature have different weights, the weight of the third feature is 0.4 and the weight of the second feature is 0.6, so the value of the second image feature is 0.4*x+0.6*y.

[0110] Through the embodiments of the present application, by integrating image features obtained based on different image enhancement methods, the model focuses on the common features of the image itself, avoiding the model from paying too much attention to image features enhanced by a certain data enhancement method, thereby improving the robustness of the model.

[0111] Continue to see Figure 3A In step 102, based on the similarity between the first image feature and the second image feature, the pairwise similarity between the first image and the second image is determined.

[0112] In some embodiments, the similarity between the first image feature and the second image feature is used to measure the similarity between the first image and the second image. At the same time, the higher the similarity between the two image features, the smaller the distance between the first image and the second image, and the greater the probability that the first image and the second image are classified into the same category.

[0113] In step 103 , contextual similarity between the first image and the second image is determined based on the neighbor image set of the first image and the neighbor image set of the second image.

[0114] The neighbor image set of the first image includes neighbor images of the first image whose similarity with the first image is greater than a similarity threshold, and the neighbor image set of the second image includes neighbor images of the second image whose similarity with the second image is greater than a similarity threshold.

[0115] In some embodiments, images whose similarity to the first image is greater than a similarity threshold are determined as images in a neighbor image set of the first image, and the number of images in the neighbor image set of the first image is less than the number of images in the image sample space.

[0116] Continuing from the above embodiment, K-1 images are selected from images whose similarity with the first image is greater than a similarity threshold in order of similarity as images in a neighbor image set of the first image, where K is an integer greater than 1, and the images in the neighbor image set of the first image include the first image itself.

[0117] For example, the similarity threshold is set to 0.5, the value of K is set to 2, and image B is selected as the image in the neighbor image set of the first image from image A whose similarity to the first image is 0.65 and image B whose similarity to the first image is 0.75. That is, the neighbor image set of the first image includes the first image and image B.

[0118] In some embodiments, images whose similarity to the second image is greater than a similarity threshold are determined as images in a neighbor image set of the second image, and the number of images in the neighbor image set of the second image is less than the number of images in the image sample space.

[0119] Continuing from the above embodiment, K-1 images are selected from images whose similarity with the second image is greater than a similarity threshold in order of similarity as images in a neighbor image set of the second image, where K is an integer greater than 1, and the images in the neighbor image set of the second image include the second image itself.

[0120] For example, the similarity threshold is set to 0.5, the value of K is set to 2, and image B is selected as the image in the neighbor image set of the second image from image A whose similarity to the second image is 0.65 and image B whose similarity to the second image is 0.75. That is, the neighbor image set of the second image includes the second image and image B.

[0121] In some embodiments, see Figure 3C , Figure 3C This is a third flow chart of the model training method provided in an embodiment of the present application. Figure 3A Step 103 shown may be performed by Figure 3C Steps 1031 to 1033 are implemented as described in detail below.

[0122] In step 1031, a first reciprocal neighbor image set is determined based on the neighbor image set of the first image, and a second reciprocal neighbor image set is determined based on the neighbor image set of the second image.

[0123] The first reciprocal neighbor image set includes images that are neighbors of the neighbor images of the first image, and the second reciprocal neighbor image set includes images that are neighbors of the neighbor images of the second image.

[0124] In some embodiments, the images in the neighbor image set of the first image are neighbor images of the first image, and the images in the neighbor image set of the second image are neighbor images of the second image. The number of neighbor images of the first image can be multiple, and the number of neighbor images of the second image can be multiple.

[0125] In some embodiments, based on the neighbor image of the first image, K-1 images are selected in order of similarity from images whose similarity with the neighbor image of the first image is greater than a similarity threshold; when the K-1 images selected in order of similarity from images whose similarity with image i is greater than a similarity threshold include the neighbor image of the first image, then the neighbor image of the first image and image i are neighbors of each other, where K is an integer greater than 1, image i is the i-th image among the selected K-1 images, and i is an integer greater than 1 and less than K-1.

[0126] For example, the value of K is 3, and two images, such as image 1 and image 2, are selected in order of similarity from images whose similarity with neighbor images of the first image is greater than a similarity threshold. When the two images selected in order of similarity from images whose similarity with image 1 is greater than a similarity threshold include a neighbor image of the first image, the neighbor image of the first image is a neighbor of image 1.

[0127] In some embodiments, according to the neighbor image of the second image, K-1 images are selected in order of similarity from images whose similarity with the neighbor image of the second image is greater than a similarity threshold; when the K-1 images selected in order of similarity from images whose similarity with image i is greater than a similarity threshold include the neighbor image of the second image, then the neighbor image of the second image and image i are neighbors of each other, where K is an integer greater than 1, image i is the i-th image among the selected K-1 images, and i is an integer greater than 1 and less than K-1.

[0128] For example, the value of K is 3, and two images, such as image 1 and image 2, are selected in order of similarity from images whose similarity with neighbor images of the second image is greater than a similarity threshold. When the two images selected in order of similarity from images whose similarity with image 1 is greater than a similarity threshold include the neighbor image of the second image, the neighbor image of the second image is a neighbor of image 1.

[0129] In some embodiments, when the target neighbor image set is the neighbor image set of the first image, the target reciprocal neighbor image set of the target neighbor image set is the first reciprocal neighbor image set, and when the target neighbor image set is the neighbor image set of the second image, the target reciprocal neighbor image set of the target neighbor image set is the second reciprocal neighbor image set, see Figure 3D , Figure 3D 4 is a schematic diagram of a fourth flow chart of a model training method provided in an embodiment of the present application. Figure 3D Step 201 to step 202 are implemented.

[0130] In step 201 , for each neighbor image in the target neighbor image set, a first neighbor image of the neighbor image and a second neighbor image of the first neighbor image are acquired.

[0131] It should be noted that the first neighbor image is at least one image whose similarity with the neighbor image is greater than a similarity threshold, and the second neighbor image is at least one image whose similarity with the first neighbor image is greater than a similarity threshold.

[0132] In some embodiments, at least one image whose similarity with each neighbor image in the target neighbor image set is greater than a similarity threshold is determined as the first neighbor image of each neighbor image in the target neighbor image set, and the number of first neighbor images is less than the number of images in the image sample space.

[0133] Continuing from the above embodiment, when the number of the first neighbor images is one, the neighbor images of the target neighbor image set are determined to be images in the third neighbor image set (ie, the first neighbor images).

[0134] Continuing from the above embodiment, when there are multiple first neighbor images, K-1 images are selected from the images whose similarity with the neighbor images of the target neighbor image set is greater than a similarity threshold in order of similarity as images in the third neighbor image set (i.e., first neighbor images), wherein K is an integer greater than 1, and the images in the third neighbor image set include the neighbor images of the target neighbor image set themselves.

[0135] For example, the similarity threshold is set to 0.5, the value of K is 2, and image B is selected as the image in the third neighbor image set from image A whose similarity to the neighbor images of the target neighbor image set is 0.65 and image B whose similarity to the neighbor images of the target neighbor image set is 0.75, that is, the third neighbor image set includes the neighbor images of the target neighbor image set and image B.

[0136] Continuing from the above embodiment, an image whose similarity with a third neighbor image (one of the images in the third neighbor image set) is greater than a similarity threshold is determined as an image in a fourth neighbor image set of the third neighbor image (i.e., a second neighbor image); the number of images in the fourth neighbor image set is less than the number of images in the image sample space; when the number of second neighbor images is one, the third neighbor image is determined as an image in the fourth neighbor image set (i.e., the second neighbor image).

[0137] Continuing with the above embodiment, when there are multiple second neighbor images, K-1 images are selected from the images whose similarity with the third neighbor image is greater than a similarity threshold in order of similarity as images in the fourth neighbor image set, where K is an integer greater than 1, and the images in the fourth neighbor image set include the third neighbor image itself.

[0138] For example, the similarity threshold is set to 0.5, the value of K is 2, and image B is selected as the image in the fourth neighbor image set from image A whose similarity to the third neighbor image is 0.65 and image B whose similarity to the third neighbor image is 0.75, that is, the fourth neighbor image set includes the third neighbor image and image B.

[0139] In step 202, if the second neighbor image is the same as the neighbor image, the first neighbor image is added to the target reciprocal neighbor image set.

[0140] It should be noted that when the number of first neighbor images is one, that is, the first neighbor image is a neighbor image of the target neighbor image set, since the second neighbor image is at least one image whose similarity with the first neighbor image is greater than a similarity threshold, if the number of second neighbor images is one and the second neighbor image is the same as the neighbor image of the target neighbor image set, the neighbor image of the target neighbor image set is added to the target reciprocal neighbor image set.

[0141] In some embodiments, when the number of first neighbor images is one, that is, the first neighbor image is a neighbor image of the target neighbor image set, since the second neighbor image is at least one image whose similarity with the first neighbor image is greater than a similarity threshold, if the number of second neighbor images is multiple and any second neighbor image is the same as the neighbor image of the target neighbor image set, the neighbor image of the target neighbor image set is added to the target reciprocal neighbor image set.

[0142] In some embodiments, when the number of first neighbor images is multiple, since the second neighbor image is at least one image whose similarity with a certain first neighbor image is greater than a similarity threshold, if the number of second neighbor images is one and the second neighbor image is the same as the neighbor image of the target neighbor image set, the first neighbor image is added to the target reciprocal neighbor image set.

[0143] In some embodiments, when there are multiple first neighbor images, since the second neighbor image is at least one image whose similarity with a certain first neighbor image is greater than a similarity threshold, if there are multiple second neighbor images and any second neighbor image is the same as a neighbor image of the target neighbor image set, the first neighbor image is added to the target reciprocal neighbor image set.

[0144] Continue to see Figure 3C In step 1032, a first similarity between the first image and the second image is determined based on the second reciprocal neighbor image set, and a second similarity between the first image and the second image is determined based on the first reciprocal neighbor image set.

[0145] In some embodiments, the first similarity and the second similarity are used to measure the similarity between two sets, and the first similarity and the second similarity are asymmetric Jaccard similarities.

[0146] In some embodiments, see Figure 3E , Figure 3E is a fifth flow chart of the model training method provided in the embodiment of the present application. Figure 3C In step 1032, determining the first similarity between the first image and the second image based on the second reciprocal neighbor image set can be performed by Figure 3E Steps 10321A to 10323A are implemented.

[0147] In step 10321A, a first intersection of the first reciprocal neighbor image set and the second reciprocal neighbor image set is determined.

[0148] In some embodiments, the first intersection of the first reciprocal neighbor image set and the second reciprocal neighbor image set is used to measure the degree of overlap between the contexts of the first image and the second image. The larger the number of images in the first intersection, the higher the degree of overlap between the contexts of the first image and the second image. The context of the first image and the second image is the first reciprocal neighbor image set and the second reciprocal neighbor image set.

[0149] In step 10322A, the first intersection is determined as an overlapping reciprocal neighbor image set, and a first ratio of the number of images in the overlapping reciprocal neighbor image set to the number of images in the first reciprocal neighbor image set is determined.

[0150] In some embodiments, the first ratio is used to measure the semantic similarity between the first image and the second image. The larger the first ratio is, the higher the semantic similarity between the first image and the second image is.

[0151] For example, the first reciprocal neighbor image set includes image A, image B, image C and image E, and the second reciprocal neighbor image set includes image A and image D. Therefore, the overlapping reciprocal neighbor image set is the first intersection of the first reciprocal neighbor image set and the second reciprocal neighbor image set, and the first intersection includes image A. It is determined that the first ratio of the number of images 1 in the overlapping reciprocal neighbor image set to the number of images 4 in the first reciprocal neighbor image set is 0.25.

[0152] In step 10323A, the first ratio is determined as the first similarity.

[0153] In some embodiments, see Figure 3F , Figure 3F 6 is a schematic diagram of a model training method according to an embodiment of the present application. Figure 3CIn step 1032, determining the first similarity between the first image and the second image based on the second reciprocal neighbor image set can be performed by Figure 3F Steps 10321B to 10324B are implemented.

[0154] In step 10321B, N first neighbor image subsets are selected from the neighbor image set of the first image.

[0155] The number N of images in the first neighbor image subset is smaller than the number of images in the neighbor image set of the first image, and N is a positive integer greater than 0.

[0156] In some embodiments, the images included in each first neighbor image subset are not completely the same.

[0157] For example, the neighbor image set of the first image includes image A, image B, image C and image D respectively, and two images are selected from the four images as the first neighbor image subset.

[0158] Continuing with the above example, image A and image C are randomly selected from four images as a first neighbor image subset, and image A and image D are randomly selected from four images as another first neighbor image subset, or image A and image B are sequentially selected from four images as a first neighbor image subset, and image B and image C are selected as a second first neighbor image subset. The embodiment of the present application does not limit the method for constructing the first neighbor image subset.

[0159] In step 10322B, N first reciprocal neighbor image subsets of the N first neighbor image subsets are determined; one first neighbor image subset corresponds to one first reciprocal neighbor image subset.

[0160] In some embodiments, the first reciprocal neighbor image subset includes images that are neighbors of neighbor images of the first image in the first neighbor image subset. According to the neighbor images of the first image in the first neighbor image subset, K-1 images are selected in order of similarity from images whose similarity with the neighbor images of the first image is greater than a similarity threshold. When the K-1 images selected in order of similarity from images whose similarity with image i is greater than a similarity threshold include the neighbor images of the first image in the first neighbor image subset, the neighbor images of the first image in the first neighbor image subset are neighbors of image i, and image i is determined to be an image in the first reciprocal neighbor image subset, wherein K is an integer greater than 1, image i is the i-th image among the selected K-1 images, and i is an integer greater than 1 and less than K-1.

[0161] For example, the value of K is 3, and two images, such as image 1 and image 2, are selected in order of similarity from images whose similarity to the neighbor image of the first image in the first neighbor image subset is greater than a similarity threshold. When the two images selected in order of similarity from images whose similarity to image 1 is greater than a similarity threshold include the neighbor image of the first image in the first neighbor image subset, the neighbor image of the first image in the first neighbor image subset is a neighbor of image 1, and image 1 is determined as an image in the first reciprocal neighbor image subset.

[0162] In step 10323B, for each first reciprocal neighbor image subset, a second intersection between the first reciprocal neighbor image subset and the second reciprocal neighbor image set is determined, and a second ratio of the number of images in the second intersection to the number of images in the first reciprocal neighbor image subset is determined.

[0163] In some embodiments, the second ratio is used to measure the semantic similarity between the first image and the second image. The larger the second ratio is, the higher the semantic similarity between the first image and the second image is.

[0164] For example, the first reciprocal neighbor image subset S1 includes image A and image B, and the second reciprocal neighbor image set includes image A and image D. Therefore, the second intersection of the first reciprocal neighbor image subset S1 and the second reciprocal neighbor image set includes image A, and a second ratio P1 of the number of images 1 in the second intersection to the number of images 2 in the second reciprocal neighbor image set is determined to be 0.5. The first reciprocal neighbor image subset S2 includes image A, image B, and image C, and the second reciprocal neighbor image set includes image A and image D. Therefore, the second intersection of the first reciprocal neighbor image subset S2 and the second reciprocal neighbor image set includes image A, and a second ratio P2 of the number of images 1 in the second intersection to the number of images 3 in the second reciprocal neighbor image set is determined to be 0.333.

[0165] In step 10324B, the determined N second ratios are subjected to data processing to obtain a first similarity between the first image and the second image.

[0166] In some embodiments, a weighted sum of the N second ratios is performed to determine the first similarity between the first image and the second image.

[0167] For example, when N is equal to 2, the second ratio P1 corresponding to the first reciprocal neighbor image subset S1 is 0.5, and the second ratio P2 corresponding to the first reciprocal neighbor image subset S2 is 0.333.

[0168] Continuing with the above example, when the second ratio P1 and the second ratio P2 have the same weight, that is, the weights of the second ratio P1 and the second ratio P2 are both 0.5, the value of the first similarity is 0.4165, or, when the second ratio P1 and the second ratio P2 have different weights, the weight of the second ratio P1 is 0.4, and the weight of the second ratio P2 is 0.6, so the value of the first similarity is 0.39998.

[0169] Continue to see Figure 3C In step 1033, data processing is performed on the first similarity and the second similarity to obtain contextual similarity between the first image and the second image.

[0170] In some embodiments, the first similarity and the second similarity are weightedly summed to determine the contextual similarity between the first image and the second image.

[0171] For example, the first similarity is 0.8, and the second similarity is 0.6. When the first similarity and the second similarity have the same weight, that is, the weights of the first similarity and the second similarity are both 0.5, the value of the context similarity is 0.7. Or, when the first similarity and the second similarity have different weights, the weight of the first similarity is 0.4, and the weight of the second similarity is 0.6, the value of the context similarity is 0.68.

[0172] Through the embodiments of the present application, images that are neighbors of the image in the neighbor image set of the image are used as the context of the image, and data that is irrelevant to the image in the neighbor image set of the image is avoided, thereby determining the indirect semantic relationship of each image. The indirect semantic relationship between different images is conducive to extracting common features in images of different categories, so that the model can further understand the potential features of images of different categories, supplement the category information in unsupervised learning, and improve the accuracy of image classification.

[0173] Continue to see Figure 3A , in step 104, the parameters of the teacher model are updated based on the pairwise similarity and the contextual similarity.

[0174] In some embodiments, a loss value is determined based on the pairwise similarity and the contextual similarity, and the parameters of the teacher model are updated based on the loss value.

[0175] In some embodiments, see Figure 3G , Figure 3G This is the seventh flow chart of the model training method provided in the embodiment of the present application. Figure 3A Step 104 shown may be performed by Figure 3G Steps 1041 to 1043 are implemented as described in detail below.

[0176] In step 1041, data processing is performed on the pairwise similarity and the contextual similarity to obtain the contextual semantic similarity.

[0177] In some embodiments, the pairwise similarity and the contextual similarity are weightedly summed to determine the contextual semantic similarity between the paired image and the context image.

[0178] For example, the pairwise similarity is 0.8 and the contextual similarity is 0.6. When the pairwise similarity and the contextual similarity have the same weight, that is, the weights of the pairwise similarity and the contextual similarity are both 0.5, the value of the contextual similarity is 0.7. Or, when the pairwise similarity and the contextual similarity have different weights, the weight of the pairwise similarity is 0.4 and the weight of the contextual similarity is 0.6, so the value of the contextual semantic similarity is 0.68.

[0179] In step 1042, a third image feature of the first image and a fourth image feature of the second image are acquired, and a distance between the third image feature and the image feature is determined.

[0180] It should be noted that the embodiment of the present application does not limit the method for obtaining the distance between the third image feature and the fourth image feature. The distance between the third image feature and the fourth image feature can be the Euclidean distance, Mahalanobis distance, etc. between the third image feature and the fourth image feature.

[0181] In some embodiments, the image processing model is a teacher model, see Figure 3H , Figure 3H 8 is a schematic diagram of the eighth flow chart of the model training method provided in the embodiment of the present application. Figure 3G The third image feature of the first image and the fourth image feature of the second image in step 1042 shown in the figure can be obtained by Figure 3H Steps 10421 to 10424 are implemented as described in detail below.

[0182] In step 10421, feature extraction is performed on the first enhanced image of the first image using the student model to obtain a third enhanced feature corresponding to the first enhanced image.

[0183] Here, the first enhanced image may be obtained by performing image enhancement on the first image by using at least one image enhancement method, wherein the number of the first enhanced images is at least one.

[0184] In some embodiments, taking the example of obtaining a first enhanced image after performing image enhancement on the first image through two image enhancement methods, feature extraction is performed on enhanced image A and enhanced image B respectively through the student model to obtain the fifth feature corresponding to enhanced image A and the sixth feature corresponding to enhanced image B, wherein enhanced image A is obtained by performing the first data enhancement on the first image, and enhanced image B is obtained by performing the second data enhancement on the first image, and enhanced image A and enhanced image B are both first enhanced images.

[0185] Continuing from the above embodiment, a first data enhancement is performed on the first image through the student model to obtain an enhanced image A, and a second data enhancement is performed on the first image to obtain an enhanced image B. The first data enhancement and the second data enhancement are different data enhancement methods. The image enhancement method is to process certain image features, such as edges, contours, contrast, etc., to improve the visual effect of the image and improve the clarity of the image. The embodiment of the present application does not limit the selection of the image enhancement method. The image enhancement method can be grayscale transformation, image sharpening, etc. The enhanced image A is encoded through the encoding layer of the student model, and the encoded feature is the fifth feature. The enhanced image B is encoded through the encoding layer of the student model, and the encoded feature is the sixth feature.

[0186] In step 10422, data processing is performed on the third enhanced feature to obtain a third image feature corresponding to the first image.

[0187] In some embodiments, taking the example that the third enhanced feature includes the fifth feature and the sixth feature, data processing is performed on the fifth feature and the sixth feature to obtain the third image feature corresponding to the first image, and the fifth feature and the sixth feature are weighted summed to obtain the first image feature corresponding to the first image.

[0188] For example, the fifth feature is x and the sixth feature is y, where x and y have the same dimension. When the fifth feature and the sixth feature have the same weight, that is, the weights of the fifth feature and the sixth feature are both 0.5, the value of the first image feature is 0.5*x+0.5*y. When the fifth feature and the sixth feature have different weights, the weight of the fifth feature is 0.4, the weight of the sixth feature is 0.6, and the value of the first image feature is 0.4*x+0.6*y.

[0189] In step 10423, feature extraction is performed on the second enhanced image of the second image using the student model to obtain a fourth enhanced feature corresponding to the second enhanced image.

[0190] Here, the second enhanced image may be obtained by performing image enhancement on the second image by at least one image enhancement method, wherein the number of the second enhanced images is at least one.

[0191] In some embodiments, taking the example of obtaining a second enhanced image after performing image enhancement on the second image by two image enhancement methods, feature extraction is performed on enhanced image C and enhanced image D respectively through the student model to obtain the seventh feature corresponding to enhanced image C and the eighth feature corresponding to enhanced image D, wherein enhanced image C is obtained by performing first data enhancement on the second image, and enhanced image D is obtained by performing second data enhancement on the second image, and enhanced image C and enhanced image D are both first enhanced images.

[0192] Continuing from the above embodiment, a first data enhancement is performed on the second image through the student model to obtain an enhanced image C, and a second data enhancement is performed on the second image to obtain an enhanced image D. The first data enhancement and the second data enhancement are different data enhancement methods. The image enhancement method is to process certain image features, such as edges, contours, contrast, etc., to improve the visual effect of the image and improve the clarity of the image. The embodiment of the present application does not limit the selection of the image enhancement method. The image enhancement method can be grayscale transformation, image sharpening, etc. The enhanced image C is encoded through the encoding layer of the student model, and the encoded feature is the seventh feature. The enhanced image D is encoded through the encoding layer of the student model, and the encoded feature is the eighth feature.

[0193] In step 10424, data processing is performed on the fourth enhanced feature to obtain a fourth image feature corresponding to the second image.

[0194] In some embodiments, taking the second enhanced feature including the seventh feature and the eighth feature as an example, the seventh feature and the eighth feature are data processed to obtain the fourth image feature corresponding to the second image, and the seventh feature and the eighth feature are weighted summed to obtain the second image feature corresponding to the second image.

[0195] For example, the seventh feature is x and the eighth feature is y, where x and y have the same dimension. When the seventh feature and the eighth feature have the same weight, that is, the weights of the seventh feature and the eighth feature are both 0.5, the value of the second image feature is 0.5*x+0.5*y. When the seventh feature and the eighth feature have different weights, the weight of the seventh feature is 0.4 and the weight of the eighth feature is 0.6, so the value of the second image feature is 0.4*x+0.6*y.

[0196] Continue to see Figure 3G In step 1043, a loss value is determined based on the distance and contextual semantic similarity, and the parameters of the image processing model are updated based on the loss value.

[0197] It should be noted that the image processing model is a teacher model.

[0198] In some embodiments, a contrast loss algorithm is called to perform loss calculation based on distance and contextual semantic similarity to obtain a loss value of the model, the parameters of the student model are updated based on the loss value, and the parameters of the image processing model are updated based on the updated student model, wherein the image processing model is used to extract features from the input image, and the student model is used to update the parameters of the image processing model.

[0199] In some embodiments, see Fig. 3I , Fig. 3I is a ninth flow chart of the model training method provided in the embodiment of the present application. Figure 3G The loss value is determined based on the distance and context semantic similarity in step 1043 shown, which can be obtained by Fig. 3I Steps 301A to 304A are implemented as described in detail below.

[0200] In step 301A, the third image feature and the fourth image feature are classified by a classifier to obtain a first distribution probability.

[0201] In some embodiments, a classifier is used to classify image features after the image is encoded by the student model to obtain a distribution probability corresponding to the image, and the first distribution probability is the weighted average result of the distribution probabilities of multiple encoded features encoded by the student model.

[0202] In some embodiments, see Figure 3J , Figure 3J This is the tenth flow chart of the model training method provided in the embodiment of the present application. Fig. 3I Step 301A shown may be performed by Figure 3J Steps 3011A to 3013A are implemented as described in detail below.

[0203] In step 3011A, the third image feature is classified by a classifier to obtain a distribution probability of the third image feature.

[0204] In some embodiments, the distribution probability of the third image feature, that is, the probability that the third image feature belongs to different categories, the sum of the probabilities is 1.

[0205] For example, the third image feature is classified by a classifier, and the probability that the third image belongs to category A is 0.4, and the probability that the third image belongs to category B is 0.6, and the distribution probability of the third image feature is [0.4, 0.6].

[0206] In step 3012A, the fourth image feature is classified by a classifier to obtain a distribution probability of the fourth image feature.

[0207] In some embodiments, the distribution probability corresponding to the fourth image feature, that is, the probability that the fourth image feature belongs to different categories, the sum of the probabilities is 1.

[0208] For example, the fourth image feature is classified by a classifier, and the probability that the fourth image belongs to category A is 0.4, and the probability that the fourth image belongs to category B is 0.6, and the distribution probability of the fourth image feature is [0.4, 0.6].

[0209] In step 3013A, data processing is performed on the distribution probability of the third image feature and the distribution probability of the fourth image feature to obtain a first distribution probability.

[0210] In some embodiments, a weighted sum is performed on the distribution probability of the third image feature and the distribution probability of the fourth image feature to obtain the first distribution probability.

[0211] For example, the distribution probability of the third image feature is [0.4, 0.6], and the distribution probability of the third image feature is [0.2, 0.8]. When the distribution probability of the third image feature and the distribution probability of the fourth image feature have the same weight, that is, the distribution probability of the third image feature and the distribution probability of the third image feature have a weight of 0.5, so the first distribution probability is [0.3, 0.7]. When the distribution probability of the third image feature and the distribution probability of the fourth image feature have different weights, the weight of the distribution probability of the third image feature is 0.4, and the weight of the distribution probability of the fourth image feature is 0.6, so the first distribution probability is [0.28, 0.72].

[0212] Continue to see Fig. 3I In step 302, the first image feature and the second image feature are classified by a classifier to obtain a second distribution probability.

[0213] In some embodiments, a classifier is used to classify image features after the image is encoded by an image processing model to obtain a distribution probability of the image. The second distribution probability of the image processing model is the weighted average result of the distribution probabilities of multiple encoded features encoded by the image processing model.

[0214] In step 303A, data processing is performed on the first distribution probability and the second distribution probability to obtain a clustering loss value.

[0215] In some embodiments, the KL divergence between the first distribution probability and the second distribution probability is determined, and the sum of the KL divergence between the first distribution probability and the second distribution probability and the clustering regularization term is determined as the clustering loss value, wherein the clustering regularization term is used to limit the complexity of the model, thereby avoiding the performance degradation problem during the model training process, that is, the degenerate solution problem of incorrectly assigning most images to categories including a few images.

[0216] In step 304A, processing is performed based on the clustering loss value, the distance, and the contextual semantic similarity to obtain a loss value.

[0217] In some embodiments, a contrast loss algorithm is called based on distance and context semantic similarity, a weighted average is performed on the obtained contrast loss value and clustering loss value, and the result of the weighted average is determined as the loss value.

[0218] In some embodiments, see Figure 3K , Figure 3K This is the eleventh flow chart of the model training method provided in the embodiment of the present application. Figure 3G The parameters of the image processing model are updated based on the loss value in step 1043 shown, which can be achieved by Figure 3K Steps 301B to 303B are implemented.

[0219] It should be noted that the image processing model is a teacher model.

[0220] In step 301B, based on the loss value, back-propagation is performed on the student model to obtain updated parameters of the student model.

[0221] In some embodiments, based on the loss value, the student model is back-propagated, and the parameters of the student model are updated until the loss value gradually converges, and the parameters of each student model update are saved.

[0222] In some embodiments, based on the loss value, the classifier is back-propagated, the parameters of the classifier are updated until the loss value gradually converges, and the parameters of the classifier when the loss value converges are saved.

[0223] In step 302B, momentum parameters are obtained.

[0224] Among them, the momentum parameter is used to control the updating degree of the parameters of the image processing model.

[0225] In some embodiments, the larger the value of the momentum parameter, the greater the degree of update of the parameters of the image processing model, and the smaller the value of the momentum parameter, the smaller the degree of update of the parameters of the image processing model, wherein the momentum parameter is a real number greater than 0 and less than 1.

[0226] In step 303B, the parameters of the image processing model are processed based on the momentum parameters and the updated parameters of the student model to obtain the updated parameters of the image processing model.

[0227] In some embodiments, the difference between 1 and momentum is determined, and the sum of the product of the momentum parameter and the image processing model parameter and the product of the difference between 1 and momentum and the student model parameter is determined as the updated parameter of the image processing model.

[0228] For example, the momentum parameter is m, the parameter of the image processing model is x, and the parameter of the student model is y, then the value of m*x+(1-m)*y is determined as the updated parameter of the image processing model.

[0229] Through the embodiments of the present application, the parameters of the image processing model are updated through the student model, the update speed of the image processing model is gradually controlled, and the stability of feature extraction of the image processing model is improved.

[0230] It should be noted that in the following image classification example, those skilled in the art may apply the image classification method provided in the embodiment of the present application to the image classification process based on their understanding of the following.

[0231] See also Figure 4 , Figure 4 is a flowchart of the image classification method provided in the embodiment of the present application, which will be combined with Figure 4 The steps shown are used for illustration. The image classification method provided in the embodiment of the present application can be implemented by a server or a terminal alone, or by a server and a terminal in collaboration. The following will take the collaborative implementation by a server and a terminal as an example for illustration.

[0232] In step 401, feature extraction is performed on an input image through an image processing model to obtain image features corresponding to the input image.

[0233] Among them, the image processing model is trained by the model training method provided in the embodiment of the present application.

[0234] In some embodiments, feature extraction is performed on an input image through an image processing model, and the obtained image features contain contextual semantic information of the image.

[0235] Through the embodiments of the present application, an image processing model that has learned more accurate contextual semantic features between samples and complex associations between data is used to extract features from the input image, thereby obtaining more accurate clustering classification information.

[0236] In step 402, the image features are classified by a classifier to obtain the category to which the input image belongs.

[0237] In some embodiments, the classifier performs classification processing on the image features of the input image to obtain the probability distribution of the input image for different categories, and determines the category corresponding to the maximum probability in the probability distribution as the category to which the input image belongs.

[0238] For example, the classifier classifies the image features of the input image and obtains the probability distribution of the input image [0.2, 0.8], where the probability corresponding to category A is 0.2, and the probability corresponding to category B is 0.8. Category B corresponding to the probability of 0.8 is determined as the category to which the input image belongs.

[0239] Below, an exemplary application of the model training method provided in an embodiment of the present application in an actual application scenario will be described.

[0240] The embodiment of the present application proposes a model training method for solving the problems of high labeling cost and difficulty in many scenarios. The relevant technology often needs to use unsupervised learning methods to solve the problem. Clustering is a commonly used method in traditional unsupervised methods. The purpose of clustering is to divide the data set into several categories so that the similarity between data in the same category is high, while the similarity between data in different categories is low.

[0241] The supervised learning models of related technologies require a large amount of labeled data and cannot fully utilize a large amount of unlabeled data, which increases the training cost and manual annotation cost of the model. However, learning effective semantic information under unlabeled conditions is still a big challenge.

[0242] The related art only learns the simple association between samples based on the nearest neighbor and the compactness within the category, but does not learn the differences and complex associations between categories and subcategories, making it difficult to mine the complex associations between samples. The contextual semantic similarity of the embodiment of the present application considers the similarity between sample features and the association between different samples at the same time, and can more effectively mine the association between sample features in the data set.

[0243] Take image classification model training as an example, see Figure 5 , Figure 5 It is a schematic diagram of the model provided in the embodiment of the present application.

[0244] like Figure 5 As shown, an embodiment of the present application proposes a model training method based on deep clustering to improve the accuracy of image classification.

[0245] The following is an explanation of each module of the model training method provided in the embodiment of the present application.

[0246] The model training method provided in the embodiment of the present application is divided into three modules, namely, a contrast representation learning module 501, a semantic similarity learning module 502 and a clustering module 503, wherein the contrast representation learning module 501 is used to extract features of the input image, the semantic similarity learning module 502 learns the similarity between the features of the image based on contextual semantic similarity, and the clustering module is used to determine the parameters of the clustering network (i.e., the classifier).

[0247] In contrastive representation learning module 501, since deep clustering methods rely heavily on representation learning, good representation is more conducive to clustering. Self-supervised contrastive learning methods (such as SimCLR algorithm and BYOL algorithm) regard the same sample with different enhancements as positive samples and different sample pairs as negative samples to extract discriminative representation features.

[0248] The embodiment of the present application is based on the BYOL algorithm as a comparative representation learning framework, by using the student network f(·) (i.e., the student model) and the teacher network f ξ The framework uses self-distillation technology to utilize the complex high-dimensional information in low-dimensional space, eliminate the influence of false negative samples, and extract more discriminative representation features.

[0249] The following is an explanation of the process in the contrast representation learning module 501 provided in the embodiment of the present application.

[0250] Determine the instance contrast loss between images, for example, for each image instance x i , through two data enhancement transformations T a (i.e., the first data enhancement) and T b (i.e. second data enhancement) to generate enhanced image and As a positive sample pair. Use the student network f(·), the teacher network f ξ (·), we get two pairs of different view representations. and

[0251] in, is the data augmentation transformation T of the student network f(·) a The enhanced image Image features for feature extraction.

[0252] The embodiment of the present application uses cosine distance to measure the contrast loss between images, normalizes the features passed through the student network and the teacher network to obtain normalized positive samples, and then aligns the features of the two view representation pairs in the normalized positive sample pairs to learn discriminative image features.

[0253] The calculation method for determining the instance contrast loss between images is as shown in formula (1).

[0254]

[0255] Among them, g(·) is a predictor used to maintain the stability of the two networks. and Calculate the instance contrast loss and find the average of the instance contrast losses obtained by the representation of the two views as the final instance contrast loss. a ) is the result obtained by the predictor after the student network extracts features, N is the number of samples in a single batch, z a , Under two different enhancements, the student network f(·) and the teacher network f ξ (·) The view obtained by feature extraction.

[0256] The following is an explanation of the process in the semantic similarity module 502 provided in the embodiment of the present application. First, the input image instance x i Perform nearest neighbor batch construction.

[0257] The way of constructing mini-batch training has a huge impact on the performance of metric learning. The embodiment of the present application proposes a strategy based on nearest neighbor search. For each mini-batch, q query samples are randomly sampled, and then the k-1 nearest neighbor samples (including the query sample and its k-1 nearest neighbors) (i.e., the neighbor image set) of each query sample are searched according to similarity to obtain the number of samples in the current mini-batch, q*k. Unlike the pk sampling batch construction method in the related art, i.e., randomly sampling and selecting k images from p different categories, the embodiment of the present application proposes a strategy based on nearest neighbor search that is simple and fast, does not require knowing the sample category, and allows the mini-batch to contain diverse and related samples.

[0258] Second, the contextual semantic similarity between images is determined.

[0259] Through the Teacher Network ξ (·) We approximate class equivalence relations by using the semantic similarity between the data in the embedding space obtained, which is used as synthetic soft supervision to learn the student network. The quality of the predicted semantic similarity as the only supervision for training is crucial to improving model accuracy. However, computing reliable semantic similarity is not trivial, especially in the early stages of unsupervised learning when the teacher network is obviously incomplete and cannot grasp the semantic relationship between data in the early stages of unsupervised learning.

[0260] To overcome this challenge, the embodiments of the present application measure the combination of pairwise similarity and contextual similarity of a pair of data in the teacher embedding feature space by determining the contextual semantic similarity between images. Contextual information, i.e., the neighborhood on the data manifold, is introduced when predicting semantic similarity. Rather than just considering the relationship between two images of interest, i.e., the similarity between the two images is greater than the similarity threshold, their indirect semantic relationship is found through their context. Their multiple indirect semantic relationships help capture the common patterns, i.e., common features, that are often observed in each class, thereby understanding potential class equivalence relationships.

[0261] Two samples z iξ (i.e. the first image feature) and z jξ The pairwise similarity of (i.e., the second image feature) is expressed as It is given by formula (2).

[0262]

[0263] Among them, z iξ and z jξ Is the teacher network ξ (·) embedding vector, σ is the Gaussian kernel bandwidth.

[0264] When the teacher embedding feature space is pre-trained in a fully supervised manner, it is known that such pairwise similarities can encode information about z jξ and z jξ The information encoded by the relationship includes the category information provided by supervised learning and the distance of similarity between samples, but the category information is missing in unsupervised metric learning. Therefore, the category information is supplemented by determining the context similarity.

[0265] The basic assumption of context similarity is that the more semantically similar two samples are, the greater their context overlap is. Related techniques use the nearest neighbors of data points in the teacher embedding feature space as their context, but when the embedding feature space has not been fully trained, the samples in the embedding feature space usually contain irrelevant data. The present embodiment uses the k-reciprocal nearest neighbor relation as the similarity context to discover highly relevant candidate samples. t The k-reciprocal nearest neighbor set (i.e., the reciprocal neighbor set) of is given by formula (3).

[0266] R k (t) = {j|(j∈N k (i))∧(i∈N k (j))} (3)

[0267] Among them, N k(i) is x t Among the current k nearest neighbors, the k nearest neighbors of one sample i include itself (ie, i∈N k (i)), we can determine that j is one of the k nearest neighbors of sample i, and obtain the k nearest neighbors of sample j. When the k nearest neighbors of sample j include sample i, sample j is determined as a sample in the k-reciprocal nearest neighbor set. k (t) corresponds to sample x t The set of k-reciprocal nearest neighbors.

[0268] The initial form of contextual similarity measures R k (i) (i.e., the first reciprocal neighbor set) and R k (j) (i.e., the second reciprocal neighbor set) is the degree of overlap between the two, where R k (i) corresponds to sample x i The k-reciprocal nearest neighbor set, R k (i) corresponds to sample x i k-reciprocal nearest neighbor set, while considering whether x i and x j In a k-reciprocal nearest neighbor relationship. Since the size of the neighbor set x i and x j will be different, and the asymmetric Jaccard similarity design is obtained as shown in formula (4).

[0269]

[0270] In addition, the embodiment of the present application adopts the idea of ​​query expansion to further improve its reliability. Specifically, It is restated as the average of the contextual similarities of multiple nearest neighbor subsets in the nearest neighbor set as shown in formula (5).

[0271]

[0272] Among them, from the k samples of the nearest neighbor, k / 2 samples are selected as the subset of the nearest neighbor, and the corresponding context similarity is determined according to each subset, and the context similarity is determined by the weighted average result of multiple context similarities The expanded version in (5) is no longer symmetric. To ensure symmetry, the final form of context similarity is defined as and of and, With A similar calculation process will be By replacing the subscripts in the calculation process, we can get The embodiments of the present application are The method of obtaining is not repeated here, and the final form of context similarity is given by formula (6).

[0273]

[0274] Finally, the contextual semantic similarity is defined as the average of the pairwise similarity in equation (2) and the contextual similarity in equation (6), as shown in equation (7):

[0275]

[0276] in and Both are within [0, 1], so their weights are balanced. Contextual semantic similarity effectively represents the semantic relevance between data by considering the pairwise relationship and contextual semantics of the data, which is highly correlated with the truth class equivalence.

[0277] Third, learn about student networks.

[0278] A soft adversarial loss is adopted, which aims to optimize the student network using soft labels obtained by contextual semantic similarity as comprehensive supervision. The contextualized semantic similarity is used as the weight of the attraction and repulsion terms of the loss, thus determining the force of pulling or pushing a pair of data on the student embedding feature space.

[0279] Calculated context similarity loss As shown in formula (8).

[0280]

[0281] where w ij is the context similarity calculated in the third step, and the distance measure between two samples is where z is the feature generated by the embedding vectors of all student networks f(·) in the batch, n is the number of samples in the batch, and δ is the margin.

[0282] The following is an explanation of the process in the clustering module 503 provided in the embodiment of the present application.

[0283] First, obtain clustering consistency.

[0284] The features z generated by the embedding vectors of all student networks f(·) in the batch data, and all teacher networks f ξ (·) Generated feature z ξ , after the clustering network module c(·), we get the distribution probability Q = c(z) and Q ξ =c(z ξ), the Kullback-Leibler divergence of the two distributions is calculated as shown in formula (9), where the clustering network c(·) is used to project the original feature z to the cluster distribution p of K categories.

[0285]

[0286] Second, obtain the clustering regularization term.

[0287] To avoid the degenerate solution where most samples are assigned to a minority of clusters, a clustering regularization loss is added. When a degenerate solution appears, the regularization loss value becomes larger, while the regularization loss value is small when the uniform distribution occurs.

[0288] The distribution probability Q is shown in formula (10) and formula (11).

[0289]

[0290]

[0291] Among them, q i Represents the features extracted by the student network and assigned to cluster category c i The probability of ξi It can represent that the features extracted by the teacher network are assigned to the cluster category c i probability.

[0292] pass Calculate the distribution entropy, the distribution of each category is calculated by get.

[0293] Third, obtain the clustering loss.

[0294] The final clustering loss It can be obtained by the following formula (12).

[0295]

[0296] Among them, KL(Q,Q ξ ) is Q, Q ξ The KL divergence of the distribution, is the regularization term.

[0297] In the embodiment of the present application, after the instance contrast loss in the contrast representation learning module 501, the context semantic loss in the semantic similarity learning module 502, and the clustering loss in the clustering module 503 are obtained through multiple modules, the total loss function is calculated, wherein the instance contrast loss in the contrast representation learning module 501 is Used to learn the representation of a single instance, the contextual semantic similarity loss in the semantic similarity learning module 502 Used to learn similarities within a dataset, clustering loss in clustering module 503 To learn category-related information, we finally get the total loss function and train the model, as shown in formula (13).

[0298]

[0299] Among them, λ cont It is used to characterize the influence of similarity in the data set on the model loss, λ cluster Used to characterize the impact of category-related information on model loss.

[0300] The embodiment of the present application performs a momentum update of the teacher model after obtaining the total loss.

[0301] For example, the teacher model f ξ (·) is updated as the student network model f(·) is trained, so as to gradually enhance the synthetic supervision calculated from the teacher embedding space. The related art is to replace the teacher network model with the student network model at each iteration. However, this will reduce the consistency of synthetic supervision in the iteration, resulting in unstable training of the student network model. In order to improve the stability of model feature extraction, the embodiment of the present application is based on the moving average (EMA) operation of momentum, and updates the teacher model f through the parameter θ of the student network model f(·) ξ The parameter θ of (·) ξ , the update formula is shown in formula (13):

[0302] θ ξ ←mθ ξ +(1-m)θ (13)

[0303] Among them, the parameters θ of the student network model are updated through back propagation, m∈[0, 1] is the coefficient that controls the momentum update rate. As its value increases, the update speed of the teacher network model will slow down.

[0304] The following is an explanation of the algorithm flow of the model training method provided in the embodiment of the present application.

[0305] Step 601, initializing the input data.

[0306] The following is an explanation of the data initialization in step 601 of the model training method provided in an embodiment of the present application.

[0307] First, by loading image data, a data set D is obtained. Based on a specific data size (for example, 64), the images in the data set are sampled according to the nearest neighbor batch construction method in the semantic similarity learning module 502 (each batch of data selects k-1 nearest neighbor samples), and the images are loaded as a processing batch to obtain a nearest neighbor-based batch data B.

[0308] Second, construct an image enhancement transformation set T, where transformation T includes common image enhancement methods, including random cropping to a uniform size (such as 224×224), random left and right flipping, random color jittering, random grayscale transformation, etc.

[0309] Step 602: Initialize the model.

[0310] The following is an explanation of the initialization of the model in step 602 of the model training method provided in the embodiment of the present application.

[0311] First, before model optimization, a student network f(·) is constructed based on the basic feature extraction backbone network (resnet residual network or VGG network, etc.) and the projection network (including feature linear connection layer, relu activation function layer, batch normalization layer and target linear connection layer), and a teacher network f(·) is constructed based on the student network f(·). ξ (·), where the teacher network f ξ (·) network parameters θ ξ Keep the original network structure parameters θ consistent, but stop gradient updating and do not perform derivation through the back-propagation algorithm.

[0312] Second, construct the prediction layer network g(·) (including feature linear connection layer, relu activation function layer, batch normalization layer and target linear connection layer).

[0313] Third, a clustering layer network c(·) is constructed (including a feature linear connection layer (including a feature linear connection layer, a relu activation function layer, a batch normalization layer, and a target linear connection layer).

[0314] Step 603: training the model.

[0315] The model training process in step 602 of the model training method provided in an embodiment of the present application is explained below.

[0316] First, for each image instance x in the processing batch B in the dataset, i , through two random data augmentation transformations T a and T b Enhance the data to obtain the converted data x a and x b .

[0317] Second, through the student network f(·), the teacher network f ξ (·), predictor g(·) and stop gradient operation, and obtain two pairs of different view representations (z a ←f(x a ), and (z b ←f(x b ), ).in Compute instance-based contrastive loss based on feature representation

[0318] Third, based on the feature z obtained by the teacher network ξ Calculate the contextual semantic similarity W, where w ij Represents z iξ and z jξ The contextual semantic similarity of . Combine the features z obtained by the student network and calculate the contextual semantic loss

[0319] Fourth, based on the classification network c(·) and features (z and z ξ ) Calculate the distribution probability Q a and The clustering loss is calculated based on the clustering consistency and clustering regularization in the clustering module 503 respectively.

[0320] Fifth, the total loss is finally obtained

[0321] Sixth, based on the optimizer (stochastic gradient optimizer sgd, or adaptive momentum optimizer adam, etc.), the cosine annealing function is sampled to update the learning rate lr in real time to minimize the total loss The back-propagation algorithm is used to perform derivation and update the network parameters of the encoder f(·), prediction layer g(·), and clustering layer c(·).

[0322] Seventh, based on the exponential moving average algorithm and momentum m, the momentum encoder f ξ (·) The network parameters are updated with momentum, θ ξ ←mθ ξ +(1-m)θ.

[0323] Eighth, perform a specific number of rounds of optimization to obtain the final model and save the encoder f of the teacher model ξ (·) and clustering networks for image classification clustering tasks.

[0324] The following is an explanation of the algorithm flow of a specific application scenario of the model method provided in an embodiment of the present application.

[0325] Step 701, construct a teacher-student model network based on contextual semantic clustering, initialize the network parameters, and process the data in the unlabeled data set according to the data loading method in the model to obtain a series of different batches of data.

[0326] Step 702: The graph convolutional contrast clustering model is trained for 200-1000 rounds according to the algorithm flow in step 603. In each round of training, the single instance loss, contextual semantic loss and clustering loss are calculated based on each batch to obtain the total loss, and the model parameters are optimized by minimizing the total loss value. The teacher and student network parameters are further updated by reverse derivation and EMA exponential moving update to obtain the optimized model.

[0327] Step 703, further extracting an evaluation network model (including a teacher network and a clustering network) based on the teacher-student network model for specific reasoning tasks such as classification and clustering.

[0328] By training a large amount of unlabeled data through the semantic similarity clustering model, an effective image encoding network and clustering classification network are obtained. This network can be used for image feature extraction and clustering.

[0329] In summary, the embodiment of the present application obtains the global contextual semantic information of the data set through similarity sampling, learns the contextual semantic similarity within the batch through the teacher model, and helps the model learn more accurate contextual semantic features between samples and the complex associations between data, thereby obtaining more accurate clustering classification information. By introducing contextual semantic similarity for the first time to solve the problem of inaccurate extraction of semantic related information by early models, the model's feature extraction ability for unlabeled samples is effectively improved, as well as the accuracy of image clustering, and after model training, a clustering network with better performance is obtained. The clustering network can be used for face feature extraction, and further used in application scenarios such as face recognition, face attribute recognition, and face detection. In addition, the sampling module of the embodiment of the present application directly divides the samples into multiple groups, which helps to more effectively obtain the semantic features of adjacent samples, while considering the similarity between sample features and the association between different samples, and can more effectively mine the association between sample features of the data set, improve the model's feature extraction ability for unlabeled samples, and effectively improve the accuracy of clustering.

[0330] Below, an exemplary application of the image method provided in an embodiment of the present application in a practical application scenario will be described.

[0331] Taking image classification as an example, see Figure 6 , Figure 6 This is a schematic diagram of the image classification principle provided in an embodiment of the present application.

[0332] like Figure 6 As shown, the embodiment of the present application proposes an image classification method.

[0333] The input image is fed into the trained teacher network and the obtained features are fed into the classifier to obtain the classification of the input image.

[0334] In summary, the embodiment of the present application obtains the global contextual semantic information of the data set through similarity sampling, and learns the contextual semantic similarity within the batch through the teacher network, thereby obtaining a teacher network containing contextual semantic information, which helps the model learn more accurate contextual semantic features between samples and the complex associations between data, thereby obtaining more accurate clustering and classification information.

[0335] The following is a description of an exemplary structure of a model training device 555 provided in an embodiment of the present application implemented as a software module. In some embodiments, Figure 2A As shown, the software modules stored in the model training device 555 of the memory 550 may include:

[0336] The feature extraction module 5551 is used to extract features from the first image and the second image through an image processing model to obtain first image features corresponding to the first image and second image features corresponding to the second image.

[0337] The acquisition module 5552 is used to determine the pairwise similarity between the first image and the second image based on the similarity between the first image feature and the second image feature; and determine the contextual similarity between the first image and the second image based on the neighbor image set of the first image and the neighbor image set of the second image.

[0338] The updating module 5553 is used to update the parameters of the image processing model based on the pairwise similarity and the contextual similarity.

[0339] In some embodiments, the feature extraction module 5551 is also used to perform feature extraction on the first enhanced image of the first image through an image processing model to obtain a first enhancement of the first enhanced image; perform data processing on the first enhanced feature to obtain a first image feature of the first image; perform feature extraction on the second enhanced image of the second image through the image processing model to obtain a second enhanced feature of the second enhanced image; perform data processing on the second enhanced feature to obtain a second image feature of the second image.

[0340] In some embodiments, the acquisition module 5552 is further used to determine a first reciprocal neighbor image set based on the neighbor image set of the first image, and to determine a second reciprocal neighbor image set based on the neighbor image set of the second image, wherein the first reciprocal neighbor image set includes images that are neighbors of the neighbor images of the first image, and the second reciprocal neighbor image set includes images that are neighbors of the neighbor images of the second image; based on the second reciprocal neighbor image set, determine a first similarity between the first image and the second image, and based on the first reciprocal neighbor image set, determine a second similarity between the first image and the second image; perform data processing on the first similarity and the second similarity to obtain contextual similarity between the first image and the second image.

[0341] In some embodiments, the acquisition module 5552 is further used to acquire, for each neighbor image in the target neighbor image set, a first neighbor image of the neighbor image and a second neighbor image of the first neighbor image; if the second neighbor image is the same as the neighbor image, the first neighbor image is added to the target reciprocal neighbor image set; when the target neighbor image set is the neighbor image set of the first image, the target reciprocal neighbor image set of the target neighbor image set is the first reciprocal neighbor image set, and when the target neighbor image set is the neighbor image set of the second image, the target reciprocal neighbor image set of the target neighbor image set is the second reciprocal neighbor image set.

[0342] In some embodiments, the acquisition module 5552 is further used to determine a first intersection of the first reciprocal neighbor image set and the second reciprocal neighbor image set; determine the first intersection as an overlapping reciprocal neighbor image set, and determine a first ratio of the number of images in the overlapping reciprocal neighbor image set to the number of images in the first reciprocal neighbor image set; and determine the first ratio as a first similarity.

[0343] In some embodiments, the acquisition module 5552 is further used to select N first neighbor image subsets from the neighbor image set of the first image; determine N first reciprocal neighbor image subsets of the N first neighbor image subsets; one first neighbor image subset corresponds to one first reciprocal neighbor image subset; for each first reciprocal neighbor image subset, determine a second intersection between the first reciprocal neighbor image subset and the second reciprocal neighbor image set, and determine a second ratio of the number of images in the second intersection to the number of images in the first reciprocal neighbor image subset; perform data processing on the determined N second ratios to obtain a first similarity between the first image and the second image.

[0344] In some embodiments, the update module 5553 is also used to perform data processing on pairwise similarity and contextual similarity to obtain contextual semantic similarity; obtain the third image feature of the first image and the fourth image feature of the second image, and determine the distance between the third image feature and the fourth image feature; determine the loss value based on the distance and the contextual semantic similarity, and update the parameters of the image processing model based on the loss value.

[0345] In some embodiments, the update module 5553 is also used to perform feature extraction on the first enhanced image of the first image through the student model to obtain a third enhanced feature corresponding to the first enhanced image; perform data processing on the third enhanced feature to obtain a third image feature corresponding to the first image; perform feature extraction on the second enhanced image of the second image through the student model to obtain a fourth enhanced feature corresponding to the second enhanced image; perform data processing on the fourth enhanced feature to obtain a fourth image feature corresponding to the second image.

[0346] In some embodiments, the update module 5553 is also used to perform backpropagation on the student model based on the loss value to obtain updated parameters of the student model; obtain momentum parameters, wherein the momentum parameters are used to control the update degree of the parameters of the image processing model; based on the momentum parameters and the updated parameters of the student model, the parameters of the image processing model are processed to obtain updated parameters of the image processing model.

[0347] In some embodiments, the update module 5553 is also used to classify the third image feature and the fourth image feature through a classifier to obtain a first distribution probability; classify the first image feature and the second image feature through a classifier to obtain a second distribution probability; perform data processing on the first distribution probability and the second distribution probability to obtain a clustering loss value; perform processing based on the clustering loss value, distance, and contextual semantic similarity to obtain a loss value.

[0348] In some embodiments, the update module 5553 is also used to classify the third image feature through a classifier to obtain the distribution probability of the third image feature; classify the fourth image feature through a classifier to obtain the distribution probability of the fourth image feature; and perform data processing on the distribution probability of the third image feature and the distribution probability of the fourth image feature to obtain the first distribution probability.

[0349] The following is a description of an exemplary structure of the image classification device 556 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 2B As shown, the software modules stored in the image classification device 556 of the memory 550 may include:

[0350] The feature extraction module 5561 is used to extract features of the input image through an image processing model to obtain image features corresponding to the input image, wherein the image processing model is trained by the model training method provided in the embodiment of the present application.

[0351] The image classification module 5562 is used to classify the image features through a classifier to obtain the category to which the input image belongs.

[0352] An embodiment of the present application provides a computer program product, which includes computer executable instructions. The computer executable instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer executable instructions from the computer-readable storage medium, and the processor executes the computer executable instructions, so that the electronic device executes the model training method or image classification method described above in the embodiment of the present application.

[0353] The present application embodiment provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions or computer programs are stored. When the computer-executable instructions or computer programs are executed by a processor, the processor will be caused to execute the model training method provided by the present application embodiment, for example, FIG. 3A to FIG. 3K The model training method shown or Figure 4 The image classification method is shown.

[0354] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.

[0355] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0356] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0357] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0358] In summary, through the embodiments of the present application, features of the first image and the second image are extracted with the help of an image processing model to obtain first image features corresponding to the first image and second image features corresponding to the second image, and based on the similarity between the first image features and the second image features, the pairwise similarity between the first image and the second image is determined, and based on the neighbor image set of the first image and the neighbor image set of the second image, the contextual similarity between the first image and the second image is determined, and then, the parameters of the image processing model are updated based on the pairwise similarity and the contextual similarity, while taking into account the similarity between sample features and the association between different samples, so as to more effectively mine the association between sample features, and learn the contextual similarity through the image processing model, thereby further improving the accuracy of image classification using the image processing model.

[0359] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A model training method, characterized in that: The method comprises: Extracting features from the first image and the second image using an image processing model to obtain first image features of the first image and second image features of the second image; determining a pairwise similarity between the first image and the second image based on a similarity between the first image feature and the second image feature; determining contextual similarity between the first image and the second image based on a neighbor image set of the first image and a neighbor image set of the second image; Parameters of the image processing model are updated based on the pairwise similarity and the contextual similarity.

2. The method according to claim 1, characterized in that The extracting features of the first image and the second image by using the image processing model to obtain a first image feature of the first image and a second image feature of the second image includes: Extracting features of a first enhanced image of the first image by using an image processing model to obtain first enhanced features of the first enhanced image; Performing data processing on the first enhanced feature to obtain a first image feature of the first image; Extracting features of a second enhanced image of the second image by using the image processing model to obtain second enhanced features of the second enhanced image; Data processing is performed on the second enhanced feature to obtain a second image feature of the second image.

3. The method according to claim 1, characterized in that The determining, based on the neighbor image set of the first image and the neighbor image set of the second image, the context similarity between the first image and the second image comprises: Determine a first reciprocal neighbor image set based on the neighbor image set of the first image, and determine a second reciprocal neighbor image set based on the neighbor image set of the second image, wherein the first reciprocal neighbor image set includes images that are neighbors of the neighbor images of the first image, and the second reciprocal neighbor image set includes images that are neighbors of the neighbor images of the second image; determining a first similarity between the first image and the second image based on the second reciprocal neighbor image set, and determining a second similarity between the first image and the second image based on the first reciprocal neighbor image set; Data processing is performed on the first similarity and the second similarity to obtain context similarity between the first image and the second image.

4. The method according to claim 3, characterized in that The target neighbor image set includes a neighbor image set of the first image and a neighbor image set of the second image; when the target neighbor image set is the neighbor image set of the first image, the target reciprocal neighbor image set of the target neighbor image set is the first reciprocal neighbor image set, and when the target neighbor image set is the neighbor image set of the second image, the target reciprocal neighbor image set of the target neighbor image set is the second reciprocal neighbor image set; Determining the target reciprocal neighbor image set based on the target neighbor image set includes: For each neighbor image in the target neighbor image set, acquiring a first neighbor image of the neighbor image and a second neighbor image of the first neighbor image; If the second neighbor image is the same as the neighbor image, the first neighbor image is added to the target reciprocal neighbor image.

5. The method according to claim 3, characterized in that: The determining, based on the second reciprocal neighbor image set, a first similarity between the first image and the second image comprises: Determine a first intersection of the first reciprocal neighbor image set and the second reciprocal neighbor image set; Determine the first intersection as an overlapping reciprocal neighbor image set, and determine a first ratio of the number of images in the overlapping reciprocal neighbor image set to the number of images in the first reciprocal neighbor image set; The first ratio is determined as the first similarity.

6. The method according to claim 3, characterized in that: The determining, based on the second reciprocal neighbor image set, a first similarity between the first image and the second image comprises: Selecting N first neighbor image subsets from the neighbor image set of the first image; Determine N first reciprocal neighbor image subsets of the N first neighbor image subsets; one first neighbor image subset corresponds to one first reciprocal neighbor image subset; For each first reciprocal neighbor image subset, determining a second intersection between the first reciprocal neighbor image subset and the second reciprocal neighbor image set, and determining a second ratio of the number of images in the second intersection to the number of images in the first reciprocal neighbor image subset; The determined N second ratios are subjected to data processing to obtain a first similarity between the first image and the second image.

7. The method according to claim 1, characterized in that The updating of the parameters of the image processing model based on the pairwise similarity and the contextual similarity comprises: Performing data processing on the pairwise similarity and the contextual similarity to obtain contextual semantic similarity; Acquire a third image feature of the first image and a fourth image feature of the second image, and determine a distance between the third image feature and the fourth image feature; A loss value is determined based on the distance and the contextual semantic similarity, and parameters of the image processing model are updated based on the loss value.

8. The method according to claim 7, characterized in that The image processing model is a teacher model, and the obtaining of the third image feature of the first image and the fourth image feature of the second image includes: Extracting features of the first enhanced image of the first image by using a student model to obtain a third enhanced feature corresponding to the first enhanced image; Performing data processing on the third enhanced feature to obtain a third image feature corresponding to the first image; Extracting features of the second enhanced image of the second image by using the student model to obtain fourth enhanced features corresponding to the second enhanced image; Data processing is performed on the fourth enhanced feature to obtain a fourth image feature corresponding to the second image.

9. The method according to claim 8, characterized in that The updating of the parameters of the image processing model based on the loss value comprises: Based on the loss value, back-propagating the student model to obtain updated parameters of the student model; Acquiring a momentum parameter, wherein the momentum parameter is used to control the updating degree of the parameters of the image processing model; Based on the momentum parameters and the updated parameters of the student model, the parameters of the image processing model are processed to obtain the updated parameters of the image processing model.

10. The method according to claim 7, characterized in that The determining of the loss value based on the distance and the context semantic similarity comprises: Classifying the third image feature and the fourth image feature by a classifier to obtain a first distribution probability; Classifying the first image feature and the second image feature by a classifier to obtain a second distribution probability; Performing data processing on the first distribution probability and the second distribution probability to obtain a clustering loss value; Processing is performed based on the clustering loss value, the distance, and the context semantic similarity to obtain a loss value.

11. The method according to claim 10, characterized in that The classifying the third image feature and the fourth image feature by a classifier to obtain a first distribution probability includes: Classifying the third image feature by a classifier to obtain a distribution probability of the third image feature; Classifying the fourth image feature by a classifier to obtain a distribution probability of the fourth image feature; The distribution probability of the third image feature and the distribution probability of the fourth image feature are processed to obtain a first distribution probability.

12. An image classification method, characterized in that: The method comprises: Extracting features of an input image through an image processing model to obtain image features of the input image, wherein the image processing model is trained by the model training method according to any one of claims 1 to 11; The image features are classified by a classifier to obtain the category to which the input image belongs.

13. A model training device, characterized in that: The device comprises: A feature extraction module, used to extract features from the first image and the second image through an image processing model to obtain a first image feature of the first image and a second image feature of the second image; an acquisition module, configured to determine a pairwise similarity between the first image and the second image based on a similarity between features of the first image and features of the second image; and determine a contextual similarity between the first image and the second image based on a neighbor image set of the first image and a neighbor image set of the second image; An updating module is used to update the parameters of the image processing model based on the pairwise similarity and the contextual similarity.

14. An image classification device, characterized in that: The device comprises: A feature extraction module, used to extract features of an input image through an image processing model to obtain image features corresponding to the input image, wherein the image processing model is trained by the model training method according to any one of claims 1 to 11; The image classification module is used to classify the image features through a classifier to obtain the category to which the input image belongs.

15. An electronic device, characterized in that: The electronic device comprises: A memory for storing computer executable instructions; A processor, for implementing the model training method described in any one of claims 1 to 11, or implementing the image classification method described in claim 12, when executing the computer executable instructions or computer programs stored in the memory.

16. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the model training method described in any one of claims 1 to 11 is implemented, or the image classification method described in claim 12 is implemented.

17. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the model training method described in any one of claims 1 to 11 is implemented, or the image classification method described in claim 12 is implemented.

Citation Information

Patent Citations

  • Image similarity judgment method and system

    CN113313192A

  • Image classification method, model training method, equipment and storage medium

    CN116524266A

  • Image classification method and system based on source domain independent domain adaptation and active learning

    CN116863186A

  • Model training method and device, image classification method and device and electronic equipment

    CN117218399A

  • Unsupervised domain adaptation with similarity learning for images

    US20190325299A1