Image classification method and related device thereof
AssigneeHuawei Technologies Co., Ltd.
InventorsHan SHU, Jiahao WANG, Hanting CHEN, Wenshuo LI, Yunhe WANG
Life of this patent
Estimating the term…
Abstract
This disclosure provides an image classification method and a related device thereof. The method includes the following operations: After obtaining a target image, a transformer network may perform linear transformation processing based on the target image to obtain a Q-feature, a K-feature, and a V-feature. The transformer network calculates a distance between the Q-feature and the K-feature to obtain an attention feature. Then, the transformer network performs fusion processing on the attention feature and the V-feature, and obtains a classification result of the target image based on a fused feature.
Claims20
An image classification method, wherein the method is implemented by using a transformer network, and the method comprises:
- obtaining M first features of a target image, wherein M≥1;
- performing linear transformation processing based on a kth first feature to obtain a kth second feature, a kth third feature, and a kth fourth feature, wherein k=1, . . . , M;
- calculating a distance between the kth second feature and the kth third feature to obtain a kth fifth feature;
- performing first fusion processing based on the kth fifth feature and the kth fourth feature to obtain a kth sixth feature;
- and
- obtaining a classification result of the target image based on M sixth features.
An image classification apparatus, wherein the apparatus comprises a memory and a processor, the memory stores code, the processor is configured to execute the code, and when the code is executed, the image classification apparatus performs operations comprising:
- obtaining M first features of a target image, wherein M≥1;
- performing linear transformation processing based on a kth first feature to obtain a kth second feature, a kth third feature, and a kth fourth feature, wherein k=1, . . . , M;
- calculating a distance between the kth second feature and the kth third feature to obtain a kth fifth feature;
- performing first fusion processing based on the kth fifth feature and the kth fourth feature to obtain a kth sixth feature;
- and
- obtaining a classification result of the target image based on M sixth features.
A non-transitory computer-readable storage medium, wherein the computer-readable storage medium stores one or more instructions, and when the instructions are executed by one or more computers, the one or more computers are enabled to implement operations comprising:
- obtaining M first features of a target image, wherein M≥1;
- performing linear transformation processing based on a kth first feature to obtain a kth second feature, a kth third feature, and a kth fourth feature, wherein k=1, . . . , M;
- calculating a distance between the kth second feature and the kth third feature to obtain a kth fifth feature;
- performing first fusion processing based on the kth fifth feature and the kth fourth feature to obtain a kth sixth feature;
- and
- obtaining a classification result of the target image based on M sixth features.
Dependencies are inferred from the claim text.