{
  "id": 679362,
  "title": "Median Filter ×7 Is REALLY All You Need (Private Score: 0.614 -> 0.628)",
  "url": "/competitions/vesuvius-challenge-surface-detection/discussion/679362",
  "author_name": "",
  "post_date": "2026-02-28T23:22:22.090703300Z",
  "votes": 14,
  "comment_count": 15,
  "views": 0,
  "content": "<p>I tried incorporating the post-processing step “median filter ×7” described in <a href=\"https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s\" target=\"_blank\">the 18th place solution</a> into my best submission, and my private score improved significantly from 0.614 to 0.628!\nPlease give it a try as well and share your results!</p>\n<p>[<a href=\"https://www.kaggle.com/code/ren4yu/vesuvius-nnunet-ensemble-rot90\" target=\"_blank\">Before</a>] [<a href=\"https://www.kaggle.com/code/ren4yu/fork-of-vesuvius-nnunet-ensemble-rot90?scriptVersionId=300587212\" target=\"_blank\">After</a>]</p>",
  "messages": [
    {
      "id": "3415439",
      "postDate": "02/28/2026 23:22:22",
      "content": "<p>I tried incorporating the post-processing step “median filter ×7” described in <a href=\"https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s\" target=\"_blank\">the 18th place solution</a> into my best submission, and my private score improved significantly from 0.614 to 0.628!\nPlease give it a try as well and share your results!</p>\n<p>[<a href=\"https://www.kaggle.com/code/ren4yu/vesuvius-nnunet-ensemble-rot90\" target=\"_blank\">Before</a>] [<a href=\"https://www.kaggle.com/code/ren4yu/fork-of-vesuvius-nnunet-ensemble-rot90?scriptVersionId=300587212\" target=\"_blank\">After</a>]</p>",
      "rawMarkdown": "I tried incorporating the post-processing step “median filter ×7” described in [the 18th place solution](https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s) into my best submission, and my private score improved significantly from 0.614 to 0.628!\nPlease give it a try as well and share your results!\n\n[[Before](https://www.kaggle.com/code/ren4yu/vesuvius-nnunet-ensemble-rot90)] [[After](https://www.kaggle.com/code/ren4yu/fork-of-vesuvius-nnunet-ensemble-rot90?scriptVersionId=300587212)]",
      "votes": null
    },
    {
      "id": "3415445",
      "postDate": "02/28/2026 23:30:05",
      "content": "<p>Wow, that is incredible. Can you describe this technique specifically? Do you infer many models and then take the median prediction? </p>",
      "rawMarkdown": "Wow, that is incredible. Can you describe this technique specifically? Do you infer many models and then take the median prediction?",
      "votes": null
    },
    {
      "id": "3415452",
      "postDate": "02/28/2026 23:48:43",
      "content": "<p>Hi yu4u!</p>\n<p>Thanks for giving it a try — I'm happy to hear it’s been helpful for others too.</p>\n<p>I left a comment about the technique:\n<a href=\"https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s#3415448\" target=\"_blank\">https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s#3415448</a></p>\n<p>Everyone, give it a try! Just insert 7 lines!!!</p>\n<pre><code>from scipy.ndimage import median_filter  \ndef postprocess(mask: np.ndarray) -&gt; np.ndarray:\n     mask = mask.copy() \n     for _ in range(7):\n         mask = (median_filter(mask, size=3) &gt; 0).astype(np.uint8) \nreturn mask.astype(np.uint8)\n\nmask = postprocess(mask.astype(np.uint8))\n</code></pre>",
      "rawMarkdown": "Hi yu4u!\n\nThanks for giving it a try — I'm happy to hear it’s been helpful for others too.\n\nI left a comment about the technique:\nhttps://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s#3415448\n\nEveryone, give it a try! Just insert 7 lines!!!\n\n```python\nfrom scipy.ndimage import median_filter  \ndef postprocess(mask: np.ndarray) -> np.ndarray:\n     mask = mask.copy() \n     for _ in range(7):\n         mask = (median_filter(mask, size=3) > 0).astype(np.uint8) \nreturn mask.astype(np.uint8)\n\nmask = postprocess(mask.astype(np.uint8))\n```",
      "votes": null
    },
    {
      "id": "3415492",
      "postDate": "03/01/2026 00:31:40",
      "content": "<p>In our solution, one crucial trick is applying a uniform filter on the hard mask before feeding into shape warping step. I highly doubt using yours is much better.</p>",
      "rawMarkdown": "In our solution, one crucial trick is applying a uniform filter on the hard mask before feeding into shape warping step. I highly doubt using yours is much better.",
      "votes": null
    },
    {
      "id": "3415496",
      "postDate": "03/01/2026 00:38:04",
      "content": "<p>In my case, ensemble -&gt; binarization -&gt; median filter -&gt; remove small objects.\nAs <a href=\"https://www.kaggle.com/sugupoko\" target=\"_blank\">@sugupoko</a> mentioned in the comment, this approach is not about taking the median across multiple inference outputs; instead, it applies a spatial median filter seven times.</p>",
      "rawMarkdown": "In my case, ensemble -> binarization -> median filter -> remove small objects.\nAs @sugupoko mentioned in the comment, this approach is not about taking the median across multiple inference outputs; instead, it applies a spatial median filter seven times.",
      "votes": null
    },
    {
      "id": "3415598",
      "postDate": "03/01/2026 03:09:26",
      "content": "<p>We previously tried the Median Filter, but the Gaussian filter yielded better results, suppressing b1 more effectively.</p>",
      "rawMarkdown": "We previously tried the Median Filter, but the Gaussian filter yielded better results, suppressing b1 more effectively.",
      "votes": null
    },
    {
      "id": "3415606",
      "postDate": "03/01/2026 03:26:34",
      "content": "<p>After reading your solution, I also wanted to try a Gaussian filter.\nIf you’ve tested it, could you share whether applying it before or after binarization gave a better score, and how the score changed with different sigma values?</p>\n<blockquote>\n  <p>Apply a Gaussian filter (sigma=1) to the boolean mask, then threshold back to bool via &gt; 0.5. This trick turned out to be surprisingly effective, though the exact mechanism is not entirely clear.</p>\n</blockquote>",
      "rawMarkdown": "After reading your solution, I also wanted to try a Gaussian filter.\nIf you’ve tested it, could you share whether applying it before or after binarization gave a better score, and how the score changed with different sigma values?\n\n> Apply a Gaussian filter (sigma=1) to the boolean mask, then threshold back to bool via > 0.5. This trick turned out to be surprisingly effective, though the exact mechanism is not entirely clear.",
      "votes": null
    },
    {
      "id": "3415609",
      "postDate": "03/01/2026 03:29:55",
      "content": "<p>The sigma value has a significant impact; we keep it at 1.0.</p>",
      "rawMarkdown": "The sigma value has a significant impact; we keep it at 1.0.",
      "votes": null
    },
    {
      "id": "3415695",
      "postDate": "03/01/2026 06:52:47",
      "content": "<p>It is applied after binarization .</p>",
      "rawMarkdown": "It is applied after binarization .",
      "votes": null
    },
    {
      "id": "3415696",
      "postDate": "03/01/2026 06:53:47",
      "content": "<p>A sigma value of 1.0 is optimal; increasing or decreasing it will lower the score.</p>",
      "rawMarkdown": "A sigma value of 1.0 is optimal; increasing or decreasing it will lower the score.",
      "votes": null
    },
    {
      "id": "3416046",
      "postDate": "03/01/2026 23:49:29",
      "content": "<p>In my case, the median filter seems to work better.</p>\n<table>\n<thead>\n<tr>\n<th>Filter</th>\n<th>Setting</th>\n<th>Timing</th>\n<th>Score</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Baseline</td>\n<td></td>\n<td></td>\n<td>0.614</td>\n</tr>\n<tr>\n<td>Median Filter</td>\n<td>×6</td>\n<td>after binarization</td>\n<td><strong>0.628</strong></td>\n</tr>\n<tr>\n<td>Median Filter</td>\n<td>×7</td>\n<td>after binarization</td>\n<td><strong>0.628</strong></td>\n</tr>\n<tr>\n<td>Median Filter</td>\n<td>×8</td>\n<td>after binarization</td>\n<td>0.626</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 1.0</td>\n<td>after binarization</td>\n<td>0.618</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 3.0</td>\n<td>after binarization</td>\n<td>0.321</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 1.0</td>\n<td>before binarization</td>\n<td>0.596</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 3.0</td>\n<td>before binarization</td>\n<td>0.207</td>\n</tr>\n</tbody>\n</table>",
      "rawMarkdown": "In my case, the median filter seems to work better.\n\n| Filter          |     Setting | Timing              | Score |\n| --------------- | ----------: | ------------------- | ----: |\n| Baseline   |           |   | 0.614 |\n| Median Filter   |          ×6 | after binarization  | **0.628** |\n| Median Filter   |          ×7 | after binarization  | **0.628** |\n| Median Filter   |          ×8 | after binarization  | 0.626 |\n| Gaussian Filter | sigma = 1.0 | after binarization  | 0.618 |\n| Gaussian Filter | sigma = 3.0 | after binarization  | 0.321 |\n| Gaussian Filter | sigma = 1.0 | before binarization | 0.596 |\n| Gaussian Filter | sigma = 3.0 | before binarization | 0.207 |",
      "votes": null
    },
    {
      "id": "3416072",
      "postDate": "03/02/2026 02:19:58",
      "content": "<p>Thanks for experimenting.</p>\n<p>I’m curious why it has such a positive effect on metric.\nWhen you repeat it multiple times, it becomes smoother, masks start to connect, and then sometimes they separate…</p>",
      "rawMarkdown": "Thanks for experimenting.\n\nI’m curious why it has such a positive effect on metric.\nWhen you repeat it multiple times, it becomes smoother, masks start to connect, and then sometimes they separate…",
      "votes": null
    },
    {
      "id": "3416116",
      "postDate": "03/02/2026 05:24:27",
      "content": "<p>Hi, <a href=\"https://www.kaggle.com/sugupoko\" target=\"_blank\">@sugupoko</a>, here are  my partial results, I'll release more.<br>\nFor some reason, converting the model to TensorRT also yields better results. We observe simultaneous improvements in both CV, LB and PB scores. Additionally, we notice that some blurred edges are introduced after converting to TensorRT. This might contributes some digits to topo and voi</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>LB</th>\n<th>PB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>5-stage + remove small object (baseline)</td>\n<td>0.592</td>\n<td>0.614</td>\n</tr>\n<tr>\n<td>6-stage + remove small object (baseline)</td>\n<td>0.588</td>\n<td>0.615</td>\n</tr>\n<tr>\n<td>6-stage + 7x median filter + remove small object</td>\n<td>0.593</td>\n<td>0.618</td>\n</tr>\n<tr>\n<td>5-stage + 6x median filter + remove small object</td>\n<td>0.597</td>\n<td>0.623</td>\n</tr>\n<tr>\n<td>5-stage + 7x median filter + remove small object</td>\n<td>0.596</td>\n<td>0.623</td>\n</tr>\n<tr>\n<td>5-stage + 8x median filter + remove small object</td>\n<td>0.596</td>\n<td>0.624</td>\n</tr>\n</tbody>\n</table>",
      "rawMarkdown": "Hi, @sugupoko, here are  my partial results, I'll release more.  \nFor some reason, converting the model to TensorRT also yields better results. We observe simultaneous improvements in both CV, LB and PB scores. Additionally, we notice that some blurred edges are introduced after converting to TensorRT. This might contributes some digits to topo and voi\n\n|  | LB | PB |\n| --- | --- | --- |\n| 5-stage + remove small object (baseline) | 0.592 | 0.614 |\n| 6-stage + remove small object (baseline) | 0.588 | 0.615 |\n| 6-stage + 7x median filter + remove small object | 0.593 | 0.618 |\n| 5-stage + 6x median filter + remove small object | 0.597 | 0.623 |\n| 5-stage + 7x median filter + remove small object | 0.596 | 0.623 |\n| 5-stage + 8x median filter + remove small object | 0.596 | 0.624 |",
      "votes": null
    },
    {
      "id": "3416184",
      "postDate": "03/02/2026 08:43:10",
      "content": "<p>I also used Gausian filter with sigma 1. Very effective indeed.</p>",
      "rawMarkdown": "I also used Gausian filter with sigma 1. Very effective indeed.",
      "votes": null
    },
    {
      "id": "3416465",
      "postDate": "03/02/2026 23:47:58",
      "content": "<p>Also observe major topo cv boost\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4310004%2F0982f3f81e89ef6ab21b21999de40228%2Fimage.png?generation=1772495277298187&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Also observe major topo cv boost\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4310004%2F0982f3f81e89ef6ab21b21999de40228%2Fimage.png?generation=1772495277298187&alt=media)",
      "votes": null
    },
    {
      "id": "3416681",
      "postDate": "03/03/2026 13:44:48",
      "content": "<p>Thanks <a href=\"https://www.kaggle.com/tom99763\" target=\"_blank\">@tom99763</a> san.</p>\n<p>It’s a very interesting change!</p>",
      "rawMarkdown": "Thanks @tom99763 san.\n\nIt’s a very interesting change!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3415445,
      "author_name": "cdeotte",
      "author_url": "",
      "post_date": "02/28/2026 23:30:05",
      "content": "<p>Wow, that is incredible. Can you describe this technique specifically? Do you infer many models and then take the median prediction? </p>",
      "votes": null,
      "replies": [
        {
          "id": 3415496,
          "author_name": "ren4yu",
          "author_url": "",
          "post_date": "03/01/2026 00:38:04",
          "content": "<p>In my case, ensemble -&gt; binarization -&gt; median filter -&gt; remove small objects.\nAs <a href=\"https://www.kaggle.com/sugupoko\" target=\"_blank\">@sugupoko</a> mentioned in the comment, this approach is not about taking the median across multiple inference outputs; instead, it applies a spatial median filter seven times.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 3415452,
      "author_name": "sugupoko",
      "author_url": "",
      "post_date": "02/28/2026 23:48:43",
      "content": "<p>Hi yu4u!</p>\n<p>Thanks for giving it a try — I'm happy to hear it’s been helpful for others too.</p>\n<p>I left a comment about the technique:\n<a href=\"https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s#3415448\" target=\"_blank\">https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s#3415448</a></p>\n<p>Everyone, give it a try! Just insert 7 lines!!!</p>\n<pre><code>from scipy.ndimage import median_filter  \ndef postprocess(mask: np.ndarray) -&gt; np.ndarray:\n     mask = mask.copy() \n     for _ in range(7):\n         mask = (median_filter(mask, size=3) &gt; 0).astype(np.uint8) \nreturn mask.astype(np.uint8)\n\nmask = postprocess(mask.astype(np.uint8))\n</code></pre>",
      "votes": null,
      "replies": []
    },
    {
      "id": 3415492,
      "author_name": "tom99763",
      "author_url": "",
      "post_date": "03/01/2026 00:31:40",
      "content": "<p>In our solution, one crucial trick is applying a uniform filter on the hard mask before feeding into shape warping step. I highly doubt using yours is much better.</p>",
      "votes": null,
      "replies": []
    },
    {
      "id": 3415598,
      "author_name": "ggayoayogg",
      "author_url": "",
      "post_date": "03/01/2026 03:09:26",
      "content": "<p>We previously tried the Median Filter, but the Gaussian filter yielded better results, suppressing b1 more effectively.</p>",
      "votes": null,
      "replies": [
        {
          "id": 3415606,
          "author_name": "ren4yu",
          "author_url": "",
          "post_date": "03/01/2026 03:26:34",
          "content": "<p>After reading your solution, I also wanted to try a Gaussian filter.\nIf you’ve tested it, could you share whether applying it before or after binarization gave a better score, and how the score changed with different sigma values?</p>\n<blockquote>\n  <p>Apply a Gaussian filter (sigma=1) to the boolean mask, then threshold back to bool via &gt; 0.5. This trick turned out to be surprisingly effective, though the exact mechanism is not entirely clear.</p>\n</blockquote>",
          "votes": null,
          "replies": [
            {
              "id": 3415609,
              "author_name": "ggayoayogg",
              "author_url": "",
              "post_date": "03/01/2026 03:29:55",
              "content": "<p>The sigma value has a significant impact; we keep it at 1.0.</p>",
              "votes": null,
              "replies": []
            },
            {
              "id": 3415695,
              "author_name": "chengtingyi",
              "author_url": "",
              "post_date": "03/01/2026 06:52:47",
              "content": "<p>It is applied after binarization .</p>",
              "votes": null,
              "replies": []
            },
            {
              "id": 3415696,
              "author_name": "chengtingyi",
              "author_url": "",
              "post_date": "03/01/2026 06:53:47",
              "content": "<p>A sigma value of 1.0 is optimal; increasing or decreasing it will lower the score.</p>",
              "votes": null,
              "replies": []
            }
          ]
        },
        {
          "id": 3416184,
          "author_name": "cpmpml",
          "author_url": "",
          "post_date": "03/02/2026 08:43:10",
          "content": "<p>I also used Gausian filter with sigma 1. Very effective indeed.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 3416046,
      "author_name": "ren4yu",
      "author_url": "",
      "post_date": "03/01/2026 23:49:29",
      "content": "<p>In my case, the median filter seems to work better.</p>\n<table>\n<thead>\n<tr>\n<th>Filter</th>\n<th>Setting</th>\n<th>Timing</th>\n<th>Score</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Baseline</td>\n<td></td>\n<td></td>\n<td>0.614</td>\n</tr>\n<tr>\n<td>Median Filter</td>\n<td>×6</td>\n<td>after binarization</td>\n<td><strong>0.628</strong></td>\n</tr>\n<tr>\n<td>Median Filter</td>\n<td>×7</td>\n<td>after binarization</td>\n<td><strong>0.628</strong></td>\n</tr>\n<tr>\n<td>Median Filter</td>\n<td>×8</td>\n<td>after binarization</td>\n<td>0.626</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 1.0</td>\n<td>after binarization</td>\n<td>0.618</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 3.0</td>\n<td>after binarization</td>\n<td>0.321</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 1.0</td>\n<td>before binarization</td>\n<td>0.596</td>\n</tr>\n<tr>\n<td>Gaussian Filter</td>\n<td>sigma = 3.0</td>\n<td>before binarization</td>\n<td>0.207</td>\n</tr>\n</tbody>\n</table>",
      "votes": null,
      "replies": [
        {
          "id": 3416072,
          "author_name": "sugupoko",
          "author_url": "",
          "post_date": "03/02/2026 02:19:58",
          "content": "<p>Thanks for experimenting.</p>\n<p>I’m curious why it has such a positive effect on metric.\nWhen you repeat it multiple times, it becomes smoother, masks start to connect, and then sometimes they separate…</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 3416116,
      "author_name": "tom99763",
      "author_url": "",
      "post_date": "03/02/2026 05:24:27",
      "content": "<p>Hi, <a href=\"https://www.kaggle.com/sugupoko\" target=\"_blank\">@sugupoko</a>, here are  my partial results, I'll release more.<br>\nFor some reason, converting the model to TensorRT also yields better results. We observe simultaneous improvements in both CV, LB and PB scores. Additionally, we notice that some blurred edges are introduced after converting to TensorRT. This might contributes some digits to topo and voi</p>\n<table>\n<thead>\n<tr>\n<th></th>\n<th>LB</th>\n<th>PB</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>5-stage + remove small object (baseline)</td>\n<td>0.592</td>\n<td>0.614</td>\n</tr>\n<tr>\n<td>6-stage + remove small object (baseline)</td>\n<td>0.588</td>\n<td>0.615</td>\n</tr>\n<tr>\n<td>6-stage + 7x median filter + remove small object</td>\n<td>0.593</td>\n<td>0.618</td>\n</tr>\n<tr>\n<td>5-stage + 6x median filter + remove small object</td>\n<td>0.597</td>\n<td>0.623</td>\n</tr>\n<tr>\n<td>5-stage + 7x median filter + remove small object</td>\n<td>0.596</td>\n<td>0.623</td>\n</tr>\n<tr>\n<td>5-stage + 8x median filter + remove small object</td>\n<td>0.596</td>\n<td>0.624</td>\n</tr>\n</tbody>\n</table>",
      "votes": null,
      "replies": [
        {
          "id": 3416465,
          "author_name": "tom99763",
          "author_url": "",
          "post_date": "03/02/2026 23:47:58",
          "content": "<p>Also observe major topo cv boost\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4310004%2F0982f3f81e89ef6ab21b21999de40228%2Fimage.png?generation=1772495277298187&amp;alt=media\" alt=\"\"></p>",
          "votes": null,
          "replies": [
            {
              "id": 3416681,
              "author_name": "sugupoko",
              "author_url": "",
              "post_date": "03/03/2026 13:44:48",
              "content": "<p>Thanks <a href=\"https://www.kaggle.com/tom99763\" target=\"_blank\">@tom99763</a> san.</p>\n<p>It’s a very interesting change!</p>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "3415439": "I tried incorporating the post-processing step “median filter ×7” described in [the 18th place solution](https://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s) into my best submission, and my private score improved significantly from 0.614 to 0.628!\nPlease give it a try as well and share your results!\n\n[[Before](https://www.kaggle.com/code/ren4yu/vesuvius-nnunet-ensemble-rot90)] [[After](https://www.kaggle.com/code/ren4yu/fork-of-vesuvius-nnunet-ensemble-rot90?scriptVersionId=300587212)]",
    "3415445": "Wow, that is incredible. Can you describe this technique specifically? Do you infer many models and then take the median prediction?",
    "3415452": "Hi yu4u!\n\nThanks for giving it a try — I'm happy to hear it’s been helpful for others too.\n\nI left a comment about the technique:\nhttps://www.kaggle.com/competitions/vesuvius-challenge-surface-detection/writeups/18th-median-filter-x-7-post-processing-is-very-s#3415448\n\nEveryone, give it a try! Just insert 7 lines!!!\n\n```python\nfrom scipy.ndimage import median_filter  \ndef postprocess(mask: np.ndarray) -> np.ndarray:\n     mask = mask.copy() \n     for _ in range(7):\n         mask = (median_filter(mask, size=3) > 0).astype(np.uint8) \nreturn mask.astype(np.uint8)\n\nmask = postprocess(mask.astype(np.uint8))\n```",
    "3415492": "In our solution, one crucial trick is applying a uniform filter on the hard mask before feeding into shape warping step. I highly doubt using yours is much better.",
    "3415496": "In my case, ensemble -> binarization -> median filter -> remove small objects.\nAs @sugupoko mentioned in the comment, this approach is not about taking the median across multiple inference outputs; instead, it applies a spatial median filter seven times.",
    "3415598": "We previously tried the Median Filter, but the Gaussian filter yielded better results, suppressing b1 more effectively.",
    "3415606": "After reading your solution, I also wanted to try a Gaussian filter.\nIf you’ve tested it, could you share whether applying it before or after binarization gave a better score, and how the score changed with different sigma values?\n\n> Apply a Gaussian filter (sigma=1) to the boolean mask, then threshold back to bool via > 0.5. This trick turned out to be surprisingly effective, though the exact mechanism is not entirely clear.",
    "3415609": "The sigma value has a significant impact; we keep it at 1.0.",
    "3415695": "It is applied after binarization .",
    "3415696": "A sigma value of 1.0 is optimal; increasing or decreasing it will lower the score.",
    "3416046": "In my case, the median filter seems to work better.\n\n| Filter          |     Setting | Timing              | Score |\n| --------------- | ----------: | ------------------- | ----: |\n| Baseline   |           |   | 0.614 |\n| Median Filter   |          ×6 | after binarization  | **0.628** |\n| Median Filter   |          ×7 | after binarization  | **0.628** |\n| Median Filter   |          ×8 | after binarization  | 0.626 |\n| Gaussian Filter | sigma = 1.0 | after binarization  | 0.618 |\n| Gaussian Filter | sigma = 3.0 | after binarization  | 0.321 |\n| Gaussian Filter | sigma = 1.0 | before binarization | 0.596 |\n| Gaussian Filter | sigma = 3.0 | before binarization | 0.207 |",
    "3416072": "Thanks for experimenting.\n\nI’m curious why it has such a positive effect on metric.\nWhen you repeat it multiple times, it becomes smoother, masks start to connect, and then sometimes they separate…",
    "3416116": "Hi, @sugupoko, here are  my partial results, I'll release more.  \nFor some reason, converting the model to TensorRT also yields better results. We observe simultaneous improvements in both CV, LB and PB scores. Additionally, we notice that some blurred edges are introduced after converting to TensorRT. This might contributes some digits to topo and voi\n\n|  | LB | PB |\n| --- | --- | --- |\n| 5-stage + remove small object (baseline) | 0.592 | 0.614 |\n| 6-stage + remove small object (baseline) | 0.588 | 0.615 |\n| 6-stage + 7x median filter + remove small object | 0.593 | 0.618 |\n| 5-stage + 6x median filter + remove small object | 0.597 | 0.623 |\n| 5-stage + 7x median filter + remove small object | 0.596 | 0.623 |\n| 5-stage + 8x median filter + remove small object | 0.596 | 0.624 |",
    "3416184": "I also used Gausian filter with sigma 1. Very effective indeed.",
    "3416465": "Also observe major topo cv boost\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F4310004%2F0982f3f81e89ef6ab21b21999de40228%2Fimage.png?generation=1772495277298187&alt=media)",
    "3416681": "Thanks @tom99763 san.\n\nIt’s a very interesting change!"
  },
  "source": "meta"
}