hamming embedding and weak geometry consistency for...

42
Hamming Embedding and Weak Geometry Consistency for large scale image search Hervé Jégou, Matthijs Douze & Cordelia Schmid

Upload: others

Post on 02-Jun-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming Embedding and Weak Geometry Consistency for large scale image search

Hervé Jégou, Matthijs Douze & Cordelia Schmid

Page 2: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Large scale object/scene recognition

• Each image described by approximately 2000 descriptors• 2 109 descriptors to index!

• Database representation in RAM: • Raw size of descriptors : 1 TB, search+memory intractable

• Fast search with LSH: 800 GB, memory intractable

Image search system

ranked image list

Image dataset:> 1 million images

query

Page 3: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

State-of-the-art: Bag-of-features (BOF) [Sivic & Zisserman’03]

Hessian-Affineregions + SIFT descriptors

Bag-of-featuresprocessing

+tf-idf weighting

querying

sparse frequency vector

centroids(visual words)

Invertedfile

[Mikolajezyk & Schmid 04][Lowe 04]

ranked imageshort-list

Set of SIFTdescriptors

Queryimage

Geometricverification

Re-ranked list

[Lowe 04, Chum & al 2007]

• “visual words”: • 1 “word” (index) per local descriptor

• only images ids in inverted file

=> 8 GB fits!

[Sivic & al 03, Nister & al 04, …]

Page 4: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Outline

• Bag-of-features: approximate nearest neighbors (ANN) search interpretation

• Hamming Emdedding

• Weak geometry consistency

Page 5: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Bag-of-features as an ANN search algorithm

• Matching function of descriptors : k-nearest neighbors or -search

• Bag-of-features matching functionwhere q(x) is a quantizer, i.e., assignment to visual word and

δa,b is the Kronecker operator (δa,b=1 iff a=b)

fq(x; y) = ±q(x);q(y)

Page 6: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Approximate nearest neighbor search evaluation

• ANN algorithms usually returns a short-list of nearest neighbors• this short-list is supposed to contain the NN with high probability

• exact search may be performed to re-order this short-list

• Proposed quality evaluation of ANN search: trade-off between

• Accuracy: NN recall = probability that the NN is in this list

against

• Ambiguity removal = proportion of vectors in the short-list• the lower this proportion, the more information we have about the vector

• the lower this proportion, the lower the complexity if we perform exact search on the short-list

• ANN search algorithms usually have some parameters to handle this trade-off

Page 7: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

ANN evaluation of bag-of-features

ANN algorithms returns a list of potential neighbors

Accuracy: NN recall= probability that the NN is in this list

Ambiguity removal: = proportion of vectors in the short-list

In BOF, this trade-off is managed by the number of clusters k

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

1e-07 1e-06 1e-05 0.0001 0.001 0.01 0.1

NN

rec

all

rate of points retrieved

k=100

200

500

1000

2000

5000

10000

20000 30000

50000

BOF

Page 8: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Outline

• Bag-of-features: voting and ANN interpretation

• Hamming Embedding

• Weak geometry consistency

Page 9: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

State-of-the art: First issue

• The intrinsic matching scheme performed by BOF is weak• for a “small” visual dictionary: too many false matches

• for a “large” visual dictionary: many true matches are missed

• No good trade-off between “small” and “large” !• either the Voronoi cells are too big

• or these cells can’t absorb the descriptor noise

→ intrinsic approximate nearest neighbor search of BOF is not sufficient

Page 10: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

20K visual word: false matchs

Page 11: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

200K visual word: good matches missed

Page 12: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

State-of-the art: First issue

• Need to fight against the quantization noise→ several recent paper proposed methods to have a richer representation of (sets of) descriptors

• In image search: multiple or soft assignment of descriptors to visual words• Jegou et al, “A contextual dissimilarity measure for accurate and efficient

image search”, CVPR’2007

• Philbin et al., “Lost in quantization: improving particular object retrieval in large scale image databases”, CVPR’2008

• these methods reduce the sparsity of the BOF representation → negative impact on the search efficiency

Page 13: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming Embedding

• Representation of a descriptor x• Vector-quantized to q(x) as in standard BOF

+ short binary vector b(x) for an additional localization in the Voronoi cell

• Two descriptors x and y match iif

where h(a,b) is the Hamming distance

• Nearest neighbors for Hamming distance ≈ those for Euclidean distance→ a metric in the embedded space reduces dimensionality curse effects

• Efficiency

• Hamming distance = very few operations

• Fewer random memory accesses: 3 x faster that standard BOF with same dictionary size!

½q(x) = q(y)h(b(x); b(y)) < ¿

Page 14: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming Embedding

• Off-line (given a quantizer)

• draw an orthogonal projection matrix P of size db × d

→ this defines db random projection directions

• for each Voronoi cell and projection direction, compute the median value for a learning set

• On-line: compute the binary signature b(x) of a given descriptor

• project x onto the projection directions as z(x) = (z1,…zdb)

• bi(x) = 1 if zi(x) is above the learned median value, otherwise 0

Page 15: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Indexing structurefilters 99.9995%

of the descriptors(for k=200000)

filters 98.8% of the remaining descriptors

(for ht=22)

Page 16: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming and Euclidean neighborhood

• trade-off between memory usage and accuracy

→ more bits yield higher accuracy

We used 64 bits (8 bytes)

0

0.2

0.4

0.6

0.8

1

0 0.2 0.4 0.6 0.8 1

rate

of

5-N

N r

etri

eved

(re

call)

rate of cells points retrieved

8 bits16 bits32 bits64 bits

128 bits

arbitr

ar des

criptor f

ilterin

g (ran

dom)

Page 17: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming Embedding: filtering matches

3.0%

53.6%

93.6%

23.7%

0

0.2

0.4

0.6

0.8

1

10 20 30 40 50 60

reca

ll

Hamming distance threshold

5-NN

all descriptors

b(x) {0,1}64∈

Page 18: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

ANN evaluation of Hamming Embedding

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

1e-08 1e-07 1e-06 1e-05 0.0001 0.001 0.01 0.1

NN

rec

all

rate of points retrieved (=1-filtering rate)

k=100

200

500

1000

2000

5000

10000

20000 30000

50000

ht=16

18

20

22

HE+BOFBOF

32 28 24

compared to BOF: at least 10 times less points in the short-list for the same level of accuracy

Hamming Embedding provides a much better trade-off between recall and ambiguity removal

Page 19: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming Embedding: Example

Page 20: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Compared with 20K dictionary : false matches

Page 21: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Hamming Embedding: Example

Page 22: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Compared with 200K visual word: good matches missed

Page 23: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Outline

• Bag-of-features: voting and ANN interpretation

• Hamming Emdedding

• Weak geometry consistency

Page 24: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

State-of-the art: Second issue

• Re-ranking based on full geometric verification • works very well

• but performed on a short-list only (typically, 100 images)

→ for very large datasets, the number of distracting images is so high that relevant images are not even short-listed!

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

1000 10000 100000 1000000dataset size

rate

of r

elev

ant i

mag

es s

hort

-list

ed 20 images

100 images

1000 images

short-list size:

[Lowe 04, Chum & al 2007]

Page 25: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Weak geometry consistency

• Weak geometric information used for all images (not only the short-list)

• Each invariant interest region detection has a scale and rotation angle associated, here characteristic scale and dominant gradient orientation

Scale change 2Rotation angle ca. 20 degrees

• Each matching pair results in a scale and angle difference

• For the global image scale and rotation changes are roughly consistent

Page 26: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Pisa tower: Let analyze the dominent orientation difference of matching descriptors

Page 27: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Max = rotation angle between images

Orientation consistency

FILTERED!

Page 28: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

PEAK

FILTERED!

Page 29: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

WGC: scale consistency

PEAK

FILTERED!

Page 30: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

WGC: scale consistency

FILTERED!

PEAK

Page 31: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Weak geometry consistency

• Integrate the geometric verification into the BOF representation • votes for an image projected onto two quantized subspaces, that is vote for

an image at a given angle & scale

→ these subspace are shown to be independent

• a score sj for all quantized angle and scale differences for each image

• final score: filtering for each parameter (angle and scale) and min selection

• Only matches that do agree with the main difference of orientation and scale will be taken into account in the final score

• Re-ranking using full geometric transformation still adds information in a final stage

Page 32: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Integrating geometric a priori information

• Images orientation difference is strongly non uniform• natural orientation for many images (but still π/2 rotation ambiguity)

• human tendency to use the same orientation for the same place

0.01

0.1

2pi3pi/2pi0quantized angle difference

non matching images

matching images

rate

of

mat

ches

pi/2

0.01

0.1

2pi3pi/2pipi/20

wei

ghti

ng

quantized angle difference

prior: pi/2 rotation

PRIOR

Page 33: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Experimental results

• Evaluation for the INRIA holidays dataset, 1491 images• 500 query images + 991 annotated true positives

• Most images are holiday photos of friends and family

• 1 million distractor images from Flickr

• Dataset size 1.001.491 images

• Vocabulary construction on a different Flickr set

• Almost real-time search speed, see retrieval demo

• Evaluation metric: mean average precision (in [0,1], bigger = better)

• Average over precision/recall curve

Page 34: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Holidays dataset – example queries (out of 500)

Page 35: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Example query – response : Venice Channel

Query

Base 4Base 3

Base 2Base 1

Page 36: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Example query – response : San Marco square

Query Base 1 Base 3Base 2

Base 9Base 8

Base 4 Base 5 Base 7Base 6

Page 37: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Results – Venice Channel

Base 1 Flickr

Flickr Base 4

Base 3

Query

Page 38: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

BOF 2Ours 1

BOF 43064Ours 5

Query

BOF 5890Ours 4

Page 39: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Results – San Marco

Query

Base 01 Base 03

Base 02 Base 06

Flickr Flickr

Page 40: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Comparison with state-of-the-art

• Evaluation on our holidays dataset, 500 query images, 1 million images in total

• Metric: mean average precision (in [0,1], bigger = better)

2110 msSearch – WGC

Average query time (4 CPU cores)

650 msSearch – HE+WGC200 msSearch – HE

620 msSearch – baseline600 msQuantization880 msCompute descriptors

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

1000000100000100001000

mA

P

database size

baselineWGC

HEWGC+HE

+re-ranking

Page 41: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Trecvid video copy detection task: evaluation results

• NDCR measure: the lower the best (0 = perfect)

• See our excellent results for all types of transformations below• circles: our result• squares: best results• dashed: medians of all runs (22 participants)

Page 42: Hamming Embedding and Weak Geometry Consistency for …masc.cs.gmu.edu/wiki/uploads/GuilinLiu/ham.pdf• final score: filtering for each parameter (angle and scale) and min selection

Conclusion

• HE: state-of-the-art representation of local descriptors

• WGC: use partial geometry information for billions descriptors

• See Internet demo (from http://lear.inrialpes.fr)

• Trecvid copyright detection task: we obtained excellent results

DEMO AND QUESTIONS