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

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

Info

Publication number
CN111680754A
CN111680754A CN202010529538.7A CN202010529538A CN111680754A CN 111680754 A CN111680754 A CN 111680754A CN 202010529538 A CN202010529538 A CN 202010529538A CN 111680754 A CN111680754 A CN 111680754A
Authority
CN
China
Prior art keywords
category
classification model
real
prediction
class
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.)
Granted
Application number
CN202010529538.7A
Other languages
Chinese (zh)
Other versions
CN111680754B (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.)
Beijing ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network Technology 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 Beijing ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology 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

Images

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Biology (AREA)
  • Evolutionary Computation (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Image Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

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 classification model is obtained by adjusting the 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 using the error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the predicted class corresponding to the output of the initial classification model. The image classification method can improve the accuracy of image classification.

Description

Image classification method and device, electronic equipment and computer-readable storage medium
Technical Field
The present disclosure relates to the field of image processing technologies, and in particular, to an image classification method and apparatus, an electronic device, and a computer-readable storage medium.
Background
With the development of artificial intelligence technology, people have begun to use artificial intelligence technology to train artificial intelligence models to solve various problems.
When the objects in the image are identified and classified at present, if the predicted category is different from the real category, the deviation from the real category may be large, for example, the tea table is classified, the real category of the tea table is a furniture category, and if the tea table is not classified into the furniture category, the tea table may be classified into totally irrelevant categories, 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
This 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, an image classification method is provided, which includes:
acquiring an image to be classified;
inputting the images to be classified into a classification model to obtain the categories of the images;
the classification model is obtained by adjusting the 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 using the error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the predicted class corresponding to the output of the initial classification model.
In a second aspect, there is provided an image classification apparatus, comprising:
the acquisition module is used for acquiring 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 classification model is obtained by adjusting the 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 using the error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the predicted class corresponding to the output of the initial classification model.
In a third aspect, an electronic device is provided, which includes:
one or more processors;
a memory;
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: the image classification method shown in the first aspect of the present disclosure is implemented.
In a fourth aspect, a computer-readable medium is provided, on which a computer program is stored, wherein the program, when executed by a processor, implements the image classification method shown in the first aspect of the present disclosure.
The technical scheme provided by the disclosure has the following beneficial effects:
the parameters of the classification model are obtained by adjusting 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 prediction class of the sample image, the loss function between the real class and the prediction class with high association degree with the real class can be adjusted to be smaller, so that the model tends to output the real class, the next prediction class with high association degree with the real class is output, even if the class output by the trained model is different from the real class, the class with high association degree with the real class is also output, and the classification accuracy can be effectively improved.
Further, if a 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 prediction category may be determined first, and if the association degree is greater, it is indicated that the corresponding error coefficient is smaller, the error coefficient is more required to be set, and if the association degree is smaller, it is indicated that the corresponding error coefficient is greater, and the error coefficient is closer to 1, the error coefficient may not be required to be set.
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 various embodiments of the present disclosure will become more apparent by referring to the following detailed description when taken in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numbers refer to the same or similar elements. It should be understood that the drawings are schematic and that elements and features are not necessarily drawn to scale.
Fig. 1 is a schematic flowchart of an image classification method according to an embodiment of the present disclosure;
fig. 2 is a schematic flowchart of an image classification method according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a scheme for determining a degree of association provided in an example of the present disclosure;
FIG. 4 is a schematic diagram of one scheme for determining error coefficients provided in one example of the present disclosure;
fig. 5 is a schematic flow chart of an image classification method provided in an example of the present disclosure;
fig. 6 is a schematic structural diagram of an image classification apparatus 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 are shown in the 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 rather are provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the disclosure are for illustration purposes only and are not intended to limit the scope of the 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. Moreover, 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 "include" and variations thereof as used herein are 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". Relevant definitions for other terms will be given in the following description.
It should be noted that the terms "first", "second", and the like in the present disclosure are only used for distinguishing the devices, modules or units, and are not used for limiting the devices, modules or units to be different devices, modules or units, and also for limiting the sequence or interdependence relationship of the functions executed by the devices, modules or units.
It is noted that references to "a", "an", and "the" modifications in this disclosure are intended to be illustrative rather than limiting, and that those skilled in the art will recognize that "one or more" may be used unless the context clearly dictates otherwise.
The names of messages or information exchanged between devices in the embodiments of the present disclosure are for illustrative purposes only, and are not intended to limit the scope of the messages or information.
The present disclosure provides an image classification method, an image classification device, an electronic device, and a computer-readable medium, which are intended to solve the above technical problems of the prior art.
The following describes the technical solutions of the present disclosure and how to solve the above technical problems in specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present disclosure will be described below with reference to the accompanying drawings.
The embodiment of the present disclosure provides an image classification method, which may be applied to a terminal for performing image classification, as shown in fig. 1, the method may include:
step S101, acquiring an image to be classified;
step S102, inputting the image to be classified into a classification model to obtain the category of the image;
the classification model is obtained by adjusting the 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 using the error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the predicted class corresponding to the output of the initial classification model.
Specifically, a sample image is input into an initial classification model, the sample image is labeled 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 to obtain the classification model.
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 prediction class of the sample image, and the loss function between the real class and the prediction 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 prediction class with high association with the real class is output.
The embodiment of the present disclosure provides a possible implementation manner, and the classification model is obtained by training based on the following manner:
step S101a, inputting the sample image labeled with the real category into the initial classification model, and obtaining the prediction category of the sample image output by the initial classification model.
Wherein the real category is the actual category of the target in the sample image; the prediction category may be a category obtained by identifying and classifying the image by the initial classification model.
Specifically, the prediction category output by the initial classification model may be the same as or different from the actual category.
Step S101b, a loss function of the initial classification model is obtained based on the true class and the predicted class.
Specifically, the obtaining of the loss function of the initial classification model based on the real category and the prediction category in step S101b may include:
(1) acquiring a first feature vector corresponding to the real category and acquiring a second feature vector corresponding to the prediction category;
(2) and obtaining a loss function of the initial classification model based on the first feature vector and the second feature vector.
In a specific implementation process, the loss function of the initial classification model may be obtained according to a difference degree between the first feature vector and the second feature vector, and a calculation process of the specific loss function is not limited herein.
In step S101c, an error coefficient between the target in the sample image and the prediction class is determined.
Specifically, an error database may be preset, a plurality of real categories are stored in the error database, each real category is provided with a plurality of prediction categories, each real category includes at least one target, and an error coefficient is provided between each target in each real category and one corresponding prediction category.
In a specific implementation, the error coefficient between the target and the prediction category in the sample image may be queried in a preset error database.
And 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 obtained by multiplying the error coefficient by a loss value calculated by the loss function, and taking the obtained product as the corrected error coefficient; or the parameters of the loss function may be corrected based on the error coefficients, and the specific correction process is not limited herein.
In a specific implementation process, if the loss value calculated by 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 coefficients, the classification model may be obtained when the corrected loss function converges.
In the embodiment, the error coefficient between the target in the sample image and the prediction category is determined, and the loss function is corrected based on the error coefficient, so that the parameters of the initial classification model are adjusted according to the corrected loss function to obtain the classification model, and the accuracy of the classification result can be effectively improved.
Before determining the error coefficient between the target in the sample image and the prediction category in step S101c, a possible implementation manner is provided in the embodiments of the present disclosure, which may further include:
determining the degree of association between the real category and the prediction category;
the determining of the error coefficient between the real category and the prediction 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 type.
In a specific implementation process, the association degree between the real category and the prediction category may be determined first, if the association degree is greater, it is indicated that the corresponding error coefficient is smaller, the error coefficient is more required to be set, and if the association degree is smaller, it is indicated that the corresponding error coefficient is greater, and the error coefficient is closer to 1, the error coefficient may not be required to be set.
Before determining the error coefficient between the target in the sample image and the prediction category in step S101c, a possible implementation manner is provided in the embodiments of the present disclosure, which may further include:
(1) a plurality of real categories and a plurality of prediction categories are obtained.
Specifically, a plurality of sample images may be obtained, each sample image is labeled with a real category, and the plurality of sample images are respectively input into the 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 association degree between the real category and each prediction category can be determined by the following modes: and when a certain target belongs to the real category, the probability of simultaneously belonging to the prediction category is obtained, and the correlation degree is positively correlated with the obtained probability.
For example, the real category is a table category, the prediction category is a furniture category, the association degree between the table category and the furniture category is determined, the probability that a table belongs to the table category and the furniture category is 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 prediction category is not necessarily equal to the degree of association between the prediction 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 is provided between each real category and each prediction category.
(3) And 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.
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 prediction category is inversely related to the degree of association between the real category and the prediction category.
That is to say, the greater the degree of association between the real category and the prediction category is, the greater the probability that a certain target belongs to the real category at the same time, and the greater the accuracy of the judgment at this time, the smaller the corrected loss function that should be obtained, and the smaller the corresponding error coefficient.
(4) An error database is constructed based on error coefficients between each target in each real category and each prediction category.
As shown in fig. 4, the error database may be a relational comparison table between each target in the real category, the prediction category, and the error coefficient, 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, such as the furniture category, includes a tea table and a chair, and the corresponding prediction category is the table category, a smaller error coefficient may be set between the tea table and the table category, and a relatively larger error coefficient may be set between the chair and the table category, so that the tea table may not be classified into the furniture category, but rather into the table category.
In order to facilitate a clearer understanding of the 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 the sample image marked with the real category into an initial classification model to obtain the prediction category of the sample image output by the initial classification model;
step S502, obtaining a loss function of the initial classification model;
step S503, determining the association degree between the real category and the prediction category;
step S504, judge whether the degree of association between real classification and prediction classification is greater than the preset threshold; if yes, go to step S505;
step S505, determining an error coefficient between the target in the sample image and the 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 images to be classified;
step S509, the image to be classified is input into the classification model, and the category of the image is obtained.
In the image classification method, the parameters of the classification model are obtained by adjusting 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 prediction class of the sample image, the loss function between the real class and the prediction class with high association degree with the real class can be adjusted to be smaller, so that the model tends to output the real class, the next prediction class with high association degree with the real class is output, even if the class output by the trained model is different from the real class, the class with high association degree with the real class is also output, and the classification accuracy can be effectively improved.
Further, if a 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 prediction category may be determined first, and if the association degree is greater, it is indicated that the corresponding error coefficient is smaller, the error coefficient is more required to be set, and if the association degree is smaller, it is indicated that the corresponding error coefficient is greater, and the error coefficient is closer to 1, the error coefficient may not be required to be set.
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 obtaining module 601, configured to obtain an image to be classified;
a classification module 602, configured to input an image to be classified into a classification model, so as to obtain a category of the image;
the classification model is obtained by adjusting the 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 using the error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the predicted class corresponding to the output of the initial classification model.
In an embodiment of the present disclosure, a possible implementation manner is provided, and the image classification apparatus 60 further includes a training module, configured to:
inputting the sample image marked with the real category into an initial classification model to obtain a prediction category of the sample image output by the initial classification model;
obtaining a loss function of the initial classification model based on the real classification and the prediction classification;
determining an error coefficient between the target and the prediction class in the sample image;
and 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.
In an embodiment of the present disclosure, a possible implementation manner is provided, where the training module further includes a determining unit, configured to:
determining the degree of association between the real category and the prediction category;
the training module, when determining the error coefficient between the true category and the predicted category, is specifically configured to:
and if the determined association degree is greater than a preset threshold value, determining an error coefficient between the real category and the prediction category.
The embodiment of the present disclosure provides a possible implementation manner, and when obtaining the loss function of the initial classification model based on the real class and the prediction class, the training module is specifically configured to:
acquiring a first feature vector corresponding to the real category and acquiring a second feature vector corresponding to the prediction category;
and obtaining a loss function of the initial classification model based on the first feature vector and the second feature vector.
The embodiment of the present disclosure provides a possible implementation manner, and when determining an error coefficient between a target and a prediction category in a sample image, a training module is specifically configured to:
inquiring error coefficients between the target and the prediction category in the sample image in a preset error database; the error database stores a plurality of real categories, and each real category comprises 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 one corresponding prediction category.
In an embodiment of the present disclosure, a possible implementation manner is provided, and the image classification apparatus 60 further includes a building module, where the building module is configured to:
acquiring a plurality of real categories and a plurality of prediction categories;
for each real category, determining the association degree between the real category and each prediction 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 error coefficients between each target in each real category and each prediction category.
In the embodiment of the present disclosure, a possible implementation manner is provided, and 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.
In the image classification device, the parameters of the classification model are obtained by adjusting 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 prediction class of the sample image, the loss function between the real class and the prediction class with high association degree with the real class can be adjusted to be smaller, so that the model tends to output the real class, the next prediction class with high association degree with the real class is output, even if the class output by the trained model is different from the real class, the class with high association degree with the real class is also output, and the classification accuracy can be effectively improved.
Further, if a 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 prediction category may be determined first, and if the association degree is greater, it is indicated that the corresponding error coefficient is smaller, the error coefficient is more required to be set, and if the association degree is smaller, it is indicated that the corresponding error coefficient is greater, and the error coefficient is closer to 1, the error coefficient may not be required to be set.
The image classification device of the embodiment of the disclosure can execute the image classification method provided by the embodiment of the disclosure, and the implementation principles thereof are similar, the actions executed by the modules in the image classification device in the embodiments of the disclosure correspond to the steps in the image classification method in the embodiments of the disclosure, and for the detailed functional description of the modules in the image classification device, reference may be specifically made to the description in the corresponding image classification method shown in the foregoing, and details are not repeated here.
Referring now to FIG. 7, shown is a schematic diagram of an electronic device 700 suitable for use in implementing embodiments of the present disclosure. 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., car navigation terminals), and the like, and fixed terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
The electronic device includes: a memory and a processor, wherein the processor may be referred to as the processing device 701 hereinafter, and 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 shown in detail below:
as shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from storage 708 into a Random Access Memory (RAM) 703. In the RAM 703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; 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 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer readable medium, the computer program containing program code for performing the method illustrated by the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of the embodiments of the present disclosure.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. 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 present 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
In some embodiments, 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 communications 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 network.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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;
the classification model is obtained by adjusting the 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 using the error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the predicted class corresponding to the output of the initial classification model.
Computer program code for carrying out operations for the present disclosure may be written in any combination of 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of a module or unit does not in some cases constitute a limitation of the unit itself, for example, a classification module may also be described as a "module for classifying images".
The functions described herein above 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: field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), systems on a chip (SOCs), Complex Programmable Logic Devices (CPLDs), 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, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing information. 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.
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 category of the image;
the classification model is obtained by adjusting parameters of an 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 through an error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the corresponding predicted class output by 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 a prediction category of the sample image output by the initial classification model;
obtaining a loss function of the initial classification model based on the real classification and the prediction classification;
determining the error coefficient between a target in the sample image and the prediction class;
and 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 determining the error coefficient between the target in the sample image and the prediction class, the method further comprises:
determining a degree of association between the real category and the predicted category;
the determining an error coefficient between the true class and the predicted class comprises:
determining the error coefficient between the target in the sample image and the prediction type if the determined degree of association is greater than a preset threshold.
According to one or more embodiments of the present disclosure, the obtaining the loss function of the initial classification model based on the real class and the prediction class includes:
acquiring a first feature vector corresponding to the real category and acquiring a second feature vector corresponding to the prediction category;
obtaining a loss function of the initial classification model 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 class includes:
querying an error coefficient between a target in a sample image and the prediction category in a preset error database; wherein, a plurality of real categories are stored in the error database, and each real category comprises 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 one corresponding prediction category.
According to one or more embodiments of the present disclosure, before determining the error coefficient between the real class and the prediction class, the method further includes:
acquiring a plurality of real categories and a plurality of prediction categories;
for each real category, determining the association degree between the real category and each prediction 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 category and each prediction category.
According to one or more embodiments of the present disclosure, the error coefficient between any target in each real category and each corresponding prediction category is inversely related to the degree of association between the real category and the prediction category.
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the disclosure herein is not limited to the particular combination of features described above, but also encompasses other embodiments in which any combination of the features described above or their equivalents does not depart from the spirit of the disclosure. For example, the above features and (but not limited to) the features disclosed in this disclosure having similar functions are replaced with each other to form the technical solution.
Further, while 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. Under 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 limitations on the scope of the 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 disclosed as example forms of implementing the claims.

Claims (10)

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 category of the image;
the classification model is obtained by adjusting parameters of an 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 through an error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the corresponding predicted class output by the initial classification model.
2. The image classification method according to claim 1, characterized in that the classification model is trained on the basis of:
inputting the sample image marked with the real category into the initial classification model to obtain a prediction category of the sample image output by the initial classification model;
obtaining a loss function of the initial classification model based on the real classification and the prediction classification;
determining the error coefficient between a target in the sample image and the prediction class;
and 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.
3. The image classification method according to claim 2, wherein before determining the error coefficient between the target in the sample image and the prediction class, further comprising:
determining a degree of association between the real category and the predicted category;
the determining an error coefficient between the true class and the predicted class comprises:
determining the error coefficient between the target in the sample image and the prediction type if the determined degree of association is greater than a preset threshold.
4. The image classification method according to claim 2, wherein the obtaining of the loss function of the initial classification model based on the real class and the prediction class comprises:
acquiring a first feature vector corresponding to the real category and acquiring a second feature vector corresponding to the prediction category;
obtaining a loss function of the initial classification model based on the first feature vector and the second feature vector.
5. The image classification method according to claim 2 or 3, wherein the determining the error coefficient between the target in the sample image and the prediction class comprises:
querying an error coefficient between a target in a sample image and the prediction category in a preset error database; wherein, a plurality of real categories are stored in the error database, and each real category comprises 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 one corresponding prediction category.
6. The image classification method according to claim 4, wherein before determining the error coefficients 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 the association degree between the real category and each prediction 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 category and each prediction category.
7. The image classification method according to claim 6, wherein the error coefficient between any object in each real class and each corresponding prediction class is inversely related to the degree of association between the real class and the prediction class.
8. An image classification apparatus, comprising:
the acquisition module is used for acquiring images to be classified;
the classification module is used for inputting the images to be classified into a classification model to obtain the categories of the images;
the classification model is obtained by adjusting parameters of an 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 through an error coefficient; the error coefficients are determined based on the true class of the sample image input to the initial classification model and the corresponding predicted class output by the initial classification model.
9. 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 programs configured to: performing the image classification method according to any of claims 1-7.
10. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the image classification method of any one of claims 1 to 7.
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 true CN111680754A (en) 2020-09-18
CN111680754B 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)

Cited By (1)

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

Citations (10)

* 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
US20190065897A1 (en) * 2017-08-28 2019-02-28 Boe Technology Group Co., Ltd. Medical image analysis method, medical image analysis system 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
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

Patent Citations (10)

* 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
US20190065897A1 (en) * 2017-08-28 2019-02-28 Boe Technology Group Co., Ltd. Medical image analysis method, medical image analysis system and storage medium
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
陈舟等: "一种隧洞探测型自主式水下机器人及其图像拼接方法", 《船舶工程》, vol. 41, no. 03 *

Cited By (1)

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

Also Published As

Publication number Publication date
CN111680754B (en) 2023-09-19

Similar Documents

Publication Publication Date Title
CN110413812B (en) Neural network model training method and device, electronic equipment and storage medium
CN111784712B (en) Image processing method, device, equipment and computer readable 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
CN112364860A (en) Training method and device of character recognition model and electronic equipment
CN112650841A (en) Information processing method and device and electronic equipment
CN113449070A (en) Multimodal data retrieval method, device, medium and electronic equipment
CN111209306A (en) Business logic judgment method and device, electronic equipment and storage medium
CN110009101B (en) Method and apparatus for generating a quantized neural network
CN111209432A (en) Information acquisition method and device, electronic equipment and computer readable medium
CN113191257B (en) Order of strokes detection method and device and electronic equipment
CN112380883B (en) Model training method, machine translation method, device, equipment and storage medium
CN114067327A (en) Text recognition method and device, readable medium and electronic equipment
CN111680754B (en) Image classification method, device, electronic equipment and computer readable storage medium
CN111798251A (en) Verification method and device of house source data and electronic equipment
CN111262907A (en) Service instance access method and device and electronic equipment
CN115272760A (en) Small sample smoke image fine classification method suitable for forest fire smoke detection
CN110209851B (en) Model training method and device, electronic equipment and storage medium
CN111737575B (en) Content distribution method, content distribution device, readable medium and electronic equipment
CN113486749A (en) Image data collection method, device, electronic equipment and computer readable medium
CN112418233A (en) Image processing method, image processing device, readable medium and electronic equipment
CN112488947A (en) Model training and image processing method, device, equipment and computer readable medium
CN111580890A (en) Method, apparatus, electronic device, and computer-readable medium for processing features
CN112070163B (en) Image segmentation model training and image segmentation method, device and equipment
CN113283115B (en) Image model generation method and device and electronic equipment

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