IP Library Granted Patent US 12,131,521
Granted Patent B2
US 12,131,521 · App. 17/587,284 · Granted Oct 29, 2024

Image classification method and apparatus

Inventors: Hanting Chen (Beijing, CN); Yunhe Wang (Beijing, CN); Chunjing Xu (Shenzhen, CN)
Assignee: Huawei Technologies Co., Ltd.
G06V10/764G06F17/16G06N3/02G06V10/7715G06V10/82
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,131,521
App. No.
17/587,284
Granted
Oct 29, 2024
Kind
B2
Abstract

This application relates to an image recognition technology in the field of computer vision of artificial intelligence, and provides an image classification method and apparatus. An example method includes obtaining an input feature map of a to-be-processed image, and then performing feature extraction processing on the input feature map based on a feature extraction kernel of a neural network to obtain an output feature map, where each of a plurality of output sub-feature maps is determined based on the corresponding input sub-feature map and the feature extraction kernel, at least one of the output sub-feature maps is determined based on a target matrix obtained after an absolute value is taken, and a difference between the target matrix and the input sub-feature map corresponding to the target matrix is the feature extraction kernel. The to-be-processed image is classified based on the output feature map to obtain a classification result of the to-be-processed image.

Claims (935)

1. An image classification method, comprising:

obtaining an input feature map of a to-be-processed image, wherein the input feature map comprises a plurality of input sub-feature maps;

performing feature extraction processing on the input feature map based on a feature extraction kernel of a neural network to obtain an output feature map, wherein the output feature map comprises a plurality of output sub-feature maps, wherein each of the plurality of output sub-feature maps is determined based on the corresponding input sub-feature map and the feature extraction kernel, wherein at least one of the output sub-feature maps is determined based on a target matrix obtained after an absolute value is taken, and wherein a difference between the target matrix and the input sub-feature map corresponding to the target matrix is the feature extraction kernel; and

classifying the to-be-processed image based on the output feature map to obtain a classification result of the to-be-processed image.

2. The method according to claim 1 , wherein the target matrix is obtained by performing matrix addition or matrix subtraction on at least one of the input sub-feature maps and the feature extraction kernel.

3. The method according to claim 2 , wherein the at least one of the output sub-feature maps is obtained according to the following formula:

Y

(

m

,

n

,

t

)

F

(

i

,

j

,

k

,

t

)

=

-

Hard

tanh

(

F

(

i

,

j

,

k

,

t

)

±

X

(

m

+

i

,

n

+

j

,

k

)

)

;

wherein

|(⋅)| is an operation for taking an absolute value, Σ(⋅) is a summation operation, Y(m,n,t) is the at least one of the output sub-feature maps, Y(m,n,t) is an element in an m th row and an n th column on a t th page in the output feature map, X(m+i,n+j,k) is an element determined based on an i th row and a j th column on a k th page in the at least one of the input sub-feature maps, F(i,j,k,t) is an element in an i th row and a j th column on a k th page in the feature extraction kernel, t is a channel quantity of the feature extraction kernel, d is a row quantity of the feature extraction kernel, C is a channel quantity of the input feature map, and d, C, i, j, k, m, n, and t are all integers.

4. The method according to claim 1 , wherein a gradient of the feature extraction kernel is determined based on the target matrix, and a gradient of the input sub-feature map is determined based on the target matrix.

5. The method according to claim 4 , wherein when a value of T(m,n,i,j,k,t) falls within a preset value range, a gradient of F(i,j,k,t) is determined based on the value of T(m,n,i,j,k,t), and a gradient of X(m+i,n+j,k) is determined based on the value of T(m,n,i,j,k,t), wherein:

T(m,n,i,j,k,t)=X(m+i,n+j,k)±F(i,j,k,t), F(i,j,k,t) is an element in the i th row and the j th column on the k th page in the feature extraction kernel, X(m+i, n+j,k) is an element determined based on the i th row and the j th column on the k th page in the at least one of the input sub-feature maps, and i, j, k, m, n, and t are all integers.

6. The method according to claim 5 , wherein the gradient of F(i,j,k,t) is obtained according to the following formula:

Y

(

m

,

n

,

t

)

F

(

i

,

j

,

k

,

t

)

=

-

Hard

tan

h

(

F

(

i

,

j

,

k

,

t

)

±

X

(

m

+

i

,

n

+

j

,

k

)

)

;

and

the gradient of X(m+i,n+j, k) is obtained according to the following formula:

Y

(

m

,

n

,

t

)

X

(

m

+

i

,

n

+

j

,

k

)

=

-

Hard

tanh

(

X

(

m

+

i

,

n

+

j

,

k

)

±

F

(

i

,

j

,

k

,

t

)

)

,

wherein

Hard

tanh

(

x

)

=

{

1

x

>

1

-

1

x

<

-

1

x

-

1

x

1

,

Y

(

m

,

n

,

t

)

F

(

i

,

j

,

k

,

t

)

is

the

gradient

of

F

(

i

,

j

,

k

,

t

)

,

and

Y

(

m

,

n

,

t

)

X

(

m

+

i

,

n

+

j

,

k

)

is

the

gradient

of

X

(

m

+

i

,

n

+

j

,

k

)

.

7. An image classification apparatus, comprising:

at least one processor;

one or more memories coupled to the at least one processor and storing programming instructions for execution by the at least one processor to:

obtain an input feature map of a to-be-processed image, wherein the input feature map comprises a plurality of input sub-feature maps;

perform feature extraction processing on the input feature map based on a feature extraction kernel of a neural network to obtain an output feature map, wherein the output feature map comprises a plurality of output sub-feature maps, each of the plurality of output sub-feature maps is determined based on the corresponding input sub-feature map and the feature extraction kernel, at least one of the output sub-feature maps is determined based on a target matrix obtained after an absolute value is taken, and a difference between the target matrix and the input sub-feature map corresponding to the target matrix is the feature extraction kernel; and

classify the to-be-processed image based on the output feature map, to obtain a classification result of the to-be-processed image.

8. The apparatus according to claim 7 , wherein the target matrix is obtained by performing matrix addition or matrix subtraction on at least one of the input sub-feature maps and the feature extraction kernel.

9. The apparatus according to claim 8 , wherein the at least one of the output sub-feature maps is obtained according to the following formula:

Y

(

m

,

n

,

t

)

=

i

=

0

d

-

1

j

=

0

d

-

1

k

=

1

C

-

"\[LeftBracketingBar]"

X

(

m

+

i

,

n

+

j

,

k

)

-

F

(

i

,

j

,

k

,

t

)

"\[RightBracketingBar]"

;

or

Y

(

m

,

n

,

t

)

=

i

=

0

d

-

1

j

=

0

d

-

1

k

=

1

C

-

"\[LeftBracketingBar]"

X

(

m

+

i

,

n

+

j

,

k

)

+

F

(

i

,

j

,

k

,

t

)

"\[RightBracketingBar]"

,

wherein:

|(⋅)| is an operation for taking an absolute value, Σ(⋅) is a summation operation, Y(m,n,t) is the at least one of the output sub-feature maps, Y(m,n,t) is an element in an m th row and an n th column on a t th page in the output feature map, X(m+i,n+j,k) is an element determined based on an i th row and a j th column on a k th page in the at least one of the input sub-feature maps, F(i,j,k,t) is an element in an i th row and a j th column on a k th page in the feature extraction kernel, t is a channel quantity of the feature extraction kernel, d is a row quantity of the feature extraction kernel, C is a channel quantity of the input feature map, and d, C, i, j, k, m, n, and t are all integers.

10. The apparatus according to claim 7 , wherein a gradient of the feature extraction kernel is determined based on the target matrix, and a gradient of the input sub-feature map is determined based on the target matrix.

11. The apparatus according to claim 10 , wherein when a value of T(m,n,i,j,k,t) falls within a preset value range, a gradient of F (i,j,k,t) is determined based on the value of T(m,n,i,j,k,t), and a gradient of X(m+i,n+j,k) is determined based on the value of T(m,n,i,j,k,t), wherein:

T(m,n,i,j,k,t)=X(m+i,n+j,k)±F(i,j,k,t), F(i,j,k,t) is an element in the i th row and the j th column on the k th page in the feature extraction kernel, X(m+i, n+j,k) is an element determined based on the i th row and the j th column on the k th page in the at least one of the input sub-feature maps, and i, j, k, m, n, and t are all integers.

12. The apparatus according to claim 11 , wherein the gradient of F(i,j,k,t) is obtained according to the following formula:

Y

(

m

,

n

,

t

)

F

(

i

,

j

,

k

,

t

)

=

-

Hard

tanh

(

F

(

i

,

j

,

k

,

t

)

±

X

(

m

+

i

,

n

+

j

,

k

)

)

;

and

the gradient of X(m+i,n+j,k) is obtained according to the following formula:

Y

(

m

,

n

,

t

)

X

(

m

+

i

,

n

+

j

,

k

)

=

-

Hard

tanh

(

X

(

m

+

i

,

n

+

j

,

k

)

±

F

(

i

,

j

,

k

,

t

)

)

,

wherein

Hard

tanh

(

x

)

=

{

1

x

>

1

-

1

x

<

-

1

x

-

1

x

1

,

Y

(

m

,

n

,

t

)

F

(

i

,

j

,

k

,

t

)

is

the

gradient

of

F

(

i

,

j

,

k

,

t

)

,

and

Y

(

m

,

n

,

t

)

X

(

m

+

i

,

n

+

j

,

k

)

is

the

gradient

of

X

(

m

+

i

,

n

+

j

,

k

)

.

13. A non-transitory computer-readable storage medium, wherein the computer-readable storage medium stores program code to be executed by a device, and the program code comprises instructions used to obtain an input feature map of a to-be-processed image, wherein the input feature map comprises a plurality of input sub-feature maps;

perform feature extraction processing on the input feature map based on a feature extraction kernel of a neural network to obtain an output feature map, wherein the output feature map comprises a plurality of output sub-feature maps, wherein each of the plurality of output sub-feature maps is determined based on the corresponding input sub-feature map and the feature extraction kernel, wherein at least one of the output sub-feature maps is determined based on a target matrix obtained after an absolute value is taken, and wherein a difference between the target matrix and the input sub-feature map corresponding to the target matrix is the feature extraction kernel; and

classify the to-be-processed image based on the output feature map to obtain a classification result of the to-be-processed image.

14. The non-transitory computer-readable storage medium of claim 13 , wherein the target matrix is obtained by performing matrix addition or matrix subtraction on at least one of the input sub-feature maps and the feature extraction kernel.

15. The non-transitory computer-readable storage medium of claim 14 , wherein the at least one of the output sub-feature maps is obtained according to the following formula:

Y

(

m

,

n

,

t

)

=

i

=

0

d

-

1

j

=

0

d

-

1

k

=

1

C

-

"\[LeftBracketingBar]"

X

(

m

+

i

,

n

+

j

,

k

)

-

F

(

i

,

j

,

k

,

t

)

"\[RightBracketingBar]"

;

or

Y

(

m

,

n

,

t

)

=

i

=

0

d

-

1

j

=

0

d

-

1

k

=

1

C

-

"\[LeftBracketingBar]"

X

(

m

+

i

,

n

+

j

,

k

)

+

F

(

i

,

j

,

k

,

t

)

"\[RightBracketingBar]"

,

wherein

|(⋅)| is an operation for taking an absolute value, Σ(⋅) is a summation operation, Y(m,n,t) is the at least one of the output sub-feature maps, Y(m,n,t) is an element in an m th row and an n th column on a t th page in the output feature map, X(m+i,n+j,k) is an element determined based on an i th row and a j th column on a k th page in the at least one of the input sub-feature maps, F(i,j,k,t) is an element in an i th row and a j th column on a k th page in the feature extraction kernel, t is a channel quantity of the feature extraction kernel, d is a row quantity of the feature extraction kernel, C is a channel quantity of the input feature map, and d, C, i, j, k, m, n, and t are all integers.

16. The non-transitory computer-readable storage medium of claim 13 , wherein a gradient of the feature extraction kernel is determined based on the target matrix, and a gradient of the input sub-feature map is determined based on the target matrix.

17. A chip, wherein the chip comprises at least one processor and a data interface, and the at least one processor reads instructions stored in a memory through the data interface, to:

obtain an input feature map of a to-be-processed image, wherein the input feature map comprises a plurality of input sub-feature maps;

perform feature extraction processing on the input feature map based on a feature extraction kernel of a neural network to obtain an output feature map, wherein the output feature map comprises a plurality of output sub-feature maps, wherein each of the plurality of output sub-feature maps is determined based on the corresponding input sub-feature map and the feature extraction kernel, wherein at least one of the output sub-feature maps is determined based on a target matrix obtained after an absolute value is taken, and wherein a difference between the target matrix and the input sub-feature map corresponding to the target matrix is the feature extraction kernel; and

classify the to-be-processed image based on the output feature map to obtain a classification result of the to-be-processed image.

18. The chip of claim 17 , wherein the target matrix is obtained by performing matrix addition or matrix subtraction on at least one of the input sub-feature maps and the feature extraction kernel.

19. The chip of claim 18 , wherein the at least one of the output sub-feature maps is obtained according to the following formula:

Y

(

m

,

n

,

t

)

=

i

=

0

d

-

1

j

=

0

d

-

1

k

=

1

C

-

"\[LeftBracketingBar]"

X

(

m

+

i

,

n

+

j

,

k

)

-

F

(

i

,

j

,

k

,

t

)

"\[RightBracketingBar]"

;

or

Y

(

m

,

n

,

t

)

=

i

=

0

d

-

1

j

=

0

d

-

1

k

=

1

C

-

"\[LeftBracketingBar]"

X

(

m

+

i

,

n

+

j

,

k

)

+

F

(

i

,

j

,

k

,

t

)

"\[RightBracketingBar]"

,

wherein

|(⋅)| is an operation for taking an absolute value, Σ(⋅) is a summation operation, Y(m,n,t) is the at least one of the output sub-feature maps, Y(m,n,t) is an element in an m th row and an n th column on a t th page in the output feature map, X(m+i,n+j,k) is an element determined based on an i th row and a j th column on a k th page in the at least one of the input sub-feature maps, F(i,j,k,t) is an element in an i th row and a j th column on a k th page in the feature extraction kernel, t is a channel quantity of the feature extraction kernel, d is a row quantity of the feature extraction kernel, C is a channel quantity of the input feature map, and d, C, i, j, k, m, n, and t are all integers.

20. The chip of claim 17 , wherein a gradient of the feature extraction kernel is determined based on the target matrix, and a gradient of the input sub-feature map is determined based on the target matrix.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Mar 3, 2022
From: CHEN, HANTING; WANG, YUNHE; XU, CHUNJING
To: HUAWEI TECHNOLOGIES CO., LTD.
Reel/Frame 059163/0222 →
Priority Claims (1)
CN 201910695762.0 · Jul 30, 2019 · national
Continuity (2)
Continuation PCTCN2020105869 · Jul 30, 2020
Related Publication 20220157046A1 · May 19, 2022