Mở đầu
Tham khảo chính từ bài thuyết trình của anh Nguyễn Tuấn Nghĩa TMA 12/2022
Image Retrieval: dựa vào đặc trưng của image query để tìm các bức ảnh tương ứng trong database và xuất ra output cuối
ví dụ:
- Product Search: Tìm sản phẩm tương tự
- 3D reconstruction: dựa vào tìm vật mà xây dựng lại 3D reconstruction
- Logo Search: Tìm xem thiết kế Logo đã có hay trùng ai không
Logo image -CNN-> Spatial feature map -> flatten -> So sánh với database dạng flattened feature map
Vấn đề: - CNN chỉ trích xuất feature mà không quan tâm location -> Phép tịnh tiến translation làm 2 Logo giống nhau (nhưng 1 ở bên trái 1 ở bên phải) thành 2 feature khác nhau
-> Phụ thuộc vào vị trí (location) và hướng (orientation)-> Homography
-> Ý tưởng: global descriptor cho toàn bức ảnh mà bỏ qua thông tin không gian (ignoring spatial information)
-> Vector of Aggregated Local Descriptor (VLAD)
VLAD
Ý tưởng: (Predefined Vocal): Bag of features (BOF)
- Ta có trước những data hoàn hảo [a, b, c, d, e]
- So sánh feature vector của tất cả chữ a trong ảnh và feature vector của chữ a hoàn hảo (Euclide distance/NN) rồi normalize lại (mean) -> 0.3 . Tương tự với b,c,d,e -> 0.7, 0.4, 0.6, 0.4
- Thấy rằng vector tổng hợp của bức 1 và bức 4 gần giống nhau -> predict là cùng 1 người (cùng 1 nguồn)
Ví dụ sử dụng SIFT descriptor:
- Từ database, dùng Kmeans để tạo vocabulary
- Với mỗi image trong database, tính VLAD
- Tính SIFT của query image -> VLAD của query image
- dot product giữa query VLAD và database VLAD -> tìm được ảnh tương ứng (matching)
Về mặt toán: Implement:
https://github.com/ginofft/VLAD/blob/master/demo.ipynb
Output:
- vlads.h5 : vector của toàn bộ database
- vocabs.joblib : vocabulary
Hạn chế:
- SIFT Descriptor (handcrafted descriptor) -> Khó fine-tuning theo mục đích riêng, accurate cũng kém hơn các data-based
- Nearest Neighbor: Discrete -> Không dùng backpropagation để train được
-> NetVLAD
- Retrieval Eficiency:
+ Storing million of VLAD -> memory constraint -> hashing algorithm hoặc Dimension Reduce (PCA)
+ Đi qua từng ảnh nên lâu -> Approximate Nearest Neighbors hoặc Clustering Models
- Using Local features: chưa dùng đến Local features -> Local feature với spatial information để re-rank images trong tập output VLAD
Fisher Kernel
1 phương hướng khác cho bài toán Global feature vector
1 công cụ hữu ích để biến nhiều vector có size khác nhau à independent samples về cùng 1 size cho trước. Ý tưởng là gradient của sample's likelihood về các tham số, scaled bởi inverse square root của Fisher information matrix. Thay đổi hướng của parameter space để fit hơn với observed data. Vì vậy discriminative classifiers có thể learn trong biểu diễn space mới
https://www.youtube.com/watch?v=iEOcV959J80&ab_channel=DAGMGCPR2021Còn có thể dùng trong bài toán part features combine hay Fine-grained Recognition
Fisher Vetor Encoding: orderless encoding + variable number of feature
Miêu tả rõ hơn về mặt toán học:
Với trường hợp Gaussian distribution: -> GMM Gaussian Mixture Model
Ta thấy mọi tham số đều differenable (đạo hàm được) -> train được discriminative classifiersVậy, tham số ta cần optimized với gradient descent là pui, alpha và s
Đặc biệt ta phân tích về stock gradient descent ở ConvMaps of parts và Fisher vector enoding3. EMA bias corection (giống Adam update)
Estimated GMM:
Approximate Nearest Neighbors
Tính toán khoảng cách bất đối xứng (Asymmetric distance computation) là 1 phương thức đo lường sự không giống nhau giữa 2 đối tượngĐể có good vector approximatio, k nên lớn (k=2^64 cho 64-bit code)
NetVLAD 2016 Generalized VLAD Layer
NetVLAD layer có thể biểu diễn như 1 meta-layer (mà có thể phát triển thành nối giữa CNN và directed acyclic graph). softmax function -> soft-assignment: 1 convolution với K filters {wk} có spatial support 1x1 và biases {bk} (1 linear layer)
và 1 convolution output qua softmax -> soft-assignment
Baseline: là CNN conv5, có ther sử dụng Max Pooling (fmax) hoặc VLAD(fVLAD) kết hợp backbone là AlexNet, CGG-16 và method thiêu,conv4 tức là weights của layer 4 và trước đó đã learnBest NetVLAD: VGG16 + fVLAD whitening down size to 256-D
Triplet Loss dựa vào bộ (archor, positive, negative), dù vậy không phải mọi triplet bằng nhau
Batch Hard:
Tham khảo
- https://lear.inrialpes.fr/pubs/2010/JDSP10/jegou_compactimagerepresentation.pdf
- https://github.com/ginofft/NetVLAD
- https://en.wikipedia.org/wiki/Fisher_kernel
- https://www.sciencedirect.com/science/article/abs/pii/S0031320321001394
- https://www.robots.ox.ac.uk/~vgg/publications/2013/arandjelovic13/arandjelovic13.pdf
- https://www.youtube.com/watch?v=iEOcV959J80&ab_channel=DAGMGCPR2021
- https://arxiv.org/pdf/1511.07247.pdf
- https://github.com/ginofft/VLAD
- https://viblo.asia/p/thuat-toan-toi-uu-adam-aWj53k8Q56m
- https://www.kaggle.com/competitions/youtube8m-2018/discussion/62781
Nhận xét
Đăng nhận xét