Cascade classifier-based few-sample commodity classification system and classification methodTechnical Field
The invention relates to the technical field of commodity classification, in particular to a few-sample commodity classification system and a classification method based on a cascade classifier.
Background
Currently, visual recognition technology-based article classification methods typically rely on extensive training data to train a classification model and output classification of articles by the classification model recognition. However, in some specific application scenarios, some kinds of data are difficult to obtain, such as some cold-door commodities, just-new commodities, etc., and the commodity data of these commodities are very limited, so that an effective commodity classifier cannot be trained to classify and identify these cold-door commodities by taking these limited commodity data as training samples.
In the prior art, for classifying and identifying the few-sample commodities, a feature extractor and a classifier are mostly adopted, the feature extractor extracts commodity image features of the few-sample commodities, and then the classifier obtains a classification result of the few-sample features according to the commodity image features. The classifiers only classify the final output of the feature extractor, but do not classify the hidden layer features of the feature extractor, so that the inter-class distinction of the hidden layer features of the feature extractor is not high, the inter-class distinction of the image features finally output by the feature extractor is affected, and the accuracy of classifying and judging the few-sample commodities is finally affected.
Disclosure of Invention
The invention aims to provide a few-sample commodity classification system based on a cascade classifier, so as to solve the technical problems.
To achieve the purpose, the invention adopts the following technical scheme:
there is provided a cascade classifier-based few-sample commodity classification system for commodity classification of commodities lacking sample features, comprising:
the feature extractor training module is used for training to form a feature extractor according to the input multiple basic commodity feature samples and storing the feature extractor;
the classifier training module is used for training and forming a cascade classifier according to a plurality of input basic commodity category samples and storing the cascade classifier;
the commodity image acquisition module is used for acquiring commodity images of the few-sample commodities;
the feature extraction module is respectively connected with the small sample commodity image acquisition module and the feature extractor training module and is used for inputting the commodity image of the small sample commodity into the feature extractor, and then the feature extractor extracts multi-layer image features associated with the small sample commodity in a multi-layer image feature extraction mode;
the classification module is respectively connected with the feature extraction module and the classifier training module and is used for correspondingly inputting the extracted image features of each layer into the classifier of each stage of the cascade classifier,
the cascade classifier calculates the classification weight of the few-sample commodity corresponding to the commodity class at each classification layer according to the input image features, and updates the classification weight in a cascade manner by analyzing the correlation between the few-sample commodity and the basic commodity, finally classifies the few-sample commodity based on the image features input at the last layer and the classification weight finally obtained through cascade update, and finally outputs the classification result of the few-sample commodity.
As a preferable mode of the present invention, the image features extracted by the feature extractor include hidden features of the commodity image of the small-sample commodity after image feature extraction.
As a preferred embodiment of the present invention, each stage of the cascade classifier specifically includes:
an image feature input unit for correspondingly inputting the image features extracted by the feature extractor;
a classification weight calculation unit, connected to the image feature input unit, for calculating the classification weight of the commodity with the small sample as the corresponding commodity class according to the input image feature;
the inter-class association analysis unit is connected with the image characteristic input unit and is used for obtaining the inter-class association of the few-sample commodity and the basic commodity according to the input image characteristic analysis;
the classification weight updating unit is respectively connected with the classification weight calculating unit and the inter-class association analysis unit and is used for updating the classification weight of the commodity with the small sample as the corresponding commodity class according to the inter-class association;
and the classification unit is connected with the image characteristic input unit and the classification weight updating unit and is used for classifying the few-sample commodities according to the input image characteristics and the finally updated classification weights and obtaining classification results.
As a preferred aspect of the present invention, the small sample commodity classification system analyzes the correlation between the small sample commodity and the base commodity according to the image features associated with the small sample commodity by means of an attention mechanism.
The invention also provides a few-sample commodity classification method based on the cascade classifier, which is realized by applying the few-sample commodity classification system and comprises the following steps:
step S1, the commodity image of the few-sample commodity is acquired by the few-sample commodity classification system;
step S2, the few-sample commodity classification system performs image feature extraction on the commodity image based on the feature extractor trained in advance, and extracts multi-layer image features associated with the few-sample commodity;
step S3, the few-sample commodity classification system correspondingly inputs the image features of each layer into the classifier of each stage of the cascade classifier;
step S4, the cascade classifier calculates the classification weight of the commodity with the small sample at each classification layer as the corresponding commodity class according to the input image characteristics, and the classification weight is updated in a cascade manner by analyzing the correlation between the commodity with the small sample and the basic commodity;
and S5, the cascade classifier classifies the few-sample commodities based on the image features extracted by the last layer and the classification weights finally obtained through cascade updating, and finally outputs the classification result of the few-sample commodities.
As a preferred embodiment of the present invention, in the step S2, the image feature includes a hidden feature associated with the small sample commodity extracted by the feature extractor.
As a preferred embodiment of the present invention, in the step S4, the method for calculating the classification weight of the commodity with the small sample as the corresponding commodity class by using the cascade classifier specifically includes the following steps:
step L1, calculating a feature mean value F of the few-sample commodity according to the input image features;
step L2, putting the characteristic mean value F into a full-connection layer to obtain a corresponding first characteristic W1;
step L3, calculating the association coefficient of the characteristic mean value F and the corresponding basic commodity by using an attention mechanism, and multiplying the association coefficient by the preset class weight corresponding to the basic commodity to obtain a second characteristic W2 corresponding to the few-sample commodity;
and step L4, adding the first characteristic W1 and the second characteristic W2 to obtain the classification weight W of the commodity with the small sample as the corresponding commodity class.
As a preferred aspect of the present invention, in the step S4, the method for analyzing the association between the few-sample commodity and the base commodity by using the cascade classifier specifically includes the following steps:
m1, placing the characteristic mean value F of the few-sample commodity into a full-connection layer to obtain the first characteristic W1;
step M2, multiplying the first characteristic W1 of the few-sample commodity with the commodity characteristic of the basic commodity to obtain a first product, and then calculating a first logistic regression (Softmax) value of the first product;
and M3, multiplying the first logistic regression value calculated in the step M2 with the category weight corresponding to the basic commodity to obtain a second product, then calculating a second logistic regression value of the second product, and taking the second logistic regression value as an index for evaluating the correlation strength between the few-sample commodity and the basic commodity.
As a preferred solution of the present invention, in the step S4, the cascade classifier cascade updating the classification weight corresponding to the small sample commodity is implemented by calculating the following formula:
Wn =W1 +0.5Wn-1 ;
in the above, Wn The small sample commodity is used for representing that the small sample commodity updated by the nth class classifier weight in the cascade classifier corresponds to the classification weight of the commodity class;
W1 for representing first stage classifier computation in the cascade of classifiersThe few sample items to which correspond are the classification weights of the category of items.
The invention has the beneficial effects that:
1. the invention classifies the image features finally output by the feature extractor, classifies the image features extracted by each hidden layer of the feature extractor by the cascade classifier, enhances the degree of distinguishing between hidden features of the feature extractor, is beneficial to further improving the degree of distinguishing between the image features finally extracted by the feature extractor, and improves the accuracy and classification efficiency of commodity classification of few sample commodities.
2. According to the invention, the inter-class association between the few-sample commodity and the basic commodity is obtained through the attention mechanism, and then the few-sample commodity is updated to be the classification weight of the corresponding commodity class based on the cascade of the inter-class association, so that the accuracy of classifying the few-sample commodity is effectively improved.
Drawings
In order to more clearly illustrate the technical solution of the embodiments of the present invention, the drawings that are required to be used in the embodiments of the present invention will be briefly described below. It is evident that the drawings described below are only some embodiments of the present invention and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a schematic diagram of a cascade classifier-based few-sample commodity classification system according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the internal structure of each of the classifiers in a small sample commodity classification system according to an embodiment of the present invention;
fig. 3 is a step diagram of a method for implementing commodity classification of a few-sample commodity by using a few-sample commodity classification system based on a cascade classifier according to an embodiment of the present invention:
FIG. 4 is a block diagram showing a method for calculating the classification weight of a few-sample commodity as a corresponding commodity class by using a few-sample commodity classification system based on a cascade classifier according to an embodiment of the present invention;
FIG. 5 is a diagram of steps in a method for analyzing the correlation between a few-sample commodity and a basic commodity by a few-sample commodity classification system based on a cascade classifier according to an embodiment of the present invention;
fig. 6 is a flow chart of a cascade classifier-based commodity classification system for classifying commodities of a few-sample commodity according to an embodiment of the present invention.
Detailed Description
The technical scheme of the invention is further described below by the specific embodiments with reference to the accompanying drawings.
Wherein the drawings are for illustrative purposes only and are shown in schematic, non-physical, and not intended to be limiting of the present patent; for the purpose of better illustrating embodiments of the invention, certain elements of the drawings may be omitted, enlarged or reduced and do not represent the size of the actual product; it will be appreciated by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The same or similar reference numbers in the drawings of embodiments of the invention correspond to the same or similar components; in the description of the present invention, it should be understood that, if the terms "upper", "lower", "left", "right", "inner", "outer", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, only for convenience in describing the present invention and simplifying the description, rather than indicating or implying that the apparatus or elements being referred to must have a specific orientation, be constructed and operated in a specific orientation, so that the terms describing the positional relationships in the drawings are merely for exemplary illustration and should not be construed as limiting the present patent, and that the specific meaning of the terms described above may be understood by those of ordinary skill in the art according to specific circumstances.
In the description of the present invention, unless explicitly stated and limited otherwise, the term "coupled" or the like should be interpreted broadly, as it may be fixedly coupled, detachably coupled, or integrally formed, as indicating the relationship of components; can be mechanically or electrically connected; can be directly connected or indirectly connected through an intermediate medium, and can be communication between the two parts or interaction relationship between the two parts. The specific meaning of the above terms in the present invention will be understood in specific cases by those of ordinary skill in the art.
Referring to fig. 1, a cascade classifier-based few-sample commodity classification system provided in an embodiment of the present invention is used for classifying commodities lacking sample features, and the few-sample commodity classification system specifically includes:
the featureextractor training module 1 is used for training to form a feature extractor according to a plurality of input basic commodity feature samples and storing the feature extractor;
theclassifier training module 2 is used for training and forming a cascade classifier according to a plurality of input basic commodity category samples and storing the cascade classifier;
a small sample commodityimage acquisition module 3 for acquiring commodity images of small sample commodities;
thefeature extraction module 4 is respectively connected with the small sample commodityimage acquisition module 3 and the featureextractor training module 1 and is used for inputting commodity images of the small sample commodity into the feature extractor, and then the feature extractor extracts multi-layer image features associated with the small sample commodity in a multi-layer image feature extraction mode;
the classifyingmodule 5 is respectively connected with thefeature extracting module 4 and theclassifier training module 2 and is used for correspondingly inputting the extracted image features of each layer into each stage of classifier of the cascade classifier,
the cascade classifier calculates the classification weight of the few-sample commodity as the corresponding commodity according to the input image characteristics, and the classification weight is updated in a cascade manner by analyzing the correlation between the few-sample commodity and the basic commodity, and finally the classification result of the few-sample commodity is output based on the image characteristics input by each layer and the classification weight after the cascade update.
In a preferred aspect of this embodiment, the image features extracted by the feature extractor include hidden features of the commodity image of the commodity with a small sample after the image features are extracted.
Referring to fig. 2 and 6, eachclassifier 100 in the cascade of classifiers specifically includes:
an imagefeature input unit 101 for inputting the image features extracted by the feature extractor correspondingly;
a classificationweight calculation unit 102 connected to the imagefeature input unit 101 for calculating a classification weight of the commodity with less sample as a corresponding commodity class according to the input image feature;
an inter-classassociation analysis unit 103 connected to the imagefeature input unit 101, for obtaining inter-class association between the few-sample commodity and the basic commodity according to the input image feature analysis;
a classificationweight updating unit 104, connected to the classificationweight calculating unit 102 and the inter-classassociation analysis unit 103, respectively, for updating the less sample commodity into the classification weight of the corresponding commodity class according to the inter-class association and storing;
the classifyingunit 105 is connected to the imagefeature input unit 101 and the classificationweight updating unit 102, and is configured to classify the few-sample commodities according to the input image features and the finally updated classification weights, so as to obtain a classification result.
In the above technical solution, the few-sample commodity classification system preferably analyzes and obtains the inter-class association between the few-sample commodity and the basic commodity through the attention mechanism according to the image features associated with the few-sample commodity.
Referring to fig. 3 and 6, the invention further provides a few-sample commodity classification method based on a cascade classifier, which is implemented by applying the few-sample commodity classification system, and specifically includes the following steps:
step S1, a commodity image of a few-sample commodity is acquired by a few-sample commodity classification system;
step S2, the few-sample commodity classification system extracts image features of commodity images based on a pre-trained feature extractor, and extracts multi-layer image features related to few-sample commodities;
s3, inputting the image features of each layer into the classifier of each stage of the cascade classifier correspondingly by the commodity classification system with few samples;
step S4, the cascade classifier calculates the classification weight of the few sample commodities as corresponding commodity classes at each classification layer according to the input image characteristics, and the classification weight is updated in a cascade manner by analyzing the correlation between the few sample commodities and the basic commodity;
and S5, carrying out commodity classification on the few-sample commodities by the cascade classifier based on the image features extracted by the last layer and the classification weights finally obtained through cascade updating, and finally outputting classification results of the few-sample commodities.
In the above technical solution, the training process of the feature extractor and the cascade classifier is an existing method, for example, the feature extractor and the cascade classifier can be obtained by training using a deep learning convolutional neural network, and the specific training process is not described herein.
In step S2, the extracted image features include hidden features associated with the less sample merchandise. In general, image feature extraction is performed through a convolutional neural network, and finally output image features do not contain image hidden features, and the image hidden features are generally discarded by default.
Referring to fig. 4, in step S4, the method for calculating the classification weight of the small sample commodity as the corresponding commodity class by the cascade classifier specifically includes the following steps:
step L1, calculating a feature mean value F of few-sample commodities according to input image features;
step L2, putting the characteristic mean value F into the full connection layer to obtain a corresponding first characteristic W1;
step L3, calculating the association coefficient of the characteristic mean value F and the corresponding basic commodity by using an attention mechanism, and multiplying the association coefficient by the class weight corresponding to the preset basic commodity to obtain a second characteristic W2 corresponding to the commodity with a small sample;
and step L4, adding the first characteristic W1 and the second characteristic W2 to obtain the classification weight W of the commodity with less samples as the corresponding commodity class.
W=W1+W2。
It should be noted that, the method of calculating the feature mean value of the few-sample commodity by the few-sample commodity classification system through the classifiers of each stage is an existing feature mean value calculation method, and since the method for calculating the feature mean value is not the scope of the present invention, the process of calculating the feature mean value F corresponding to the few-sample commodity by the few-sample commodity classification system according to the image feature associated with the few-sample commodity is not described herein.
Referring to fig. 5, in step S4, a method for analyzing the association between the few sample commodities and the basic commodity by using the cascade classifier specifically includes the following steps:
step M1, putting the characteristic mean value F of the few-sample commodity into a full-connection layer to obtain a corresponding first characteristic W1;
step M2, multiplying the first characteristic W1 corresponding to the few sample commodities with the commodity characteristic of the basic commodity to obtain a first product, and then calculating a first logistic regression (Softmax) value of the first product;
and M3, multiplying the first logistic regression value calculated in the step M2 by the class weight corresponding to the basic commodity to obtain a second product, then calculating a second logistic regression value of the second product, and taking the second logistic regression value as an index for evaluating the correlation strength between the few-sample commodity and the basic commodity.
It should be noted that, the first logistic regression value calculated in the step M2 is the correlation coefficient between the feature mean value F and the basic commodity calculated in the step L3 (i.e. the correlation coefficient between the few sample commodities and the basic commodity).
The second logistic regression value calculated in the step M3 is the second feature W2 corresponding to the commodity with few samples calculated in the step L3.
In the above technical solution, the methods for calculating the first feature W1, the first logistic regression value, and the second logistic regression value are all existing calculation methods, and the calculation process is not described herein.
The method for cascade updating the classification weight corresponding to the few-sample commodity by the cascade classifier is realized by calculating the following formula:
Wn =W1 +0.5Wn-1 ;
in the above, Wn For representing in cascaded classifiersThe few sample commodities with updated n-th class classifier weights are the classification weights of the corresponding commodity classes;
W1 the classification weight is used for representing that the few-sample commodities calculated by the first-stage classifier in the cascade classifier are corresponding to the commodity class.
It should be understood that the above description is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be apparent to those skilled in the art that various modifications, equivalents, variations, and the like can be made to the present invention. However, such modifications are intended to fall within the scope of the present invention without departing from the spirit of the present invention. In addition, some terms used in the specification and claims of the present application are not limiting, but are merely for convenience of description.