CN111680754B - Image classification method, device, electronic equipment and computer readable storage medium - Google Patents

Image classification method, device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN111680754B
CN111680754B CN202010529538.7A CN202010529538A CN111680754B CN 111680754 B CN111680754 B CN 111680754B CN 202010529538 A CN202010529538 A CN 202010529538A CN 111680754 B CN111680754 B CN 111680754B
Authority
CN
China
Prior art keywords
category
real
loss function
error coefficient
classification model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010529538.7A
Other languages
Chinese (zh)
Other versions
CN111680754A (en
Inventor
王诗吟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Douyin Vision Co Ltd
Original Assignee
Douyin Vision Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Douyin Vision Co Ltd filed Critical Douyin Vision Co Ltd
Priority to CN202010529538.7A priority Critical patent/CN111680754B/en
Publication of CN111680754A publication Critical patent/CN111680754A/en
Application granted granted Critical
Publication of CN111680754B publication Critical patent/CN111680754B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • G06F18/241Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches

Abstract

The application provides an image classification method, an image classification device, electronic equipment and a computer readable storage medium, and relates to the technical field of image processing. The method comprises the following steps: acquiring an image to be classified; inputting the images to be classified into a classification model to obtain the categories of the images; the classifying model is obtained by adjusting parameters of the initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model by an error coefficient; the error coefficient is determined based on the true class of the sample image input to the initial classification model and the predicted class output by the initial classification model. The image classification method provided by the application can improve the accuracy of image classification.

Description

Image classification method, device, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of image processing technology, and in particular, to an image classification method, an apparatus, an electronic device, and a computer readable storage medium.
Background
With the development of artificial intelligence technology, people began to train artificial intelligence models using artificial intelligence technology to solve various problems.
At present, when objects in an image are identified and classified, if the predicted category is different from the real category, the deviation between the predicted category and the real category is likely to be large, for example, a tea table is classified, the real category of the tea table is furniture category, and if the real category is not classified, the real category is possibly classified into a completely irrelevant category, such as a tableware category, a chair category and the like. In this case, the accuracy of the classification result of the existing classification model is low.
Disclosure of Invention
The summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.
In a first aspect, there is provided an image classification method, the method comprising:
acquiring an image to be classified;
inputting the images to be classified into a classification model to obtain the categories of the images;
the classifying model is obtained by adjusting parameters of the initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model by an error coefficient; the error coefficient is determined based on the true class of the sample image input to the initial classification model and the predicted class output by the initial classification model.
In a second aspect, there is provided an image classification apparatus comprising:
the acquisition module is used for acquiring the images to be classified;
the classification module is used for inputting the images to be classified into the classification model to obtain the categories of the images;
the classifying model is obtained by adjusting parameters of the initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model by an error coefficient; the error coefficient is determined based on the true class of the sample image input to the initial classification model and the predicted class output by the initial classification model.
In a third aspect, an electronic device is provided, the electronic device comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to: performing an implementation of the image classification method shown in the first aspect of the present disclosure.
In a fourth aspect, there is provided a computer readable medium having a computer program stored thereon, characterized in that the program, when executed by a processor, implements the image classification method according to the first aspect of the disclosure.
The beneficial effects that this disclosure provided technical scheme brought are:
the parameters of the classification model are obtained by adjusting the corrected loss function, the loss function is obtained by correcting the loss function of the initial classification model based on an error coefficient, the error coefficient is determined by the real type and the prediction type of the sample image, the loss function between the real type and the prediction type with high association degree with the real type can be adjusted to be smaller, the model tends to output the real type, the next output is the prediction type with high association degree with the real type, and even if the type output by the trained model is different from the real type, the model with high association degree with the real type can effectively improve the classification accuracy.
Further, if one sample image belongs to at least two real categories, any one of the real categories can be used as a prediction category corresponding to the other real category, and the loss function is corrected to be smaller, so that the model tends to output any one of the at least two real categories, and the accuracy of model classification is improved.
Further, the association degree between the real category and the predicted category can be determined first, if the association degree is larger, the error coefficient is required to be set if the corresponding error coefficient is smaller, and if the association degree is smaller, the error coefficient is larger, and is close to 1 if the corresponding error coefficient is larger, the error coefficient is possibly not required to be set, so that when the association degree is larger than a preset threshold value, the error coefficient can be determined again, and the calculated amount in the training process can be effectively reduced.
Additional aspects and advantages of the disclosure will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the disclosure.
Drawings
The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by reference to the following detailed description when taken in conjunction with the accompanying drawings. The same or similar reference numbers will be used throughout the drawings to refer to the same or like elements. It should be understood that the figures are schematic and that elements and components are not necessarily drawn to scale.
Fig. 1 is a schematic flow chart of an image classification method according to an embodiment of the disclosure;
fig. 2 is a schematic flow chart of an image classification method according to an embodiment of the disclosure;
FIG. 3 is a schematic illustration of one approach to determining relevance provided in one example of the present disclosure;
FIG. 4 is a schematic illustration of one approach to determining error coefficients provided in one example of the present disclosure;
FIG. 5 is a flow chart of an image classification method provided in one example of the present disclosure;
fig. 6 is a schematic structural diagram of an apparatus for classifying images according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an electronic device for image classification according to an embodiment of the present disclosure.
Detailed Description
Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While certain embodiments of the present disclosure have been shown in the accompanying drawings, it is to be understood that the present disclosure may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustration purposes only and are not intended to limit the scope of the present disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in this disclosure are used merely to distinguish one device, module, or unit from another device, module, or unit, and are not intended to limit the order or interdependence of the functions performed by the devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the various devices in the embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.
The present disclosure provides an image classification method, apparatus, electronic device, and computer readable medium, which aim to solve the above technical problems in the prior art.
The following describes the technical solutions of the present disclosure and how the technical solutions of the present disclosure solve the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
The embodiment of the disclosure provides an image classification method, which can be applied to a terminal for image classification, as shown in fig. 1, and the method can include:
step S101, obtaining an image to be classified;
step S102, inputting an image to be classified into a classification model to obtain the class of the image;
the classifying model is obtained by adjusting parameters of the initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model by an error coefficient; the error coefficient is determined based on the true class of the sample image input to the initial classification model and the predicted class output by the initial classification model.
Specifically, a sample image is input into an initial classification model, the sample image is marked with a real class, the initial classification model outputs a prediction class of the sample image, the association degree between the real class and the prediction class can be determined, an error coefficient is determined based on the association degree, a loss function is corrected based on the error coefficient, and parameters of the initial classification model are adjusted according to the corrected loss function, so that a classification model is obtained.
In the above embodiment, the parameters of the classification model are adjusted based on the corrected loss function, the loss function is obtained by correcting the loss function of the initial classification model based on the error coefficient, the error coefficient is determined by the real class and the predicted class of the sample image, and the loss function between the real class and the predicted class with high association with the real class can be adjusted to be smaller, so that the model tends to output the real class, and the next output is the predicted class with high association with the real class, even if the class output by the trained model is different from the real class, the class with high association with the real class can effectively improve the classification accuracy.
One possible implementation manner is provided in the embodiments of the present disclosure, and the classification model is trained based on the following manner:
step S101a, inputting the sample image marked with the real category into the initial classification model to obtain the predicted category of the sample image output by the initial classification model.
The real category is the actual category of the target in the sample image; the predicted category may be a category obtained by identifying and classifying the image by the initial classification model.
Specifically, the predicted category output by the initial classification model may be the same as the true category or may be different from the true category.
In step S101b of the process of the present invention, A loss function of the initial classification model is obtained based on the true class and the predicted class.
Specifically, the obtaining the loss function of the initial classification model based on the true class and the predicted class in step S101b may include:
(1) Acquiring a first feature vector corresponding to a real category, and acquiring a second feature vector corresponding to a predicted category;
(2) A loss function of the initial classification model is obtained based on the first feature vector and the second feature vector.
In the implementation process, the loss function of the initial classification model may be obtained according to the degree of difference between the first feature vector and the second feature vector, and the specific calculation process of the loss function is not limited herein.
Step S101c, determining an error coefficient between the target in the sample image and the prediction category.
Specifically, an error database may be preset, where a plurality of real categories are stored in the error database, each real category is correspondingly provided with a plurality of prediction categories, each real category includes at least one target, and an error coefficient is set between each target in each real category and a corresponding prediction category.
In the implementation process, an error coefficient between a target in a sample image and a prediction category can be queried in a preset error database.
Step S101d, correcting the loss function based on the error coefficient, and adjusting the parameters of the initial classification model based on the corrected loss function to obtain the classification model.
Specifically, the loss function is corrected based on the error coefficient, which may be that the error coefficient is multiplied by a loss value calculated by the loss function, and the obtained product is used as the corrected error coefficient; the parameters of the loss function may be corrected based on the error coefficient, and the specific correction procedure is not limited herein.
In the specific implementation process, if the loss value obtained by calculating the loss function is corrected based on the error coefficient, a classification model can be obtained when the corrected loss value is smaller than a preset threshold value; if the parameters of the loss function are corrected based on the error coefficient, the classification model can be obtained when the corrected loss function converges.
In the above embodiment, by determining the error coefficient between the target and the prediction category in the sample image and correcting the loss function based on the error coefficient, the parameters of the initial classification model are adjusted according to the corrected loss function, so as to obtain the classification model, and the accuracy of the classification result can be effectively improved.
In one possible implementation manner provided in the embodiments of the present disclosure, before determining the error coefficient between the target and the prediction category in the sample image in step S101c, the method may further include:
determining the association degree between the real category and the predicted category;
determining error coefficients between the true category and the predicted category of step S101c may include:
and if the determined association degree is greater than a preset threshold value, determining an error coefficient between the target in the sample image and the prediction category.
In the implementation process, the association degree between the real category and the predicted category can be determined first, if the association degree is larger, the error coefficient is required to be set more when the corresponding error coefficient is smaller, and if the association degree is smaller, the error coefficient is larger, the error coefficient is required to be set more when the corresponding error coefficient is closer to 1, so that the error coefficient is not required to be set, and the calculated amount in the training process can be effectively reduced when the association degree is larger than a preset threshold value.
In one possible implementation manner provided in the embodiments of the present disclosure, before determining the error coefficient between the target and the prediction category in the sample image in step S101c, the method may further include:
(1) A plurality of true categories and a plurality of predicted categories are obtained.
Specifically, a plurality of sample images can be obtained, each sample image is marked with a real category, and the plurality of sample images are respectively input into a classification model to obtain a prediction category corresponding to each sample image.
(2) For each real category, a degree of association between the real category and each predicted category is determined.
Wherein the degree of association between the real category and each predicted category may be determined by: when a certain target belongs to a real category, probability of simultaneously belonging to a predicted category is obtained, and correlation degree and obtained probability are positively correlated.
For example, the real category is a table category, the predicted category is a furniture category, the association degree between the table category and the furniture category is determined, the probability that one table belongs to the table category and simultaneously belongs to the furniture category can be determined, and the obtained probability is multiplied by a preset coefficient value to obtain the corresponding association degree.
It should be noted that the degree of association between the real category and each predicted category is not necessarily equal to the degree of association between the predicted category and the real category.
As shown in fig. 3, an association relationship correspondence table may be established, where a plurality of real categories are provided, each real category is provided with at least one prediction category, and a corresponding association degree is provided between each real category and each prediction category.
(3) An error coefficient between each target in the real class and each predicted class is set based on a degree of association between the real class and each predicted class.
Wherein the error coefficient may be a probability value between 0 and 1.
Specifically, the error coefficient between each target in each real category and each predicted category is inversely related to the degree of association between the real category and the predicted category.
That is, the greater the association degree between the real class and the predicted class, the greater the probability of belonging to the predicted class when a certain target simultaneously belongs to the real class, the greater the accuracy of judgment at this time, the smaller the corrected loss function which should be obtained, and the smaller the corresponding error coefficient.
(4) An error database is constructed based on the error coefficients between each target in each real class and each predicted class.
As shown in fig. 4, the error database may be a relationship comparison table among each target, prediction category and error coefficient in the real categories, each target in each real category is provided with at least one prediction category, and a corresponding error coefficient may be provided between each target in each real category and each prediction category.
For example, if the real category includes a tea table and a chair, and the corresponding prediction category is a table category, a smaller error coefficient can be set between the tea table and the table category, and a relatively larger error coefficient can be set between the chair and the table category, so that when the tea table is classified, the tea table is not classified into the furniture category, but is more prone to be classified into the table category.
In order to facilitate a clearer understanding of the above-described image classification method, the image classification method in the present application will be described below with reference to the accompanying drawings and specific examples.
As shown in fig. 5, in an example, the image classification method provided by the present application may include the following steps:
step S501, inputting a sample image marked with a real class into an initial classification model to obtain a predicted class of the sample image output by the initial classification model;
step S502, obtaining a loss function of an initial classification model;
step S503, determining the association degree between the real category and the predicted category;
step S504, judging whether the association degree between the real category and the predicted category is larger than a preset threshold value; if yes, go to step S505;
step S505, determining an error coefficient between a target in the sample image and a prediction category;
Step S506, correcting the loss function based on the error coefficient;
step S507, adjusting parameters of the initial classification model based on the corrected loss function to obtain a classification model;
step S508, obtaining an image to be classified;
step S509, inputting the images to be classified into the classification model to obtain the categories of the images.
According to the image classification method, parameters of the classification model are adjusted based on the corrected loss function, the loss function is obtained by correcting the loss function of the initial classification model based on the error coefficient, the error coefficient is determined by the real type and the prediction type of the sample image, the loss function between the real type and the prediction type with high association degree with the real type can be adjusted to be smaller, the model tends to output the real type, the next output is the prediction type with high association degree with the real type, and even if the type output by the trained model is different from the real type, the model is the type with high association degree with the real type, and the classification accuracy can be effectively improved.
Further, if one sample image belongs to at least two real categories, any one of the real categories can be used as a prediction category corresponding to the other real category, and the loss function is corrected to be smaller, so that the model tends to output any one of the at least two real categories, and the accuracy of model classification is improved.
Further, the association degree between the real category and the predicted category can be determined first, if the association degree is larger, the error coefficient is required to be set if the corresponding error coefficient is smaller, and if the association degree is smaller, the error coefficient is larger, and is close to 1 if the corresponding error coefficient is larger, the error coefficient is possibly not required to be set, so that when the association degree is larger than a preset threshold value, the error coefficient can be determined again, and the calculated amount in the training process can be effectively reduced.
An embodiment of the present disclosure provides an image classification apparatus 60, as shown in fig. 6, the image classification apparatus 60 may include: an acquisition module 601, and a classification module 602, wherein,
an acquisition module 601, configured to acquire an image to be classified;
the classification module 602 is configured to input an image to be classified into a classification model to obtain a class of the image;
the classifying model is obtained by adjusting parameters of the initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model by an error coefficient; the error coefficient is determined based on the true class of the sample image input to the initial classification model and the predicted class output by the initial classification model.
One possible implementation is provided in the presently disclosed embodiments, the image classification device 60 further comprises a training module for:
inputting the sample image marked with the real category into an initial classification model to obtain the predicted category of the sample image output by the initial classification model;
acquiring a loss function of the initial classification model based on the real class and the predicted class;
determining an error coefficient between a target in the sample image and the prediction category;
correcting the loss function based on the error coefficient, and adjusting the parameters of the initial classification model based on the corrected loss function to obtain the classification model.
One possible implementation is provided in the presently disclosed embodiments, the training module further comprises a determining unit for:
determining the association degree between the real category and the predicted category;
the training module in determining the error coefficients between the true class and the predicted class, the method is particularly used for:
and if the determined association degree is greater than a preset threshold value, determining an error coefficient between the real category and the predicted category.
The embodiment of the disclosure provides a possible implementation manner, and the training module is specifically used for acquiring a loss function of an initial classification model based on a real class and a predicted class:
Acquiring a first feature vector corresponding to a real category, and acquiring a second feature vector corresponding to a predicted category;
a loss function of the initial classification model is obtained based on the first feature vector and the second feature vector.
In one possible implementation manner provided in the embodiments of the present disclosure, the training module is specifically configured to, when determining an error coefficient between a target and a prediction category in a sample image:
inquiring an error coefficient between a target in a sample image and a prediction category in a preset error database; wherein, a plurality of real categories are stored in the error database, each real category containing at least one target; each real category is correspondingly provided with a plurality of prediction categories, and an error coefficient is arranged between each target in each real category and a corresponding prediction category.
In one possible implementation manner provided in the embodiments of the present disclosure, the image classification apparatus 60 further includes a construction module, where the construction module is configured to:
acquiring a plurality of real categories and a plurality of prediction categories;
for each real category, determining a degree of association between the real category and each predicted category;
setting an error coefficient between each target in the real category and each prediction category based on the association degree between the real category and each prediction category;
An error database is constructed based on the error coefficients between each target in each real class and each predicted class.
One possible implementation manner is provided in the embodiments of the present disclosure, where an error coefficient between any target in each real category and each corresponding prediction category is inversely related to a degree of association between the real category and the prediction category.
According to the image classification device, the parameters of the classification model are adjusted based on the corrected loss function, the loss function is obtained by correcting the loss function of the initial classification model based on the error coefficient, the error coefficient is determined by the real type and the prediction type of the sample image, the loss function between the real type and the prediction type with high association degree with the real type can be adjusted to be smaller, the model tends to output the real type, the next output is the prediction type with high association degree with the real type, and even if the type output by the trained model is different from the real type, the model is the type with high association degree with the real type, and the classification accuracy can be effectively improved.
Further, if one sample image belongs to at least two real categories, any one of the real categories can be used as a prediction category corresponding to the other real category, and the loss function is corrected to be smaller, so that the model tends to output any one of the at least two real categories, and the accuracy of model classification is improved.
Further, the association degree between the real category and the predicted category can be determined first, if the association degree is larger, the error coefficient is required to be set if the corresponding error coefficient is smaller, and if the association degree is smaller, the error coefficient is larger, and is close to 1 if the corresponding error coefficient is larger, the error coefficient is possibly not required to be set, so that when the association degree is larger than a preset threshold value, the error coefficient can be determined again, and the calculated amount in the training process can be effectively reduced.
The image classification device according to the embodiments of the present disclosure may perform an image classification method provided by the embodiments of the present disclosure, and its implementation principle is similar, and actions performed by each module in the image classification device according to each embodiment of the present disclosure correspond to steps in the image classification method according to each embodiment of the present disclosure, and detailed functional descriptions of each module in the image classification device may be specifically referred to the descriptions in the corresponding image classification method shown in the foregoing, which are not repeated herein.
Referring now to fig. 7, a schematic diagram of an electronic device 700 suitable for use in implementing embodiments of the present disclosure is shown. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 7 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
An electronic device includes: a memory and a processor, where the processor may be referred to as a processing device 701 hereinafter, the memory may include at least one of a Read Only Memory (ROM) 702, a Random Access Memory (RAM) 703, and a storage device 708 hereinafter, as specifically shown below:
as shown in fig. 7, the electronic device 700 may include a processing means (e.g., a central processor, a graphics processor, etc.) 701, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 702 or a program loaded from a storage means 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other through a bus 704. Input/output (I/O) interface 705 are also connected to the bus 704.
In general, the number of the devices used in the system, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 shows an electronic device 700 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 709, either from storage 708 or ROM 702. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 701.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable medium, or any combination of the two. The computer readable storage medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to:
acquiring an image to be classified;
inputting the images to be classified into a classification model to obtain the categories of the images;
wherein, the liquid crystal display device comprises a liquid crystal display device, the classification model is obtained by adjusting parameters of the initial classification model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model by an error coefficient; the error coefficient is determined based on the true class of the sample image input to the initial classification model and the predicted class output by the initial classification model.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules or units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Where the name of the module or unit does not constitute a limitation on the unit itself in some cases, for example, the classification module may also be described as "a module for classifying images".
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing information.
According to one or more embodiments of the present disclosure, there is provided an image classification method including:
acquiring an image to be classified;
inputting an image to be classified into a classification model to obtain the class of the image;
the classifying model is obtained by adjusting parameters of an initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model through an error coefficient; the error coefficient is determined based on a true class of a sample image input to an initial classification model and a predicted class output corresponding to the initial classification model.
According to one or more embodiments of the present disclosure, the classification model is trained based on:
inputting the sample image marked with the real category into the initial classification model to obtain the predicted category of the sample image output by the initial classification model;
acquiring a loss function of the initial classification model based on the real class and the prediction class;
determining the error coefficient between a target in the sample image and the prediction category;
Correcting the loss function based on the error coefficient, and adjusting the parameters of the initial classification model based on the corrected loss function to obtain the classification model.
According to one or more embodiments of the present disclosure, before the determining the error coefficient between the target in the sample image and the prediction category, the determining further includes:
determining a degree of association between the true category and the predicted category;
the determining error coefficients between the true class and the predicted class comprises:
and if the determined association degree is greater than a preset threshold value, determining the error coefficient between the target in the sample image and the prediction category.
According to one or more embodiments of the present disclosure, the obtaining a loss function of the initial classification model based on the true class and the predicted class includes:
acquiring a first feature vector corresponding to the real category, and acquiring a second feature vector corresponding to the predicted category;
a loss function of the initial classification model is obtained based on the first feature vector and the second feature vector.
According to one or more embodiments of the present disclosure, the determining the error coefficient between the target in the sample image and the prediction category includes:
Inquiring an error coefficient between a target in a sample image and the prediction category in a preset error database; wherein, the error database stores a plurality of real categories, each real category containing at least one target; each real category is correspondingly provided with a plurality of prediction categories, and an error coefficient is arranged between each target in each real category and a corresponding prediction category.
According to one or more embodiments of the present disclosure, before the determining the error coefficient between the true class and the predicted class, the method further includes:
acquiring a plurality of real categories and a plurality of prediction categories;
for each real category, determining a degree of association between the real category and each predicted category;
setting an error coefficient between each target in the real category and each prediction category based on the association degree between the real category and each prediction category;
the error database is constructed based on error coefficients between each target in each real class and each predicted class.
According to one or more embodiments of the present disclosure, the error coefficient between any target in each real class and each corresponding predicted class is inversely related to the degree of association between that real class and the predicted class.
The foregoing description is only of the preferred embodiments of the present disclosure and description of the principles of the technology being employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in this disclosure is not limited to the specific combinations of features described above, but also covers other embodiments which may be formed by any combination of features described above or equivalents thereof without departing from the spirit of the disclosure. Such as those described above, are mutually substituted with the technical features having similar functions disclosed in the present disclosure (but not limited thereto).
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present disclosure. Certain features that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.

Claims (9)

1. An image classification method, comprising:
acquiring an image to be classified;
inputting an image to be classified into a classification model to obtain the class of the image;
the classifying model is obtained by adjusting parameters of an initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model through an error coefficient; the error coefficient is determined based on the real category of the sample image input into the initial classification model and the prediction category output by the initial classification model correspondingly; correcting the loss function of the initial classification model by the error coefficient comprises correcting a loss value obtained by calculating the loss function based on the error coefficient or correcting a parameter of the loss function based on the error coefficient;
The classification model is trained based on the following modes:
inputting the sample image marked with the real category into the initial classification model to obtain the predicted category of the sample image output by the initial classification model;
acquiring a loss function of the initial classification model based on the real class and the prediction class;
determining the error coefficient between a target in the sample image and the prediction category;
correcting the loss function based on the error coefficient, and adjusting the parameters of the initial classification model based on the corrected loss function to obtain the classification model.
2. The image classification method according to claim 1, characterized in that before said determining the error coefficient between the target in the sample image and the prediction category, further comprises:
determining a degree of association between the true category and the predicted category;
the determining error coefficients between the true class and the predicted class comprises:
and if the determined association degree is greater than a preset threshold value, determining the error coefficient between the target in the sample image and the prediction category.
3. The image classification method according to claim 1, wherein the obtaining a loss function of the initial classification model based on the true class and the predicted class comprises:
acquiring a first feature vector corresponding to the real category, and acquiring a second feature vector corresponding to the predicted category;
a loss function of the initial classification model is obtained based on the first feature vector and the second feature vector.
4. The image classification method according to claim 1 or 2, characterized in that said determining the error coefficient between the target in the sample image and the prediction category comprises:
inquiring an error coefficient between a target in a sample image and the prediction category in a preset error database; wherein, the error database stores a plurality of real categories, each real category containing at least one target; each real category is correspondingly provided with a plurality of prediction categories, and an error coefficient is arranged between each target in each real category and a corresponding prediction category.
5. The image classification method according to claim 3, wherein before said determining the error coefficient between the true class and the predicted class, further comprising:
Acquiring a plurality of real categories and a plurality of prediction categories;
for each real category, determining a degree of association between the real category and each predicted category;
setting an error coefficient between each target in the real category and each prediction category based on the association degree between the real category and each prediction category;
the error database is constructed based on error coefficients between each target in each real class and each predicted class.
6. The method of claim 5, wherein the error coefficient between any object in each real class and each corresponding predicted class is inversely related to the degree of association between the real class and the predicted class.
7. An image classification apparatus, comprising:
the acquisition module is used for acquiring the images to be classified;
the classification module is used for inputting the images to be classified into the classification model to obtain the categories of the images;
the classifying model is obtained by adjusting parameters of an initial classifying model based on the corrected loss function; the corrected loss function is obtained by correcting the loss function of the initial classification model through an error coefficient; the error coefficient is determined based on the real category of the sample image input into the initial classification model and the prediction category output by the initial classification model correspondingly; correcting the loss function of the initial classification model by the error coefficient comprises correcting a loss value obtained by calculating the loss function based on the error coefficient or correcting a parameter of the loss function based on the error coefficient;
The image classification device further comprises a training module for:
inputting the sample image marked with the real category into an initial classification model to obtain the predicted category of the sample image output by the initial classification model;
acquiring a loss function of the initial classification model based on the real class and the predicted class;
determining an error coefficient between a target in the sample image and the prediction category;
correcting the loss function based on the error coefficient, and adjusting the parameters of the initial classification model based on the corrected loss function to obtain the classification model.
8. An electronic device, comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to: image classification method according to any one of claims 1-6 is performed.
9. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the image classification method according to any one of claims 1-6.
CN202010529538.7A 2020-06-11 2020-06-11 Image classification method, device, electronic equipment and computer readable storage medium Active CN111680754B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010529538.7A CN111680754B (en) 2020-06-11 2020-06-11 Image classification method, device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010529538.7A CN111680754B (en) 2020-06-11 2020-06-11 Image classification method, device, electronic equipment and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN111680754A CN111680754A (en) 2020-09-18
CN111680754B true CN111680754B (en) 2023-09-19

Family

ID=72454867

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010529538.7A Active CN111680754B (en) 2020-06-11 2020-06-11 Image classification method, device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN111680754B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113537123B (en) * 2021-07-28 2023-04-07 上海高德威智能交通系统有限公司 Gesture recognition method and device, electronic equipment and readable storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018107906A1 (en) * 2016-12-12 2018-06-21 腾讯科技(深圳)有限公司 Classification model training method, and data classification method and device
CN109800648A (en) * 2018-12-18 2019-05-24 北京英索科技发展有限公司 Face datection recognition methods and device based on the correction of face key point
CN109815988A (en) * 2018-12-27 2019-05-28 北京奇艺世纪科技有限公司 Model generating method, classification method, device and computer readable storage medium
CN109859113A (en) * 2018-12-25 2019-06-07 北京奇艺世纪科技有限公司 Model generating method, image enchancing method, device and computer readable storage medium
WO2019228358A1 (en) * 2018-05-31 2019-12-05 华为技术有限公司 Deep neural network training method and apparatus
CN110781927A (en) * 2019-10-11 2020-02-11 苏州大学 Target detection and classification method based on deep learning under cooperation of vehicle and road
WO2020029689A1 (en) * 2018-08-07 2020-02-13 阿里巴巴集团控股有限公司 Data processing model construction method and device, server and client
CN110929807A (en) * 2019-12-06 2020-03-27 腾讯科技(深圳)有限公司 Training method of image classification model, and image classification method and device
WO2020098121A1 (en) * 2018-11-13 2020-05-22 平安科技(深圳)有限公司 Method and device for training fast model, computer apparatus, and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107492099B (en) * 2017-08-28 2021-08-20 京东方科技集团股份有限公司 Medical image analysis method, medical image analysis system, and storage medium

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018107906A1 (en) * 2016-12-12 2018-06-21 腾讯科技(深圳)有限公司 Classification model training method, and data classification method and device
WO2019228358A1 (en) * 2018-05-31 2019-12-05 华为技术有限公司 Deep neural network training method and apparatus
WO2020029689A1 (en) * 2018-08-07 2020-02-13 阿里巴巴集团控股有限公司 Data processing model construction method and device, server and client
WO2020098121A1 (en) * 2018-11-13 2020-05-22 平安科技(深圳)有限公司 Method and device for training fast model, computer apparatus, and storage medium
CN109800648A (en) * 2018-12-18 2019-05-24 北京英索科技发展有限公司 Face datection recognition methods and device based on the correction of face key point
CN109859113A (en) * 2018-12-25 2019-06-07 北京奇艺世纪科技有限公司 Model generating method, image enchancing method, device and computer readable storage medium
CN109815988A (en) * 2018-12-27 2019-05-28 北京奇艺世纪科技有限公司 Model generating method, classification method, device and computer readable storage medium
CN110781927A (en) * 2019-10-11 2020-02-11 苏州大学 Target detection and classification method based on deep learning under cooperation of vehicle and road
CN110929807A (en) * 2019-12-06 2020-03-27 腾讯科技(深圳)有限公司 Training method of image classification model, and image classification method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种隧洞探测型自主式水下机器人及其图像拼接方法;陈舟等;《船舶工程》;第41卷(第03期);全文 *

Also Published As

Publication number Publication date
CN111680754A (en) 2020-09-18

Similar Documents

Publication Publication Date Title
CN110413812B (en) Neural network model training method and device, electronic equipment and storage medium
CN110222775B (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
CN113327598B (en) Model training method, voice recognition method, device, medium and equipment
CN110634047A (en) Method and device for recommending house resources, electronic equipment and storage medium
CN113449070A (en) Multimodal data retrieval method, device, medium and electronic equipment
CN112380883B (en) Model training method, machine translation method, device, equipment and storage medium
CN112241761B (en) Model training method and device and electronic equipment
CN111858381B (en) Application fault tolerance capability test method, electronic device and medium
CN111915689B (en) Method, apparatus, electronic device, and computer-readable medium for generating an objective function
CN111680754B (en) Image classification method, device, electronic equipment and computer readable storage medium
WO2023138468A1 (en) Virtual object generation method and apparatus, device, and storage medium
CN116186545A (en) Training and application methods and devices of pre-training model, electronic equipment and medium
CN111737575B (en) Content distribution method, content distribution device, readable medium and electronic equipment
CN115272760A (en) Small sample smoke image fine classification method suitable for forest fire smoke detection
CN111414921B (en) Sample image processing method, device, electronic equipment and computer storage medium
CN110209851B (en) Model training method and device, electronic equipment and storage medium
CN110222777B (en) Image feature processing method and device, electronic equipment and storage medium
CN112418233A (en) Image processing method, image processing device, readable medium and electronic equipment
CN111339770A (en) Method and apparatus for outputting information
CN114359673B (en) Small sample smoke detection method, device and equipment based on metric learning
CN113283115B (en) Image model generation method and device and electronic equipment
CN111814807B (en) Method, apparatus, electronic device, and computer-readable medium for processing image
CN112070163B (en) Image segmentation model training and image segmentation method, device and equipment
CN116974684B (en) Map page layout method, map page layout device, electronic equipment and computer readable medium
CN111797932B (en) Image classification method, apparatus, device and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Tiktok vision (Beijing) Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: BEIJING BYTEDANCE NETWORK TECHNOLOGY Co.,Ltd.

Address after: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant after: Douyin Vision Co.,Ltd.

Address before: 100041 B-0035, 2 floor, 3 building, 30 Shixing street, Shijingshan District, Beijing.

Applicant before: Tiktok vision (Beijing) Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant