{
  "id": 359525,
  "title": "[2nd place] Solution",
  "content": "<p>Firstly, many thanks to <a href=\"https://www.kaggle.com/andrefaraujo\" target=\"_blank\">@andrefaraujo</a> for hosting such an interesting competition. And I'm glad that I moved from 3rd to 2nd place final in this competition.( sixsixsix scored higher than me actually!). I will introduce my approach in shot.</p>\n<p><a href=\"https://www.kaggle.com/code/w3579628328/2nd-place-solution?scriptVersionId=107642661\" target=\"_blank\">Inference Notebook</a></p>\n<h4>Dataset</h4>\n<ul>\n<li>Aliproducts</li>\n<li>Art_MET</li>\n<li>DeepFashion(Consumer-to-shop)</li>\n<li>DeepFashion2(hard-triplets)</li>\n<li>Fashion200K</li>\n<li>ICCV 2021 LargeFineFoodAI</li>\n<li>Food Recognition 2022</li>\n<li>JD_Products_10K</li>\n<li>Landmark2021</li>\n<li>Grocery Store</li>\n<li>rp2k</li>\n<li>Shopee</li>\n<li>Stanford_Cars</li>\n<li>Stanford_Products</li>\n</ul>\n<p>I've used a large amount of data, but didn't do much selection.</p>\n<h4>Model</h4>\n<ul>\n<li>open_clip_torch: Vit-H14-224-visual as backbone</li>\n<li>fc with dropout rate=0.2 as neck</li>\n<li>arcface head.</li>\n<li>Freeze backbone to finetune get me 0.662+-, flip boost it to 0.666.</li>\n</ul>\n<h4>Idea</h4>\n<ul>\n<li>Data Sampling: Set maxnum_images_perclass=100, minnum_images_perclass=3.</li>\n<li>Data Resampling: Do lightly resampling to balance class weight, set a minnum_images_perclass=20.</li>\n<li>Dynamic Margin (0.666-&gt;0.670): From the 1st solution of shopee competition. Set init m=0.1, then m= m+0.1 *(cur_ep-1), max_m = 0.8.</li>\n<li>stratified lr(0.670-&gt;0.713): This is a huge leap in my experiments. To remain the representation ability of the pretrained  model, I set the init_lr to 1e-4, which is the lr for the none-backbone parts, and the lr for the backbone is <strong>init_lr*lr_factor</strong>(lr_factor is reasonably low), the experiments was still on the half way when competition ended. Anyway, <strong>lr_factor=0.001</strong> is kind of a nice one, which gives me a score of 0.713 finally.(finetune with lr_factor=0.001 for 2epochs, then freeze backbone to finetune for another 1 epoch, do flipping finally.)</li>\n</ul>\n<h4>Conclusion</h4>\n<p>To do experiments more efficiently, I just sampled about 1M data for training in the early stage. during the journey to 0.670, I’ve tried many different architectures, more complex neck, sub-center arcface head(works well in open/clip_L_336), backbone ensemble, etc., but the scores just moved slowly. So I thought 0.670 is kind of a bottleneck for me, freezing backbone, keeping my eyes on the none-backbone parts. Then I decided to turn to the backbone after having done every experiments I thought I should do, even I once failed(I tried unfreezing backbone and finetune simply, the score just drop down rapidly). After thinking kind of deeply of how the backbone works, and also with luck, I succeeded in my first experiment, got a score of 0.688. I've just tried 3 different lr_factor due to time limitation, it took me about 12h+ to train one epoch. Performance: 0.001(0.707)&gt;0.005(0.700)&gt;0.01.</p>\n<p>Here I didn't do much explanation of why I did so, and there are some other interesting experiments I've done, maybe will even get a higher score. I'll include all these in paper, you are welcome to check out the fully solution if you are interested!🤗</p>\n<p>It's my first time to step into finegrained Image world, which is really interesting! I've learned a lot from this competition, and also have some further understanding on this kind of task.<br>\nFinally, thanks to everyone that contribute to this competition!</p>\n<p>Code:<br>\n<a href=\"https://github.com/XL-H/GUIE-2nd-Place-Solution\" target=\"_blank\">https://github.com/XL-H/GUIE-2nd-Place-Solution</a></p>\n<p>Paper:<br>\n<a href=\"https://arxiv.org/abs/2210.08735\" target=\"_blank\">https://arxiv.org/abs/2210.08735</a></p>",
  "comments": [
    {
      "id": 1986020,
      "author_name": "Man of the year",
      "author_url": "",
      "post_date": "2022-10-13T18:46:54.953000",
      "content": "<p>I didn't really get the stratified lr part. Could you please describe again it? Do you use different lr for the backbone and for the head parts of the model? And are they both unfrozen for the first 2 epochs?</p>\n<p>The solution is great actually.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1986290,
          "author_name": "Xiao",
          "author_url": "",
          "post_date": "2022-10-14T01:52:38.087000",
          "content": "<p>Yes, all components are unfrozen when using stratified lr for training. And it’s efficient, both backbone and non-backbone parts are conversing in a appropriate learning rate.</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 1984752,
      "author_name": "Wenxuan Ye",
      "author_url": "",
      "post_date": "2022-10-12T20:42:07.937000",
      "content": "<p>Do you try to use \"model soups\" to build an ensemble model as 4th solution players did? </p>",
      "votes": 0,
      "replies": [
        {
          "id": 1984987,
          "author_name": "Xiao",
          "author_url": "",
          "post_date": "2022-10-13T03:02:53.357000",
          "content": "<p>I didn’t do so. I was busy testing lr_factor, but didn’t find the optimal one still😅. This is an nice idea to avoid overfitting, worth trying!</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1984301,
      "author_name": "Wenxuan Ye",
      "author_url": "",
      "post_date": "2022-10-12T15:40:07.527000",
      "content": "<p>How many epochs did you set to train the model? You said each epoch took 12h+.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 1984328,
          "author_name": "Xiao",
          "author_url": "",
          "post_date": "2022-10-12T15:53:20.850000",
          "content": "<p>To achieve 0.707, only 2 epochs are needed, it's efficient. It's also based on your data scale, after preprocessing, I have about 7M data.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 1984582,
          "author_name": "Wenxuan Ye",
          "author_url": "",
          "post_date": "2022-10-12T18:22:08.233000",
          "content": "<p>Thanks, I would like to reproduce your idea by using smaller datasets. <br>\n给大佬递🍵</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 1984190,
      "author_name": "Starry",
      "author_url": "",
      "post_date": "2022-10-12T14:00:57.637000",
      "content": "<p>Congrats! I used very similar training strategy with you, set low lr on backbone while large lr on non-backbone parts and it works well. <br>\nMay I know how many GPUs you used? I just rent one single 3090 GPU (spend much money on this competition😂)   and it takes long time to train the model. </p>",
      "votes": 0,
      "replies": [
        {
          "id": 1984200,
          "author_name": "Xiao",
          "author_url": "",
          "post_date": "2022-10-12T14:05:18",
          "content": "<p>6*A40(Your message must have at least 10 characters.)</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "comment_count": 9,
  "messages": [
    {
      "id": 1984070,
      "postDate": "2022-10-12T12:52:56.533Z",
      "content": "<p>Firstly, many thanks to <a href=\"https://www.kaggle.com/andrefaraujo\" target=\"_blank\">@andrefaraujo</a> for hosting such an interesting competition. And I'm glad that I moved from 3rd to 2nd place final in this competition.( sixsixsix scored higher than me actually!). I will introduce my approach in shot.</p>\n<p><a href=\"https://www.kaggle.com/code/w3579628328/2nd-place-solution?scriptVersionId=107642661\" target=\"_blank\">Inference Notebook</a></p>\n<h4>Dataset</h4>\n<ul>\n<li>Aliproducts</li>\n<li>Art_MET</li>\n<li>DeepFashion(Consumer-to-shop)</li>\n<li>DeepFashion2(hard-triplets)</li>\n<li>Fashion200K</li>\n<li>ICCV 2021 LargeFineFoodAI</li>\n<li>Food Recognition 2022</li>\n<li>JD_Products_10K</li>\n<li>Landmark2021</li>\n<li>Grocery Store</li>\n<li>rp2k</li>\n<li>Shopee</li>\n<li>Stanford_Cars</li>\n<li>Stanford_Products</li>\n</ul>\n<p>I've used a large amount of data, but didn't do much selection.</p>\n<h4>Model</h4>\n<ul>\n<li>open_clip_torch: Vit-H14-224-visual as backbone</li>\n<li>fc with dropout rate=0.2 as neck</li>\n<li>arcface head.</li>\n<li>Freeze backbone to finetune get me 0.662+-, flip boost it to 0.666.</li>\n</ul>\n<h4>Idea</h4>\n<ul>\n<li>Data Sampling: Set maxnum_images_perclass=100, minnum_images_perclass=3.</li>\n<li>Data Resampling: Do lightly resampling to balance class weight, set a minnum_images_perclass=20.</li>\n<li>Dynamic Margin (0.666-&gt;0.670): From the 1st solution of shopee competition. Set init m=0.1, then m= m+0.1 *(cur_ep-1), max_m = 0.8.</li>\n<li>stratified lr(0.670-&gt;0.713): This is a huge leap in my experiments. To remain the representation ability of the pretrained  model, I set the init_lr to 1e-4, which is the lr for the none-backbone parts, and the lr for the backbone is <strong>init_lr*lr_factor</strong>(lr_factor is reasonably low), the experiments was still on the half way when competition ended. Anyway, <strong>lr_factor=0.001</strong> is kind of a nice one, which gives me a score of 0.713 finally.(finetune with lr_factor=0.001 for 2epochs, then freeze backbone to finetune for another 1 epoch, do flipping finally.)</li>\n</ul>\n<h4>Conclusion</h4>\n<p>To do experiments more efficiently, I just sampled about 1M data for training in the early stage. during the journey to 0.670, I’ve tried many different architectures, more complex neck, sub-center arcface head(works well in open/clip_L_336), backbone ensemble, etc., but the scores just moved slowly. So I thought 0.670 is kind of a bottleneck for me, freezing backbone, keeping my eyes on the none-backbone parts. Then I decided to turn to the backbone after having done every experiments I thought I should do, even I once failed(I tried unfreezing backbone and finetune simply, the score just drop down rapidly). After thinking kind of deeply of how the backbone works, and also with luck, I succeeded in my first experiment, got a score of 0.688. I've just tried 3 different lr_factor due to time limitation, it took me about 12h+ to train one epoch. Performance: 0.001(0.707)&gt;0.005(0.700)&gt;0.01.</p>\n<p>Here I didn't do much explanation of why I did so, and there are some other interesting experiments I've done, maybe will even get a higher score. I'll include all these in paper, you are welcome to check out the fully solution if you are interested!🤗</p>\n<p>It's my first time to step into finegrained Image world, which is really interesting! I've learned a lot from this competition, and also have some further understanding on this kind of task.<br>\nFinally, thanks to everyone that contribute to this competition!</p>\n<p>Code:<br>\n<a href=\"https://github.com/XL-H/GUIE-2nd-Place-Solution\" target=\"_blank\">https://github.com/XL-H/GUIE-2nd-Place-Solution</a></p>\n<p>Paper:<br>\n<a href=\"https://arxiv.org/abs/2210.08735\" target=\"_blank\">https://arxiv.org/abs/2210.08735</a></p>",
      "rawMarkdown": "Firstly, many thanks to @andrefaraujo for hosting such an interesting competition. And I'm glad that I moved from 3rd to 2nd place final in this competition.( sixsixsix scored higher than me actually!). I will introduce my approach in shot.\n\n[Inference Notebook](https://www.kaggle.com/code/w3579628328/2nd-place-solution?scriptVersionId=107642661)\n\n#### Dataset\n* Aliproducts\n* Art_MET\n* DeepFashion(Consumer-to-shop)\n* DeepFashion2(hard-triplets)\n* Fashion200K\n* ICCV 2021 LargeFineFoodAI\n* Food Recognition 2022\n* JD_Products_10K\n* Landmark2021\n* Grocery Store\n* rp2k\n* Shopee\n* Stanford_Cars\n* Stanford_Products\n\nI've used a large amount of data, but didn't do much selection.\n\n#### Model\n* open_clip_torch: Vit-H14-224-visual as backbone\n* fc with dropout rate=0.2 as neck\n* arcface head.\n* Freeze backbone to finetune get me 0.662+-, flip boost it to 0.666.\n\n#### Idea\n* Data Sampling: Set maxnum_images_perclass=100, minnum_images_perclass=3.\n* Data Resampling: Do lightly resampling to balance class weight, set a minnum_images_perclass=20.\n* Dynamic Margin (0.666->0.670): From the 1st solution of shopee competition. Set init m=0.1, then m= m+0.1 *(cur_ep-1), max_m = 0.8.\n* stratified lr(0.670->0.713): This is a huge leap in my experiments. To remain the representation ability of the pretrained  model, I set the init_lr to 1e-4, which is the lr for the none-backbone parts, and the lr for the backbone is **init_lr*lr_factor**(lr_factor is reasonably low), the experiments was still on the half way when competition ended. Anyway, **lr_factor=0.001** is kind of a nice one, which gives me a score of 0.713 finally.(finetune with lr_factor=0.001 for 2epochs, then freeze backbone to finetune for another 1 epoch, do flipping finally.)\n\n#### Conclusion\nTo do experiments more efficiently, I just sampled about 1M data for training in the early stage. during the journey to 0.670, I’ve tried many different architectures, more complex neck, sub-center arcface head(works well in open/clip_L_336), backbone ensemble, etc., but the scores just moved slowly. So I thought 0.670 is kind of a bottleneck for me, freezing backbone, keeping my eyes on the none-backbone parts. Then I decided to turn to the backbone after having done every experiments I thought I should do, even I once failed(I tried unfreezing backbone and finetune simply, the score just drop down rapidly). After thinking kind of deeply of how the backbone works, and also with luck, I succeeded in my first experiment, got a score of 0.688. I've just tried 3 different lr_factor due to time limitation, it took me about 12h+ to train one epoch. Performance: 0.001(0.707)>0.005(0.700)>0.01.\n\nHere I didn't do much explanation of why I did so, and there are some other interesting experiments I've done, maybe will even get a higher score. I'll include all these in paper, you are welcome to check out the fully solution if you are interested!🤗\n\nIt's my first time to step into finegrained Image world, which is really interesting! I've learned a lot from this competition, and also have some further understanding on this kind of task.\nFinally, thanks to everyone that contribute to this competition!\n\nCode:\nhttps://github.com/XL-H/GUIE-2nd-Place-Solution\n\nPaper:\nhttps://arxiv.org/abs/2210.08735",
      "votes": 26
    },
    {
      "id": 1986020,
      "postDate": "2022-10-13T18:46:54.953Z",
      "content": "<p>I didn't really get the stratified lr part. Could you please describe again it? Do you use different lr for the backbone and for the head parts of the model? And are they both unfrozen for the first 2 epochs?</p>\n<p>The solution is great actually.</p>",
      "rawMarkdown": "I didn't really get the stratified lr part. Could you please describe again it? Do you use different lr for the backbone and for the head parts of the model? And are they both unfrozen for the first 2 epochs?\n\nThe solution is great actually.",
      "replies": [
        {
          "id": 1986290,
          "postDate": "2022-10-14T01:52:38.087Z",
          "content": "<p>Yes, all components are unfrozen when using stratified lr for training. And it’s efficient, both backbone and non-backbone parts are conversing in a appropriate learning rate.</p>",
          "rawMarkdown": "Yes, all components are unfrozen when using stratified lr for training. And it’s efficient, both backbone and non-backbone parts are conversing in a appropriate learning rate.",
          "votes": 1
        }
      ]
    },
    {
      "id": 1984752,
      "postDate": "2022-10-12T20:42:07.937Z",
      "content": "<p>Do you try to use \"model soups\" to build an ensemble model as 4th solution players did? </p>",
      "rawMarkdown": "Do you try to use \"model soups\" to build an ensemble model as 4th solution players did? ",
      "replies": [
        {
          "id": 1984987,
          "postDate": "2022-10-13T03:02:53.357Z",
          "content": "<p>I didn’t do so. I was busy testing lr_factor, but didn’t find the optimal one still😅. This is an nice idea to avoid overfitting, worth trying!</p>",
          "rawMarkdown": "I didn’t do so. I was busy testing lr_factor, but didn’t find the optimal one still😅. This is an nice idea to avoid overfitting, worth trying!"
        }
      ]
    },
    {
      "id": 1984301,
      "postDate": "2022-10-12T15:40:07.527Z",
      "content": "<p>How many epochs did you set to train the model? You said each epoch took 12h+.</p>",
      "rawMarkdown": "How many epochs did you set to train the model? You said each epoch took 12h+.",
      "replies": [
        {
          "id": 1984328,
          "postDate": "2022-10-12T15:53:20.850Z",
          "content": "<p>To achieve 0.707, only 2 epochs are needed, it's efficient. It's also based on your data scale, after preprocessing, I have about 7M data.</p>",
          "rawMarkdown": "To achieve 0.707, only 2 epochs are needed, it's efficient. It's also based on your data scale, after preprocessing, I have about 7M data.",
          "votes": 1
        },
        {
          "id": 1984582,
          "postDate": "2022-10-12T18:22:08.233Z",
          "content": "<p>Thanks, I would like to reproduce your idea by using smaller datasets. <br>\n给大佬递🍵</p>",
          "rawMarkdown": "Thanks, I would like to reproduce your idea by using smaller datasets. \n给大佬递🍵"
        }
      ]
    },
    {
      "id": 1984190,
      "postDate": "2022-10-12T14:00:57.637Z",
      "content": "<p>Congrats! I used very similar training strategy with you, set low lr on backbone while large lr on non-backbone parts and it works well. <br>\nMay I know how many GPUs you used? I just rent one single 3090 GPU (spend much money on this competition😂)   and it takes long time to train the model. </p>",
      "rawMarkdown": "Congrats! I used very similar training strategy with you, set low lr on backbone while large lr on non-backbone parts and it works well. \nMay I know how many GPUs you used? I just rent one single 3090 GPU (spend much money on this competition😂)   and it takes long time to train the model. ",
      "replies": [
        {
          "id": 1984200,
          "postDate": "2022-10-12T14:05:18Z",
          "content": "<p>6*A40(Your message must have at least 10 characters.)</p>",
          "rawMarkdown": "6*A40(Your message must have at least 10 characters.)"
        }
      ]
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-24T13:24:32Z",
  "competition_id": 36414,
  "competition_slug": "google-universal-image-embedding",
  "team_id": 8897554,
  "solution_url": "/competitions/google-universal-image-embedding/writeups/xiao-2nd-place-solution"
}