{
  "id": 275924,
  "title": "13th Place - Soft Landmark ID Assignment",
  "url": "/competitions/landmark-retrieval-2021/writeups/prateek-agnihotri-13th-place-soft-landmark-id-assi",
  "author_name": "",
  "post_date": "2021-10-02T09:57:27.713Z",
  "votes": 27,
  "comment_count": 5,
  "views": 0,
  "content": "<p>Thanks to google and kaggle for hosting this competition and clairvoyant.ai for supporting this work. It was a lot of fun and a full of learning experience.</p>\n<p>Certainly, due to limited hardware, extremely large dataset, and time constraints, my models are not that powerful like top teams, but I would love to discuss post-processing, which uses soft landmark id assignment for index and test images, and gave <strong>+0.075</strong> boost on private LB.</p>\n<p>But before, to give a glimpse of models.</p>\n<h2>Models</h2>\n<p>I was using CurricularFace loss along with Adam Optimizer and Gradient Accumulation to train my models. I was using an ensemble of 5 models. All models were trained on the full GLDV2 dataset.</p>\n<p>Their scores without any post-processing and using simple KNN on model embeddings are - </p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>Image Size</th>\n<th>Public LB</th>\n<th>Private LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Effnet B4</td>\n<td>512</td>\n<td>0.322</td>\n<td>0.342</td>\n</tr>\n<tr>\n<td>Effnet B6</td>\n<td>384</td>\n<td>0.331</td>\n<td>0.349</td>\n</tr>\n<tr>\n<td>Effnet v2 - s</td>\n<td>512</td>\n<td>0.325</td>\n<td>0.351</td>\n</tr>\n<tr>\n<td>Effnet v2 - m</td>\n<td>384</td>\n<td>0.357</td>\n<td>0.373</td>\n</tr>\n<tr>\n<td>Effnet v2 - xl</td>\n<td>256</td>\n<td>0.318</td>\n<td>0.319</td>\n</tr>\n<tr>\n<td>Concat all embbedings</td>\n<td></td>\n<td>0.379</td>\n<td>0.389</td>\n</tr>\n<tr>\n<td>Concat all + Post Processing</td>\n<td></td>\n<td>0.448</td>\n<td>0.464</td>\n</tr>\n</tbody>\n</table>\n<h2>Post-Processing</h2>\n<h3>Soft Landmark ID assignment</h3>\n<p><strong>Step 1:</strong> Landmark assignment - Test Images</p>\n<p>For the landmark id assignment, I calculated the cosine similarity between the test image embeddings and the embeddings of images in the GLDV2 dataset. Next, I picked the top 'n' most similar GLDV2 images for every image in test data and assigned labels and label similarity scores to that image. An example label and label score calculation for an image A in test data is mentioned below.</p>\n<p>For a test image A, pick the top  'n' (in my case, it was 5) most similar images from GLDV2-</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>GLDV2 Img 1</th>\n<th>GLDV2 Img 2</th>\n<th>GLDV2 Img 3</th>\n<th>GLDV2 Img 4</th>\n<th>GLDV2 Img 5</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Landmark ID</td>\n<td>121</td>\n<td>10</td>\n<td>121</td>\n<td>10</td>\n<td>199</td>\n</tr>\n<tr>\n<td>Similarity Score</td>\n<td>0.9</td>\n<td>0.7</td>\n<td>0.5</td>\n<td>0.47</td>\n<td>0.45</td>\n</tr>\n</tbody>\n</table>\n<p>Then Image Landmark ID score can be calculated as</p>\n<table>\n<thead>\n<tr>\n<th>Landmark ID</th>\n<th>Images</th>\n<th>Landmark ID score</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>121</td>\n<td>GLDV2 Img 1, GLDV2 Img 3</td>\n<td>0.9+0.5 = 1.4</td>\n</tr>\n<tr>\n<td>10</td>\n<td>GLDV2 Img 2, GLDV2 Img 3</td>\n<td>0.7+0.47 = 1.17</td>\n</tr>\n<tr>\n<td>199</td>\n<td>GLDV2 Img 5</td>\n<td>0.45</td>\n</tr>\n</tbody>\n</table>\n<p>Consider landmark id score as zero for landmark ids that are not there in the top 5.</p>\n<p><strong>Step 2:</strong> Landmark assignment - Index Images</p>\n<p>A similar procedure was followed for index images, and landmark ids and landmark id scores were assigned to them as well.</p>\n<p><strong>Step 3:</strong> Test-Index similarity score calculation</p>\n<p>Finally, calculated similarity between Image A from test and Image B from Index as - </p>\n<p>Similarity (A, B) = Landmark_ID_1_score(A) x Landmark_ID_1_score(B) +<br>\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_2_score(A) x Landmark_ID_2_score(B) +<br>\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_3_score(A) x Landmark_ID_3_score(B) + <br>\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ………..</p>\n<p>Then for every image in test data, arrange all similar images from index data in descending order based on their similarity score.</p>\n<p>As the next step, At the end of this list, I concatenated the knn-neighbours not found in the above search.</p>\n<p>This post-processing gave about +0.069 boost on public LB and +0.075 on private LB, with 0.448 and 0.464 as final Public and Private scores.</p>\n<h2>Additional</h2>\n<p>Additionally, I am <a href=\"https://www.kaggle.com/prateekagnihotri/curricularface-and-gradient-accumulation\" target=\"_blank\">attaching</a> my gradient accumulation code for TPUs and a TensorFlow implementation of CurricularFace. I hope you will find them useful as well.</p>",
  "messages": [
    {
      "id": "1531720",
      "postDate": "10/02/2021 09:49:16",
      "content": "<p>Thanks to google and kaggle for hosting this competition and clairvoyant.ai for supporting this work. It was a lot of fun and a full of learning experience.</p>\n<p>Certainly, due to limited hardware, extremely large dataset, and time constraints, my models are not that powerful like top teams, but I would love to discuss post-processing, which uses soft landmark id assignment for index and test images, and gave <strong>+0.075</strong> boost on private LB.</p>\n<p>But before, to give a glimpse of models.</p>\n<h2>Models</h2>\n<p>I was using CurricularFace loss along with Adam Optimizer and Gradient Accumulation to train my models. I was using an ensemble of 5 models. All models were trained on the full GLDV2 dataset.</p>\n<p>Their scores without any post-processing and using simple KNN on model embeddings are - </p>\n<table>\n<thead>\n<tr>\n<th>Model</th>\n<th>Image Size</th>\n<th>Public LB</th>\n<th>Private LB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Effnet B4</td>\n<td>512</td>\n<td>0.322</td>\n<td>0.342</td>\n</tr>\n<tr>\n<td>Effnet B6</td>\n<td>384</td>\n<td>0.331</td>\n<td>0.349</td>\n</tr>\n<tr>\n<td>Effnet v2 - s</td>\n<td>512</td>\n<td>0.325</td>\n<td>0.351</td>\n</tr>\n<tr>\n<td>Effnet v2 - m</td>\n<td>384</td>\n<td>0.357</td>\n<td>0.373</td>\n</tr>\n<tr>\n<td>Effnet v2 - xl</td>\n<td>256</td>\n<td>0.318</td>\n<td>0.319</td>\n</tr>\n<tr>\n<td>Concat all embbedings</td>\n<td></td>\n<td>0.379</td>\n<td>0.389</td>\n</tr>\n<tr>\n<td>Concat all + Post Processing</td>\n<td></td>\n<td>0.448</td>\n<td>0.464</td>\n</tr>\n</tbody>\n</table>\n<h2>Post-Processing</h2>\n<h3>Soft Landmark ID assignment</h3>\n<p><strong>Step 1:</strong> Landmark assignment - Test Images</p>\n<p>For the landmark id assignment, I calculated the cosine similarity between the test image embeddings and the embeddings of images in the GLDV2 dataset. Next, I picked the top 'n' most similar GLDV2 images for every image in test data and assigned labels and label similarity scores to that image. An example label and label score calculation for an image A in test data is mentioned below.</p>\n<p>For a test image A, pick the top  'n' (in my case, it was 5) most similar images from GLDV2-</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>GLDV2 Img 1</th>\n<th>GLDV2 Img 2</th>\n<th>GLDV2 Img 3</th>\n<th>GLDV2 Img 4</th>\n<th>GLDV2 Img 5</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Landmark ID</td>\n<td>121</td>\n<td>10</td>\n<td>121</td>\n<td>10</td>\n<td>199</td>\n</tr>\n<tr>\n<td>Similarity Score</td>\n<td>0.9</td>\n<td>0.7</td>\n<td>0.5</td>\n<td>0.47</td>\n<td>0.45</td>\n</tr>\n</tbody>\n</table>\n<p>Then Image Landmark ID score can be calculated as</p>\n<table>\n<thead>\n<tr>\n<th>Landmark ID</th>\n<th>Images</th>\n<th>Landmark ID score</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>121</td>\n<td>GLDV2 Img 1, GLDV2 Img 3</td>\n<td>0.9+0.5 = 1.4</td>\n</tr>\n<tr>\n<td>10</td>\n<td>GLDV2 Img 2, GLDV2 Img 3</td>\n<td>0.7+0.47 = 1.17</td>\n</tr>\n<tr>\n<td>199</td>\n<td>GLDV2 Img 5</td>\n<td>0.45</td>\n</tr>\n</tbody>\n</table>\n<p>Consider landmark id score as zero for landmark ids that are not there in the top 5.</p>\n<p><strong>Step 2:</strong> Landmark assignment - Index Images</p>\n<p>A similar procedure was followed for index images, and landmark ids and landmark id scores were assigned to them as well.</p>\n<p><strong>Step 3:</strong> Test-Index similarity score calculation</p>\n<p>Finally, calculated similarity between Image A from test and Image B from Index as - </p>\n<p>Similarity (A, B) = Landmark_ID_1_score(A) x Landmark_ID_1_score(B) +<br>\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_2_score(A) x Landmark_ID_2_score(B) +<br>\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_3_score(A) x Landmark_ID_3_score(B) + <br>\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ………..</p>\n<p>Then for every image in test data, arrange all similar images from index data in descending order based on their similarity score.</p>\n<p>As the next step, At the end of this list, I concatenated the knn-neighbours not found in the above search.</p>\n<p>This post-processing gave about +0.069 boost on public LB and +0.075 on private LB, with 0.448 and 0.464 as final Public and Private scores.</p>\n<h2>Additional</h2>\n<p>Additionally, I am <a href=\"https://www.kaggle.com/prateekagnihotri/curricularface-and-gradient-accumulation\" target=\"_blank\">attaching</a> my gradient accumulation code for TPUs and a TensorFlow implementation of CurricularFace. I hope you will find them useful as well.</p>",
      "rawMarkdown": "Thanks to google and kaggle for hosting this competition and clairvoyant.ai for supporting this work. It was a lot of fun and a full of learning experience.\n\nCertainly, due to limited hardware, extremely large dataset, and time constraints, my models are not that powerful like top teams, but I would love to discuss post-processing, which uses soft landmark id assignment for index and test images, and gave **+0.075** boost on private LB.\n\nBut before, to give a glimpse of models.\n\n## Models\nI was using CurricularFace loss along with Adam Optimizer and Gradient Accumulation to train my models. I was using an ensemble of 5 models. All models were trained on the full GLDV2 dataset.\n\nTheir scores without any post-processing and using simple KNN on model embeddings are - \n| Model | Image Size | Public LB | Private LB |\n| --- | --- |\n| Effnet B4 | 512 | 0.322 | 0.342 |\n| Effnet B6 | 384 | 0.331 | 0.349 |\n| Effnet v2 - s | 512 | 0.325 | 0.351 |\n| Effnet v2 - m | 384 | 0.357 | 0.373 |\n| Effnet v2 - xl | 256 | 0.318 | 0.319 |\n| Concat all embbedings |  | 0.379 | 0.389 |\n| Concat all + Post Processing |  | 0.448 | 0.464 |\n\n## Post-Processing\n###Soft Landmark ID assignment\n**Step 1:** Landmark assignment - Test Images\n\nFor the landmark id assignment, I calculated the cosine similarity between the test image embeddings and the embeddings of images in the GLDV2 dataset. Next, I picked the top 'n' most similar GLDV2 images for every image in test data and assigned labels and label similarity scores to that image. An example label and label score calculation for an image A in test data is mentioned below.\n\nFor a test image A, pick the top  'n' (in my case, it was 5) most similar images from GLDV2-\n|  | GLDV2 Img 1 | GLDV2 Img 2 | GLDV2 Img 3 | GLDV2 Img 4 | GLDV2 Img 5 |\n| --- | --- |\n| Landmark ID | 121 | 10 | 121 | 10 | 199 |\n| Similarity Score | 0.9 | 0.7 | 0.5 | 0.47 | 0.45 |\n\nThen Image Landmark ID score can be calculated as\n| Landmark ID | Images | Landmark ID score |\n| --- | --- |\n| 121 | GLDV2 Img 1, GLDV2 Img 3 | 0.9+0.5 = 1.4 |\n| 10 | GLDV2 Img 2, GLDV2 Img 3 | 0.7+0.47 = 1.17 |\n| 199 | GLDV2 Img 5 | 0.45 |\n\nConsider landmark id score as zero for landmark ids that are not there in the top 5.\n\n**Step 2:** Landmark assignment - Index Images\n\nA similar procedure was followed for index images, and landmark ids and landmark id scores were assigned to them as well.\n\n**Step 3:** Test-Index similarity score calculation\n\nFinally, calculated similarity between Image A from test and Image B from Index as - \n\nSimilarity (A, B) = Landmark_ID_1_score(A) x Landmark_ID_1_score(B) +\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_2_score(A) x Landmark_ID_2_score(B) +\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_3_score(A) x Landmark_ID_3_score(B) + \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...........\n\nThen for every image in test data, arrange all similar images from index data in descending order based on their similarity score.\n\nAs the next step, At the end of this list, I concatenated the knn-neighbours not found in the above search.\n\nThis post-processing gave about +0.069 boost on public LB and +0.075 on private LB, with 0.448 and 0.464 as final Public and Private scores.\n\n## Additional\nAdditionally, I am [attaching](https://www.kaggle.com/prateekagnihotri/curricularface-and-gradient-accumulation) my gradient accumulation code for TPUs and a TensorFlow implementation of CurricularFace. I hope you will find them useful as well.",
      "votes": null
    },
    {
      "id": "1531801",
      "postDate": "10/02/2021 11:41:04",
      "content": "<p>Congrats! </p>\n<p>One question, the imgs size that you share with us is the train one or the inference one?</p>\n<p>Thx</p>",
      "rawMarkdown": "Congrats! \n\nOne question, the imgs size that you share with us is the train one or the inference one?\n\nThx",
      "votes": null
    },
    {
      "id": "1531815",
      "postDate": "10/02/2021 12:02:13",
      "content": "<p>Thanks, Enric!<br>\nImg sizes mentioned above are the train img sizes. During inference, like my last time <a href=\"https://www.kaggle.com/prateekagnihotri/change-image-size-to-get-0-281-lb\" target=\"_blank\">solution</a>, I did inference at train time img size x sqrt ( 2 )</p>",
      "rawMarkdown": "Thanks, Enric!\nImg sizes mentioned above are the train img sizes. During inference, like my last time [solution](https://www.kaggle.com/prateekagnihotri/change-image-size-to-get-0-281-lb), I did inference at train time img size x sqrt ( 2 )",
      "votes": null
    },
    {
      "id": "1531993",
      "postDate": "10/02/2021 14:17:50",
      "content": "<p>Thanks for sharing this <a href=\"https://www.kaggle.com/prateekagnihotri\" target=\"_blank\">@prateekagnihotri</a> … really insightful especially the post processing bit … and congratulations on you solo silver on both the competitions 👏👏</p>",
      "rawMarkdown": "Thanks for sharing this @prateekagnihotri ... really insightful especially the post processing bit ... and congratulations on you solo silver on both the competitions 👏👏",
      "votes": null
    },
    {
      "id": "1532038",
      "postDate": "10/02/2021 15:02:48",
      "content": "<p>I am happy that you find it insightful. But it is more painful not to win gold in any😉. Anyway, you have to do everything you can and have to be fortunate. I am doing my part. I hope fortune will smile.</p>",
      "rawMarkdown": "I am happy that you find it insightful. But it is more painful not to win gold in any😉. Anyway, you have to do everything you can and have to be fortunate. I am doing my part. I hope fortune will smile.",
      "votes": null
    },
    {
      "id": "1532232",
      "postDate": "10/02/2021 18:30:39",
      "content": "<p>Congrats  <a href=\"https://www.kaggle.com/prateekagnihotri\" target=\"_blank\">@prateekagnihotri</a> , awesome result!</p>",
      "rawMarkdown": "Congrats  @prateekagnihotri , awesome result!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 1531801,
      "author_name": "enric1296",
      "author_url": "",
      "post_date": "10/02/2021 11:41:04",
      "content": "<p>Congrats! </p>\n<p>One question, the imgs size that you share with us is the train one or the inference one?</p>\n<p>Thx</p>",
      "votes": null,
      "replies": [
        {
          "id": 1531815,
          "author_name": "prateekagnihotri",
          "author_url": "",
          "post_date": "10/02/2021 12:02:13",
          "content": "<p>Thanks, Enric!<br>\nImg sizes mentioned above are the train img sizes. During inference, like my last time <a href=\"https://www.kaggle.com/prateekagnihotri/change-image-size-to-get-0-281-lb\" target=\"_blank\">solution</a>, I did inference at train time img size x sqrt ( 2 )</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1531993,
      "author_name": "sandy1112",
      "author_url": "",
      "post_date": "10/02/2021 14:17:50",
      "content": "<p>Thanks for sharing this <a href=\"https://www.kaggle.com/prateekagnihotri\" target=\"_blank\">@prateekagnihotri</a> … really insightful especially the post processing bit … and congratulations on you solo silver on both the competitions 👏👏</p>",
      "votes": null,
      "replies": [
        {
          "id": 1532038,
          "author_name": "prateekagnihotri",
          "author_url": "",
          "post_date": "10/02/2021 15:02:48",
          "content": "<p>I am happy that you find it insightful. But it is more painful not to win gold in any😉. Anyway, you have to do everything you can and have to be fortunate. I am doing my part. I hope fortune will smile.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 1532232,
      "author_name": "saurabhbagchi",
      "author_url": "",
      "post_date": "10/02/2021 18:30:39",
      "content": "<p>Congrats  <a href=\"https://www.kaggle.com/prateekagnihotri\" target=\"_blank\">@prateekagnihotri</a> , awesome result!</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "1531720": "Thanks to google and kaggle for hosting this competition and clairvoyant.ai for supporting this work. It was a lot of fun and a full of learning experience.\n\nCertainly, due to limited hardware, extremely large dataset, and time constraints, my models are not that powerful like top teams, but I would love to discuss post-processing, which uses soft landmark id assignment for index and test images, and gave **+0.075** boost on private LB.\n\nBut before, to give a glimpse of models.\n\n## Models\nI was using CurricularFace loss along with Adam Optimizer and Gradient Accumulation to train my models. I was using an ensemble of 5 models. All models were trained on the full GLDV2 dataset.\n\nTheir scores without any post-processing and using simple KNN on model embeddings are - \n| Model | Image Size | Public LB | Private LB |\n| --- | --- |\n| Effnet B4 | 512 | 0.322 | 0.342 |\n| Effnet B6 | 384 | 0.331 | 0.349 |\n| Effnet v2 - s | 512 | 0.325 | 0.351 |\n| Effnet v2 - m | 384 | 0.357 | 0.373 |\n| Effnet v2 - xl | 256 | 0.318 | 0.319 |\n| Concat all embbedings |  | 0.379 | 0.389 |\n| Concat all + Post Processing |  | 0.448 | 0.464 |\n\n## Post-Processing\n###Soft Landmark ID assignment\n**Step 1:** Landmark assignment - Test Images\n\nFor the landmark id assignment, I calculated the cosine similarity between the test image embeddings and the embeddings of images in the GLDV2 dataset. Next, I picked the top 'n' most similar GLDV2 images for every image in test data and assigned labels and label similarity scores to that image. An example label and label score calculation for an image A in test data is mentioned below.\n\nFor a test image A, pick the top  'n' (in my case, it was 5) most similar images from GLDV2-\n|  | GLDV2 Img 1 | GLDV2 Img 2 | GLDV2 Img 3 | GLDV2 Img 4 | GLDV2 Img 5 |\n| --- | --- |\n| Landmark ID | 121 | 10 | 121 | 10 | 199 |\n| Similarity Score | 0.9 | 0.7 | 0.5 | 0.47 | 0.45 |\n\nThen Image Landmark ID score can be calculated as\n| Landmark ID | Images | Landmark ID score |\n| --- | --- |\n| 121 | GLDV2 Img 1, GLDV2 Img 3 | 0.9+0.5 = 1.4 |\n| 10 | GLDV2 Img 2, GLDV2 Img 3 | 0.7+0.47 = 1.17 |\n| 199 | GLDV2 Img 5 | 0.45 |\n\nConsider landmark id score as zero for landmark ids that are not there in the top 5.\n\n**Step 2:** Landmark assignment - Index Images\n\nA similar procedure was followed for index images, and landmark ids and landmark id scores were assigned to them as well.\n\n**Step 3:** Test-Index similarity score calculation\n\nFinally, calculated similarity between Image A from test and Image B from Index as - \n\nSimilarity (A, B) = Landmark_ID_1_score(A) x Landmark_ID_1_score(B) +\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_2_score(A) x Landmark_ID_2_score(B) +\n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Landmark_ID_3_score(A) x Landmark_ID_3_score(B) + \n &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...........\n\nThen for every image in test data, arrange all similar images from index data in descending order based on their similarity score.\n\nAs the next step, At the end of this list, I concatenated the knn-neighbours not found in the above search.\n\nThis post-processing gave about +0.069 boost on public LB and +0.075 on private LB, with 0.448 and 0.464 as final Public and Private scores.\n\n## Additional\nAdditionally, I am [attaching](https://www.kaggle.com/prateekagnihotri/curricularface-and-gradient-accumulation) my gradient accumulation code for TPUs and a TensorFlow implementation of CurricularFace. I hope you will find them useful as well.",
    "1531801": "Congrats! \n\nOne question, the imgs size that you share with us is the train one or the inference one?\n\nThx",
    "1531815": "Thanks, Enric!\nImg sizes mentioned above are the train img sizes. During inference, like my last time [solution](https://www.kaggle.com/prateekagnihotri/change-image-size-to-get-0-281-lb), I did inference at train time img size x sqrt ( 2 )",
    "1531993": "Thanks for sharing this @prateekagnihotri ... really insightful especially the post processing bit ... and congratulations on you solo silver on both the competitions 👏👏",
    "1532038": "I am happy that you find it insightful. But it is more painful not to win gold in any😉. Anyway, you have to do everything you can and have to be fortunate. I am doing my part. I hope fortune will smile.",
    "1532232": "Congrats  @prateekagnihotri , awesome result!"
  },
  "source": "meta"
}