{
  "id": 275955,
  "title": "5th Place Postprocessing Part - Bridged Connections",
  "url": "/competitions/landmark-retrieval-2021/discussion/275955",
  "author_name": "Kumar Shubham",
  "post_date": "2021-10-02T12:24:53.390000",
  "votes": 22,
  "comment_count": 0,
  "views": 0,
  "content": "<h1>Postprocessing Part of our solution</h1>\n<p>Huge congratulations and thanks for my teammate <a href=\"https://www.kaggle.com/tereka\" target=\"_blank\">@tereka</a> for showing brilliant efforts throughout the competition. Congratulations to other top teams as well. Special mention to Google TPU Research Program  (<a href=\"https://sites.research.google/trc/\" target=\"_blank\">https://sites.research.google/trc/</a>) which helped us in training bigger models in the last few days of the competition. </p>\n<p>Many a times we can't match index and test images by direct KNN (for example: indoor/outdoor images). Our postprocessing is based on using train images to find these connections (we call this bridged connections). This postprocessing alone gives boost of 0.075-0.09 on public/private lb.</p>\n<p>Our solution is inspired from:</p>\n<ol>\n<li>3rd place solution of 2019 Google Landmark retrieval competition. ( <a href=\"https://arxiv.org/pdf/1906.04944.pdf\" target=\"_blank\">https://arxiv.org/pdf/1906.04944.pdf</a> ) -&gt; Idea of using Landmark Assignment</li>\n<li>1st place solution of 2020 Google Landmark recognition competition (<a href=\"https://arxiv.org/pdf/2010.01650.pdf\" target=\"_blank\">https://arxiv.org/pdf/2010.01650.pdf</a> ) -&gt; Non Landmark Confidence Adjustments</li>\n<li>3rd place solution of 2020 Google Landmark recognition competition ( <a href=\"https://arxiv.org/pdf/2010.05350.pdf\" target=\"_blank\">https://arxiv.org/pdf/2010.05350.pdf</a> ) -&gt; Power Average</li>\n</ol>\n<h2>PART A - Bridged Distance Computation</h2>\n<h3>Step 1: Computing Distance between (test and landmark) and (index and landmark)</h3>\n<ol>\n<li>So, for each test and index image, we pick top 300 neighbours from train images using KNN (RAPIDS)</li>\n<li>We penalise each train image by non landmark distances. Non landmark scores for each train image is computed using non landmark images from 2019 test set. We take top 10 neighbours for each train image and get the average of their distances. (2020 Recognition 1st place solution)</li>\n<li>We compute distance between each test image and landmark id -&gt; Pick top k (k=2) nearest train images belonging to landmark from test and average them</li>\n<li>Similarly, we compute distance between each index image and landmark id </li>\n</ol>\n<h3>Step 2: Finding Top 5 Landmarks for each test and index images</h3>\n<ol>\n<li>We pick top 5 nearest landmarks for each test and index images with the help of distance calculated above</li>\n<li>We add bonus confidence (0.5) to the nearest landmark for each test and index image (distance = distance - 0.5)</li>\n</ol>\n<h3>Step 3: Calculating Bridged Distance</h3>\n<ol>\n<li><p>Bridged Distance between test and index images is calculated as: </p>\n<pre><code> Min( Max((test,landmark_id),(index,landmark_id)) for all landmark_id )\n</code></pre></li>\n</ol>\n<h2>PART B - Direct Distance Computation</h2>\n<ol>\n<li>We apply DBA (Database Augmentation) on index and test embeddings and then apply KNN.  We found that the direct connections have very high precision at high confidences but bridged connections bring more neighbours.</li>\n</ol>\n<h2>PART C - Reranking</h2>\n<ol>\n<li><p>We converted all distances into confidence -&gt; Confidence = 1-distance</p></li>\n<li><p>We aggregated direct and bridged confidence using power average approach (3rd place solution for recognition 2020)</p>\n<pre><code>Final Confidence = Direct Confidence**3 + Bridged Confidence**3\n</code></pre></li>\n<li><p>We pick top 100 index images for each test image using the confidence score calculated above. </p></li>\n</ol>\n<h2>Postprocessing Optimisation:</h2>\n<p>All the post-processing hyperparmeters were optimised on 2019 index/test dataset.</p>\n<p>Training Details are available here: <a href=\"https://www.kaggle.com/c/landmark-retrieval-2021/discussion/275942\" target=\"_blank\">https://www.kaggle.com/c/landmark-retrieval-2021/discussion/275942</a><br>\nInference Code is available here:  <a href=\"https://www.kaggle.com/ks2019/landmark-retrieval-5th-place-inference-notebook\" target=\"_blank\">https://www.kaggle.com/ks2019/landmark-retrieval-5th-place-inference-notebook</a></p>\n<p>Git Repo: <a href=\"https://github.com/kumar-shubham-ml/5th-Place-Solution-to-Google-Landmark-Retrieval-2021\" target=\"_blank\">https://github.com/kumar-shubham-ml/5th-Place-Solution-to-Google-Landmark-Retrieval-2021</a></p>",
  "messages": [
    {
      "id": 1531833,
      "postDate": "2021-10-02T12:24:53.390Z",
      "content": "<h1>Postprocessing Part of our solution</h1>\n<p>Huge congratulations and thanks for my teammate <a href=\"https://www.kaggle.com/tereka\" target=\"_blank\">@tereka</a> for showing brilliant efforts throughout the competition. Congratulations to other top teams as well. Special mention to Google TPU Research Program  (<a href=\"https://sites.research.google/trc/\" target=\"_blank\">https://sites.research.google/trc/</a>) which helped us in training bigger models in the last few days of the competition. </p>\n<p>Many a times we can't match index and test images by direct KNN (for example: indoor/outdoor images). Our postprocessing is based on using train images to find these connections (we call this bridged connections). This postprocessing alone gives boost of 0.075-0.09 on public/private lb.</p>\n<p>Our solution is inspired from:</p>\n<ol>\n<li>3rd place solution of 2019 Google Landmark retrieval competition. ( <a href=\"https://arxiv.org/pdf/1906.04944.pdf\" target=\"_blank\">https://arxiv.org/pdf/1906.04944.pdf</a> ) -&gt; Idea of using Landmark Assignment</li>\n<li>1st place solution of 2020 Google Landmark recognition competition (<a href=\"https://arxiv.org/pdf/2010.01650.pdf\" target=\"_blank\">https://arxiv.org/pdf/2010.01650.pdf</a> ) -&gt; Non Landmark Confidence Adjustments</li>\n<li>3rd place solution of 2020 Google Landmark recognition competition ( <a href=\"https://arxiv.org/pdf/2010.05350.pdf\" target=\"_blank\">https://arxiv.org/pdf/2010.05350.pdf</a> ) -&gt; Power Average</li>\n</ol>\n<h2>PART A - Bridged Distance Computation</h2>\n<h3>Step 1: Computing Distance between (test and landmark) and (index and landmark)</h3>\n<ol>\n<li>So, for each test and index image, we pick top 300 neighbours from train images using KNN (RAPIDS)</li>\n<li>We penalise each train image by non landmark distances. Non landmark scores for each train image is computed using non landmark images from 2019 test set. We take top 10 neighbours for each train image and get the average of their distances. (2020 Recognition 1st place solution)</li>\n<li>We compute distance between each test image and landmark id -&gt; Pick top k (k=2) nearest train images belonging to landmark from test and average them</li>\n<li>Similarly, we compute distance between each index image and landmark id </li>\n</ol>\n<h3>Step 2: Finding Top 5 Landmarks for each test and index images</h3>\n<ol>\n<li>We pick top 5 nearest landmarks for each test and index images with the help of distance calculated above</li>\n<li>We add bonus confidence (0.5) to the nearest landmark for each test and index image (distance = distance - 0.5)</li>\n</ol>\n<h3>Step 3: Calculating Bridged Distance</h3>\n<ol>\n<li><p>Bridged Distance between test and index images is calculated as: </p>\n<pre><code> Min( Max((test,landmark_id),(index,landmark_id)) for all landmark_id )\n</code></pre></li>\n</ol>\n<h2>PART B - Direct Distance Computation</h2>\n<ol>\n<li>We apply DBA (Database Augmentation) on index and test embeddings and then apply KNN.  We found that the direct connections have very high precision at high confidences but bridged connections bring more neighbours.</li>\n</ol>\n<h2>PART C - Reranking</h2>\n<ol>\n<li><p>We converted all distances into confidence -&gt; Confidence = 1-distance</p></li>\n<li><p>We aggregated direct and bridged confidence using power average approach (3rd place solution for recognition 2020)</p>\n<pre><code>Final Confidence = Direct Confidence**3 + Bridged Confidence**3\n</code></pre></li>\n<li><p>We pick top 100 index images for each test image using the confidence score calculated above. </p></li>\n</ol>\n<h2>Postprocessing Optimisation:</h2>\n<p>All the post-processing hyperparmeters were optimised on 2019 index/test dataset.</p>\n<p>Training Details are available here: <a href=\"https://www.kaggle.com/c/landmark-retrieval-2021/discussion/275942\" target=\"_blank\">https://www.kaggle.com/c/landmark-retrieval-2021/discussion/275942</a><br>\nInference Code is available here:  <a href=\"https://www.kaggle.com/ks2019/landmark-retrieval-5th-place-inference-notebook\" target=\"_blank\">https://www.kaggle.com/ks2019/landmark-retrieval-5th-place-inference-notebook</a></p>\n<p>Git Repo: <a href=\"https://github.com/kumar-shubham-ml/5th-Place-Solution-to-Google-Landmark-Retrieval-2021\" target=\"_blank\">https://github.com/kumar-shubham-ml/5th-Place-Solution-to-Google-Landmark-Retrieval-2021</a></p>",
      "rawMarkdown": "# Postprocessing Part of our solution\n\nHuge congratulations and thanks for my teammate @tereka for showing brilliant efforts throughout the competition. Congratulations to other top teams as well. Special mention to Google TPU Research Program  (https://sites.research.google/trc/) which helped us in training bigger models in the last few days of the competition. \n\nMany a times we can't match index and test images by direct KNN (for example: indoor/outdoor images). Our postprocessing is based on using train images to find these connections (we call this bridged connections). This postprocessing alone gives boost of 0.075-0.09 on public/private lb.\n\nOur solution is inspired from:\n1. 3rd place solution of 2019 Google Landmark retrieval competition. ( https://arxiv.org/pdf/1906.04944.pdf ) -> Idea of using Landmark Assignment\n2. 1st place solution of 2020 Google Landmark recognition competition (https://arxiv.org/pdf/2010.01650.pdf ) -> Non Landmark Confidence Adjustments\n3. 3rd place solution of 2020 Google Landmark recognition competition ( https://arxiv.org/pdf/2010.05350.pdf ) -> Power Average\n\n## PART A - Bridged Distance Computation\n\n### Step 1: Computing Distance between (test and landmark) and (index and landmark)\n\n1. So, for each test and index image, we pick top 300 neighbours from train images using KNN (RAPIDS)\n2. We penalise each train image by non landmark distances. Non landmark scores for each train image is computed using non landmark images from 2019 test set. We take top 10 neighbours for each train image and get the average of their distances. (2020 Recognition 1st place solution)\n3. We compute distance between each test image and landmark id -> Pick top k (k=2) nearest train images belonging to landmark from test and average them\n4. Similarly, we compute distance between each index image and landmark id \n\n### Step 2: Finding Top 5 Landmarks for each test and index images\n5. We pick top 5 nearest landmarks for each test and index images with the help of distance calculated above\n6. We add bonus confidence (0.5) to the nearest landmark for each test and index image (distance = distance - 0.5)\n\n### Step 3: Calculating Bridged Distance\n7. Bridged Distance between test and index images is calculated as: \n\n         Min( Max((test,landmark_id),(index,landmark_id)) for all landmark_id )\n\n## PART B - Direct Distance Computation\n\n1. We apply DBA (Database Augmentation) on index and test embeddings and then apply KNN.  We found that the direct connections have very high precision at high confidences but bridged connections bring more neighbours.\n\n## PART C - Reranking\n\n1. We converted all distances into confidence -> Confidence = 1-distance\n2. We aggregated direct and bridged confidence using power average approach (3rd place solution for recognition 2020)\n\n        Final Confidence = Direct Confidence**3 + Bridged Confidence**3\n        \n3. We pick top 100 index images for each test image using the confidence score calculated above. \n\n## Postprocessing Optimisation:\n\nAll the post-processing hyperparmeters were optimised on 2019 index/test dataset.\n\nTraining Details are available here: https://www.kaggle.com/c/landmark-retrieval-2021/discussion/275942\nInference Code is available here:  https://www.kaggle.com/ks2019/landmark-retrieval-5th-place-inference-notebook\n\nGit Repo: https://github.com/kumar-shubham-ml/5th-Place-Solution-to-Google-Landmark-Retrieval-2021",
      "votes": 22
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1531833": "# Postprocessing Part of our solution\n\nHuge congratulations and thanks for my teammate @tereka for showing brilliant efforts throughout the competition. Congratulations to other top teams as well. Special mention to Google TPU Research Program  (https://sites.research.google/trc/) which helped us in training bigger models in the last few days of the competition. \n\nMany a times we can't match index and test images by direct KNN (for example: indoor/outdoor images). Our postprocessing is based on using train images to find these connections (we call this bridged connections). This postprocessing alone gives boost of 0.075-0.09 on public/private lb.\n\nOur solution is inspired from:\n1. 3rd place solution of 2019 Google Landmark retrieval competition. ( https://arxiv.org/pdf/1906.04944.pdf ) -> Idea of using Landmark Assignment\n2. 1st place solution of 2020 Google Landmark recognition competition (https://arxiv.org/pdf/2010.01650.pdf ) -> Non Landmark Confidence Adjustments\n3. 3rd place solution of 2020 Google Landmark recognition competition ( https://arxiv.org/pdf/2010.05350.pdf ) -> Power Average\n\n## PART A - Bridged Distance Computation\n\n### Step 1: Computing Distance between (test and landmark) and (index and landmark)\n\n1. So, for each test and index image, we pick top 300 neighbours from train images using KNN (RAPIDS)\n2. We penalise each train image by non landmark distances. Non landmark scores for each train image is computed using non landmark images from 2019 test set. We take top 10 neighbours for each train image and get the average of their distances. (2020 Recognition 1st place solution)\n3. We compute distance between each test image and landmark id -> Pick top k (k=2) nearest train images belonging to landmark from test and average them\n4. Similarly, we compute distance between each index image and landmark id \n\n### Step 2: Finding Top 5 Landmarks for each test and index images\n5. We pick top 5 nearest landmarks for each test and index images with the help of distance calculated above\n6. We add bonus confidence (0.5) to the nearest landmark for each test and index image (distance = distance - 0.5)\n\n### Step 3: Calculating Bridged Distance\n7. Bridged Distance between test and index images is calculated as: \n\n         Min( Max((test,landmark_id),(index,landmark_id)) for all landmark_id )\n\n## PART B - Direct Distance Computation\n\n1. We apply DBA (Database Augmentation) on index and test embeddings and then apply KNN.  We found that the direct connections have very high precision at high confidences but bridged connections bring more neighbours.\n\n## PART C - Reranking\n\n1. We converted all distances into confidence -> Confidence = 1-distance\n2. We aggregated direct and bridged confidence using power average approach (3rd place solution for recognition 2020)\n\n        Final Confidence = Direct Confidence**3 + Bridged Confidence**3\n        \n3. We pick top 100 index images for each test image using the confidence score calculated above. \n\n## Postprocessing Optimisation:\n\nAll the post-processing hyperparmeters were optimised on 2019 index/test dataset.\n\nTraining Details are available here: https://www.kaggle.com/c/landmark-retrieval-2021/discussion/275942\nInference Code is available here:  https://www.kaggle.com/ks2019/landmark-retrieval-5th-place-inference-notebook\n\nGit Repo: https://github.com/kumar-shubham-ml/5th-Place-Solution-to-Google-Landmark-Retrieval-2021"
  }
}