{
  "id": 583133,
  "title": "369th place solution YOLO part with PB0.840 notebook",
  "url": "/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/583133",
  "author_name": "",
  "post_date": "2025-06-05T01:24:22.035173400Z",
  "votes": 37,
  "comment_count": 7,
  "views": 0,
  "content": "<p>Thanks to our hosts for organizing this competition. Our placing was poor, but I am happy to report that we scored reasonably well on the YOLO model.<br>\n※The team's highest score was PB 0.851</p>\n<h2>Making models</h2>\n<ul>\n<li><p>base model</p>\n<p>yolov8l, yolo11l  (yolov8 had a better LB score)</p></li>\n<li><p>original data</p>\n<p>competition data + external data(<a href=\"https://www.kaggle.com/datasets/brendanartley/cryoet-flagellar-motors-dataset\" target=\"_blank\">https://www.kaggle.com/datasets/brendanartley/cryoet-flagellar-motors-dataset</a>)</p></li>\n<li><p>making yolo dataset</p>\n<p>based on <strong>Parse Data notebook(</strong><a href=\"https://www.kaggle.com/code/andrewjdarley/parse-data\" target=\"_blank\">https://www.kaggle.com/code/andrewjdarley/parse-data</a>)</p>\n<p>I have devised the following points</p>\n<ul>\n<li>When creating training data, TRUST=8 for competition data and TRUST=2 for external data.</li>\n<li>When creating validation data, TRUST=4 for competition data sets only, not use external data.</li>\n<li>slice images are resized to 960x960 for uniformity</li>\n<li>vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data only</li>\n<li>BOX_SIZE is int(1000 / voxel_spacing) for competition data, 35 for external data.</li>\n<li>4-fold datasets</li></ul></li>\n<li><p>training</p>\n<p>based on Train Yolo <strong>notebook(</strong><a href=\"https://www.kaggle.com/code/andrewjdarley/train-yolo\" target=\"_blank\">https://www.kaggle.com/code/andrewjdarley/train-yolo</a>)</p>\n<p>I have changed the following points</p>\n<ul>\n<li>batch-size = 32, epoch=30, imgsz=960</li>\n<li>yolov8l:lr0=1e-4, lrf= yolo11l:lr0=0.001  cos_lr=True, etc</li>\n<li>save_period=1 and use best_dfl_loss-epoch model</li></ul></li>\n</ul>\n<h2>Inference</h2>\n<p>In  YOLO model, I have devised a calculation of the z-coordinate. In addition, I have tried to speed up the process.</p>\n<ul>\n<li><p>calculation of motor coordinates</p>\n<p>I used DFS(depth-first search). <br>\nThe x,y coordinates detected in yolo with the slice number as the z coordinate were grouped by DFS and the average value was taken. This idea originated from <a href=\"https://www.kaggle.com/itsuki9180\" target=\"_blank\">@itsuki9180</a> 's notebook in CZII (<a href=\"https://www.kaggle.com/code/itsuki9180/czii-yolo11-submission-baseline\" target=\"_blank\">https://www.kaggle.com/code/itsuki9180/czii-yolo11-submission-baseline</a>)</p></li>\n<li><p>speed up inference</p>\n<p>Submit time for public note takes 6.5h for one model. To improve the processing speed, the following efforts were made. This resulted in submit time of 1h40m for one model.</p>\n<ul>\n<li>tomo_id is divided into 4 groups and handled by 4 processes.</li>\n<li>2 processes share one T4-GPU</li>\n<li>In 1 porcess, read jpg files in a separate thread from yolo predictions</li>\n<li>yolo-predict in half-precision (FP16)</li></ul>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8234844%2F2975859e11f30ffc95edfba1e035bea5%2Fimage.png?generation=1749086495125297&amp;alt=media\" alt=\"\"></p></li>\n\n<li><p>yolo-models ensemble</p>\n<p>The yolo-models ensemble collects the per-slice detection coordinates across the entire models and processes them in DFS at once.</p></li>\n<li><p>slices-skip</p>\n<p>Even with the above multi-processing, it takes more than 6 hours to ensemble a 4-fold training model. The ensemble of the 4-fold model was reduced to 1h40m by reducing the number of slices in this <a href=\"https://www.kaggle.com/yyyy0201\" target=\"_blank\">@yyyy0201</a> discussion(<a href=\"https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/578461)\" target=\"_blank\">https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/578461)</a>.</p>\n<p>Prepare array of four randomly selected slices for every 4 slices and assign them to each 4-fold model.</p>\n<pre><code>    selected_indices = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n    selected_indices2 = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n    selected_indices3 = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n    selected_indices4 = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n</code></pre>\n<p>This resulted in a submission time of about 3hours for an ensemble of yolov8l and yolo11l 4-fold models (8models in total). and the PB score is LB0.840. this inference notebook is (<a href=\"https://www.kaggle.com/code/minfuka/byu-yolo-960-inference-fold4-slice-skip-random-v8l\" target=\"_blank\">https://www.kaggle.com/code/minfuka/byu-yolo-960-inference-fold4-slice-skip-random-v8l</a>)<br>\n(but, this notebook could be described more compactly)</p></li>\n</ul>\n<h2>Score Transition</h2>\n<p>LB Score Transition. This score is the score before it was recalculated(<a href=\"https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/574729)\" target=\"_blank\">https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/574729)</a>.</p>\n<p>All scores are using yolov8L and hold-out(8:2) dataset and best.pt.</p>\n<p>Initially I was submitting best.pt but changed to best_dfl_epoch.pt due to unstable best.pt scores.</p>\n<ul>\n<li>Change image size during training from 640 to 960 → LB 0.65</li>\n<li>Change from BS=16 to BS=32 → LB 0.699</li>\n<li>Increase target slice for data set creation in public notes to Train TRUST=8 Valid TRUST=4→ LB 0.76</li>\n<li>vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data → LB 0.80</li>\n<li>Use publicly available external data → LB0.825</li>\n</ul>\n<h2>What didn't work</h2>\n<ul>\n<li>TTA</li>\n<li>WBF</li>\n</ul>",
  "messages": [
    {
      "id": "3217392",
      "postDate": "06/05/2025 01:24:22",
      "content": "<p>Thanks to our hosts for organizing this competition. Our placing was poor, but I am happy to report that we scored reasonably well on the YOLO model.<br>\n※The team's highest score was PB 0.851</p>\n<h2>Making models</h2>\n<ul>\n<li><p>base model</p>\n<p>yolov8l, yolo11l  (yolov8 had a better LB score)</p></li>\n<li><p>original data</p>\n<p>competition data + external data(<a href=\"https://www.kaggle.com/datasets/brendanartley/cryoet-flagellar-motors-dataset\" target=\"_blank\">https://www.kaggle.com/datasets/brendanartley/cryoet-flagellar-motors-dataset</a>)</p></li>\n<li><p>making yolo dataset</p>\n<p>based on <strong>Parse Data notebook(</strong><a href=\"https://www.kaggle.com/code/andrewjdarley/parse-data\" target=\"_blank\">https://www.kaggle.com/code/andrewjdarley/parse-data</a>)</p>\n<p>I have devised the following points</p>\n<ul>\n<li>When creating training data, TRUST=8 for competition data and TRUST=2 for external data.</li>\n<li>When creating validation data, TRUST=4 for competition data sets only, not use external data.</li>\n<li>slice images are resized to 960x960 for uniformity</li>\n<li>vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data only</li>\n<li>BOX_SIZE is int(1000 / voxel_spacing) for competition data, 35 for external data.</li>\n<li>4-fold datasets</li></ul></li>\n<li><p>training</p>\n<p>based on Train Yolo <strong>notebook(</strong><a href=\"https://www.kaggle.com/code/andrewjdarley/train-yolo\" target=\"_blank\">https://www.kaggle.com/code/andrewjdarley/train-yolo</a>)</p>\n<p>I have changed the following points</p>\n<ul>\n<li>batch-size = 32, epoch=30, imgsz=960</li>\n<li>yolov8l:lr0=1e-4, lrf= yolo11l:lr0=0.001  cos_lr=True, etc</li>\n<li>save_period=1 and use best_dfl_loss-epoch model</li></ul></li>\n</ul>\n<h2>Inference</h2>\n<p>In  YOLO model, I have devised a calculation of the z-coordinate. In addition, I have tried to speed up the process.</p>\n<ul>\n<li><p>calculation of motor coordinates</p>\n<p>I used DFS(depth-first search). <br>\nThe x,y coordinates detected in yolo with the slice number as the z coordinate were grouped by DFS and the average value was taken. This idea originated from <a href=\"https://www.kaggle.com/itsuki9180\" target=\"_blank\">@itsuki9180</a> 's notebook in CZII (<a href=\"https://www.kaggle.com/code/itsuki9180/czii-yolo11-submission-baseline\" target=\"_blank\">https://www.kaggle.com/code/itsuki9180/czii-yolo11-submission-baseline</a>)</p></li>\n<li><p>speed up inference</p>\n<p>Submit time for public note takes 6.5h for one model. To improve the processing speed, the following efforts were made. This resulted in submit time of 1h40m for one model.</p>\n<ul>\n<li>tomo_id is divided into 4 groups and handled by 4 processes.</li>\n<li>2 processes share one T4-GPU</li>\n<li>In 1 porcess, read jpg files in a separate thread from yolo predictions</li>\n<li>yolo-predict in half-precision (FP16)</li></ul>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8234844%2F2975859e11f30ffc95edfba1e035bea5%2Fimage.png?generation=1749086495125297&amp;alt=media\" alt=\"\"></p></li>\n\n<li><p>yolo-models ensemble</p>\n<p>The yolo-models ensemble collects the per-slice detection coordinates across the entire models and processes them in DFS at once.</p></li>\n<li><p>slices-skip</p>\n<p>Even with the above multi-processing, it takes more than 6 hours to ensemble a 4-fold training model. The ensemble of the 4-fold model was reduced to 1h40m by reducing the number of slices in this <a href=\"https://www.kaggle.com/yyyy0201\" target=\"_blank\">@yyyy0201</a> discussion(<a href=\"https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/578461)\" target=\"_blank\">https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/578461)</a>.</p>\n<p>Prepare array of four randomly selected slices for every 4 slices and assign them to each 4-fold model.</p>\n<pre><code>    selected_indices = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n    selected_indices2 = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n    selected_indices3 = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n    selected_indices4 = [.choice(list((i, (i+, slen))))  iin (, slen, )]\n</code></pre>\n<p>This resulted in a submission time of about 3hours for an ensemble of yolov8l and yolo11l 4-fold models (8models in total). and the PB score is LB0.840. this inference notebook is (<a href=\"https://www.kaggle.com/code/minfuka/byu-yolo-960-inference-fold4-slice-skip-random-v8l\" target=\"_blank\">https://www.kaggle.com/code/minfuka/byu-yolo-960-inference-fold4-slice-skip-random-v8l</a>)<br>\n(but, this notebook could be described more compactly)</p></li>\n</ul>\n<h2>Score Transition</h2>\n<p>LB Score Transition. This score is the score before it was recalculated(<a href=\"https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/574729)\" target=\"_blank\">https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/574729)</a>.</p>\n<p>All scores are using yolov8L and hold-out(8:2) dataset and best.pt.</p>\n<p>Initially I was submitting best.pt but changed to best_dfl_epoch.pt due to unstable best.pt scores.</p>\n<ul>\n<li>Change image size during training from 640 to 960 → LB 0.65</li>\n<li>Change from BS=16 to BS=32 → LB 0.699</li>\n<li>Increase target slice for data set creation in public notes to Train TRUST=8 Valid TRUST=4→ LB 0.76</li>\n<li>vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data → LB 0.80</li>\n<li>Use publicly available external data → LB0.825</li>\n</ul>\n<h2>What didn't work</h2>\n<ul>\n<li>TTA</li>\n<li>WBF</li>\n</ul>",
      "rawMarkdown": "Thanks to our hosts for organizing this competition. Our placing was poor, but I am happy to report that we scored reasonably well on the YOLO model.\n※The team's highest score was PB 0.851\n\n## Making models\n\n- base model\n    \n     yolov8l, yolo11l  (yolov8 had a better LB score)\n    \n- original data\n    \n    competition data + external data(https://www.kaggle.com/datasets/brendanartley/cryoet-flagellar-motors-dataset)\n    \n- making yolo dataset\n    \n    based on **Parse Data notebook(**https://www.kaggle.com/code/andrewjdarley/parse-data)\n    \n    I have devised the following points\n    \n    - When creating training data, TRUST=8 for competition data and TRUST=2 for external data.\n    - When creating validation data, TRUST=4 for competition data sets only, not use external data.\n    - slice images are resized to 960x960 for uniformity\n    - vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data only\n    - BOX_SIZE is int(1000 / voxel_spacing) for competition data, 35 for external data.\n    - 4-fold datasets\n- training\n    \n    based on Train Yolo **notebook(**https://www.kaggle.com/code/andrewjdarley/train-yolo)\n    \n    I have changed the following points\n    \n    - batch-size = 32, epoch=30, imgsz=960\n    - yolov8l:lr0=1e-4, lrf= yolo11l:lr0=0.001  cos_lr=True, etc\n    - save_period=1 and use best_dfl_loss-epoch model\n\n## Inference\n\nIn  YOLO model, I have devised a calculation of the z-coordinate. In addition, I have tried to speed up the process.\n\n- calculation of motor coordinates\n    \n    I used DFS(depth-first search). \n    The x,y coordinates detected in yolo with the slice number as the z coordinate were grouped by DFS and the average value was taken. This idea originated from @itsuki9180 's notebook in CZII (https://www.kaggle.com/code/itsuki9180/czii-yolo11-submission-baseline)\n    \n- speed up inference\n    \n    Submit time for public note takes 6.5h for one model. To improve the processing speed, the following efforts were made. This resulted in submit time of 1h40m for one model.\n    \n    - tomo_id is divided into 4 groups and handled by 4 processes.\n    - 2 processes share one T4-GPU\n    - In 1 porcess, read jpg files in a separate thread from yolo predictions\n    - yolo-predict in half-precision (FP16)\n    \n    ![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8234844%2F2975859e11f30ffc95edfba1e035bea5%2Fimage.png?generation=1749086495125297&alt=media)\n    \n     \n    \n- yolo-models ensemble\n    \n    The yolo-models ensemble collects the per-slice detection coordinates across the entire models and processes them in DFS at once.\n    \n- slices-skip\n    \n    Even with the above multi-processing, it takes more than 6 hours to ensemble a 4-fold training model. The ensemble of the 4-fold model was reduced to 1h40m by reducing the number of slices in this @yyyy0201 discussion(https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/578461).\n    \n    Prepare array of four randomly selected slices for every 4 slices and assign them to each 4-fold model.\n    \n    ```\n        selected_indices = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n        selected_indices2 = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n        selected_indices3 = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n        selected_indices4 = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n    ```\n    \n     This resulted in a submission time of about 3hours for an ensemble of yolov8l and yolo11l 4-fold models (8models in total). and the PB score is LB0.840. this inference notebook is (https://www.kaggle.com/code/minfuka/byu-yolo-960-inference-fold4-slice-skip-random-v8l)\n    (but, this notebook could be described more compactly)\n\n    \n\n## Score Transition\n\nLB Score Transition. This score is the score before it was recalculated(https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/574729).\n\nAll scores are using yolov8L and hold-out(8:2) dataset and best.pt.\n\nInitially I was submitting best.pt but changed to best_dfl_epoch.pt due to unstable best.pt scores.\n\n- Change image size during training from 640 to 960 → LB 0.65\n- Change from BS=16 to BS=32 → LB 0.699\n- Increase target slice for data set creation in public notes to Train TRUST=8 Valid TRUST=4→ LB 0.76\n- vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data → LB 0.80\n- Use publicly available external data → LB0.825\n\n## What didn't work\n\n- TTA\n- WBF",
      "votes": null
    },
    {
      "id": "3217459",
      "postDate": "06/05/2025 03:17:29",
      "content": "<p>i tried trust = 6 with yolo 11m, my lb was not good. i think that is because i use batch size = 16 and image size = 640.</p>",
      "rawMarkdown": "i tried trust = 6 with yolo 11m, my lb was not good. i think that is because i use batch size = 16 and image size = 640.",
      "votes": null
    },
    {
      "id": "3217463",
      "postDate": "06/05/2025 03:34:34",
      "content": "<p>I also had extremely low LB just by setting trust = 7 or trust = 10 in BS=32 and imgsz=960. but trust = 4 was better. I did not know why until the end.</p>",
      "rawMarkdown": "I also had extremely low LB just by setting trust = 7 or trust = 10 in BS=32 and imgsz=960. but trust = 4 was better. I did not know why until the end.",
      "votes": null
    },
    {
      "id": "3217774",
      "postDate": "06/05/2025 11:49:45",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/minfuka\" target=\"_blank\">@minfuka</a>, that's massive engineering effort! Very impressive!</p>",
      "rawMarkdown": "Hey @minfuka, that's massive engineering effort! Very impressive!",
      "votes": null
    },
    {
      "id": "3217790",
      "postDate": "06/05/2025 12:01:36",
      "content": "<p>Thanks! it's only engineering but not data science,HAHAHA:D</p>",
      "rawMarkdown": "Thanks! it's only engineering but not data science,HAHAHA:D",
      "votes": null
    },
    {
      "id": "3218031",
      "postDate": "06/05/2025 17:17:45",
      "content": "<p>Great job, and thanks for sharing the details of your approach!</p>\n<p>Interestingly, my solution was quite similar in many ways<br>\nI also used <strong>YOLOv8</strong>, resized images to <strong>960×960</strong>, and relied on ** only competition data as the core dataset**</p>\n<p>Here are a few key differences in my pipeline:</p>\n<ul>\n<li><strong>Base models</strong>: I used both <code>yolov8l</code> and <code>yolov8x</code>.</li>\n<li><strong>Positive slices</strong>: For tomograms containing motors, I extracted <strong>7 slices</strong> (<code>trust_z=3</code>) around each motor.</li>\n<li><strong>Box size</strong>: Set to <code>int(500 / voxel_spacing)</code> instead of 1000.</li>\n<li><strong>Negative samples</strong>: I included <strong>20 slices per no-motor tomogram</strong> as background (empty labels) to help YOLO reduce false positives.</li>\n<li><strong>No external data</strong> was used in training.</li>\n</ul>\n<p><strong>Inference</strong>: I ensembled two models and achieved a PB of <strong>0.822</strong>:</p>\n<pre><code>model_path_841=\nmodel_path_822=\n\nmodels_config = [\n    {: model8_path_841, : , : , : , : ,:, : },\n    {: model_path_822, : , : , : , : ,:, : },\n]\n</code></pre>",
      "rawMarkdown": "Great job, and thanks for sharing the details of your approach!\n\nInterestingly, my solution was quite similar in many ways\nI also used **YOLOv8**, resized images to **960×960**, and relied on ** only competition data as the core dataset**\n\nHere are a few key differences in my pipeline:\n\n- **Base models**: I used both `yolov8l` and `yolov8x`.\n- **Positive slices**: For tomograms containing motors, I extracted **7 slices** (`trust_z=3`) around each motor.\n- **Box size**: Set to `int(500 / voxel_spacing)` instead of 1000.\n- **Negative samples**: I included **20 slices per no-motor tomogram** as background (empty labels) to help YOLO reduce false positives.\n- **No external data** was used in training.\n\n**Inference**: I ensembled two models and achieved a PB of **0.822**:\n\n```python\nmodel_path_841=\"yolo8x-models/max_recall_e37-p0.90-r0.90-m50.92-m590.63-b1.10_1.11-c0.27_0.32-d0.63_0.48.pt\"\nmodel_path_822=\"yolo8l-models/max_recall_e88-p0.74-r0.55-m50.61-m590.37-b1.32-c0.80-d0.53.pt\"\n\nmodels_config = [\n    {\"path\": model8_path_841, \"conf\": 0.55, \"start\": 0, \"step\": 2, \"imgsz\": 896,\"augment\":True, \"weight\": 1.0},\n    {\"path\": model_path_822, \"conf\": 0.55, \"start\": 0, \"step\": 2, \"imgsz\": 960,\"augment\":True, \"weight\": 1.0},\n]\n```",
      "votes": null
    },
    {
      "id": "3218151",
      "postDate": "06/05/2025 21:53:40",
      "content": "<p>thanks for your approach!</p>\n<p>I have tow questons.</p>\n<p>Did you change the imgsz of predict by model? I did not specify the imgsz of predict.<br>\nHow did you select the 20 slices of Negative samples?</p>",
      "rawMarkdown": "thanks for your approach!\n\nI have tow questons.\n\nDid you change the imgsz of predict by model? I did not specify the imgsz of predict.\nHow did you select the 20 slices of Negative samples?",
      "votes": null
    },
    {
      "id": "3218164",
      "postDate": "06/05/2025 22:30:02",
      "content": "<p>yes i set the imgsz for each model based that trained, <br>\nyolo8x train, predict with imgsz=896 get highest LB=0.841 , PB=0.802 <br>\nyolo8l train, predict with imgsz=960 get highest LB=0.822 , PB=0.786 </p>\n<p>=====================<br>\nHow did you select the 20 slices of Negative samples?</p>\n<pre><code>num_slice = \nstep = axis_shape_z // num_slice\n z  (, axis_shape_z, step):\n    ...\n</code></pre>",
      "rawMarkdown": "yes i set the imgsz for each model based that trained, \nyolo8x train, predict with imgsz=896 get highest LB=0.841 , PB=0.802 \nyolo8l train, predict with imgsz=960 get highest LB=0.822 , PB=0.786 \n\n=====================\nHow did you select the 20 slices of Negative samples?\n```python\nnum_slice = 20\nstep = axis_shape_z // num_slice\nfor z in range(0, axis_shape_z, step):\n    ...\n\n```",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 3217459,
      "author_name": "konohayui",
      "author_url": "",
      "post_date": "06/05/2025 03:17:29",
      "content": "<p>i tried trust = 6 with yolo 11m, my lb was not good. i think that is because i use batch size = 16 and image size = 640.</p>",
      "votes": null,
      "replies": [
        {
          "id": 3217463,
          "author_name": "minfuka",
          "author_url": "",
          "post_date": "06/05/2025 03:34:34",
          "content": "<p>I also had extremely low LB just by setting trust = 7 or trust = 10 in BS=32 and imgsz=960. but trust = 4 was better. I did not know why until the end.</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 3217774,
      "author_name": "tom99763",
      "author_url": "",
      "post_date": "06/05/2025 11:49:45",
      "content": "<p>Hey <a href=\"https://www.kaggle.com/minfuka\" target=\"_blank\">@minfuka</a>, that's massive engineering effort! Very impressive!</p>",
      "votes": null,
      "replies": [
        {
          "id": 3217790,
          "author_name": "minfuka",
          "author_url": "",
          "post_date": "06/05/2025 12:01:36",
          "content": "<p>Thanks! it's only engineering but not data science,HAHAHA:D</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 3218031,
      "author_name": "engadamalmohammedi",
      "author_url": "",
      "post_date": "06/05/2025 17:17:45",
      "content": "<p>Great job, and thanks for sharing the details of your approach!</p>\n<p>Interestingly, my solution was quite similar in many ways<br>\nI also used <strong>YOLOv8</strong>, resized images to <strong>960×960</strong>, and relied on ** only competition data as the core dataset**</p>\n<p>Here are a few key differences in my pipeline:</p>\n<ul>\n<li><strong>Base models</strong>: I used both <code>yolov8l</code> and <code>yolov8x</code>.</li>\n<li><strong>Positive slices</strong>: For tomograms containing motors, I extracted <strong>7 slices</strong> (<code>trust_z=3</code>) around each motor.</li>\n<li><strong>Box size</strong>: Set to <code>int(500 / voxel_spacing)</code> instead of 1000.</li>\n<li><strong>Negative samples</strong>: I included <strong>20 slices per no-motor tomogram</strong> as background (empty labels) to help YOLO reduce false positives.</li>\n<li><strong>No external data</strong> was used in training.</li>\n</ul>\n<p><strong>Inference</strong>: I ensembled two models and achieved a PB of <strong>0.822</strong>:</p>\n<pre><code>model_path_841=\nmodel_path_822=\n\nmodels_config = [\n    {: model8_path_841, : , : , : , : ,:, : },\n    {: model_path_822, : , : , : , : ,:, : },\n]\n</code></pre>",
      "votes": null,
      "replies": [
        {
          "id": 3218151,
          "author_name": "minfuka",
          "author_url": "",
          "post_date": "06/05/2025 21:53:40",
          "content": "<p>thanks for your approach!</p>\n<p>I have tow questons.</p>\n<p>Did you change the imgsz of predict by model? I did not specify the imgsz of predict.<br>\nHow did you select the 20 slices of Negative samples?</p>",
          "votes": null,
          "replies": [
            {
              "id": 3218164,
              "author_name": "engadamalmohammedi",
              "author_url": "",
              "post_date": "06/05/2025 22:30:02",
              "content": "<p>yes i set the imgsz for each model based that trained, <br>\nyolo8x train, predict with imgsz=896 get highest LB=0.841 , PB=0.802 <br>\nyolo8l train, predict with imgsz=960 get highest LB=0.822 , PB=0.786 </p>\n<p>=====================<br>\nHow did you select the 20 slices of Negative samples?</p>\n<pre><code>num_slice = \nstep = axis_shape_z // num_slice\n z  (, axis_shape_z, step):\n    ...\n</code></pre>",
              "votes": null,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "3217392": "Thanks to our hosts for organizing this competition. Our placing was poor, but I am happy to report that we scored reasonably well on the YOLO model.\n※The team's highest score was PB 0.851\n\n## Making models\n\n- base model\n    \n     yolov8l, yolo11l  (yolov8 had a better LB score)\n    \n- original data\n    \n    competition data + external data(https://www.kaggle.com/datasets/brendanartley/cryoet-flagellar-motors-dataset)\n    \n- making yolo dataset\n    \n    based on **Parse Data notebook(**https://www.kaggle.com/code/andrewjdarley/parse-data)\n    \n    I have devised the following points\n    \n    - When creating training data, TRUST=8 for competition data and TRUST=2 for external data.\n    - When creating validation data, TRUST=4 for competition data sets only, not use external data.\n    - slice images are resized to 960x960 for uniformity\n    - vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data only\n    - BOX_SIZE is int(1000 / voxel_spacing) for competition data, 35 for external data.\n    - 4-fold datasets\n- training\n    \n    based on Train Yolo **notebook(**https://www.kaggle.com/code/andrewjdarley/train-yolo)\n    \n    I have changed the following points\n    \n    - batch-size = 32, epoch=30, imgsz=960\n    - yolov8l:lr0=1e-4, lrf= yolo11l:lr0=0.001  cos_lr=True, etc\n    - save_period=1 and use best_dfl_loss-epoch model\n\n## Inference\n\nIn  YOLO model, I have devised a calculation of the z-coordinate. In addition, I have tried to speed up the process.\n\n- calculation of motor coordinates\n    \n    I used DFS(depth-first search). \n    The x,y coordinates detected in yolo with the slice number as the z coordinate were grouped by DFS and the average value was taken. This idea originated from @itsuki9180 's notebook in CZII (https://www.kaggle.com/code/itsuki9180/czii-yolo11-submission-baseline)\n    \n- speed up inference\n    \n    Submit time for public note takes 6.5h for one model. To improve the processing speed, the following efforts were made. This resulted in submit time of 1h40m for one model.\n    \n    - tomo_id is divided into 4 groups and handled by 4 processes.\n    - 2 processes share one T4-GPU\n    - In 1 porcess, read jpg files in a separate thread from yolo predictions\n    - yolo-predict in half-precision (FP16)\n    \n    ![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F8234844%2F2975859e11f30ffc95edfba1e035bea5%2Fimage.png?generation=1749086495125297&alt=media)\n    \n     \n    \n- yolo-models ensemble\n    \n    The yolo-models ensemble collects the per-slice detection coordinates across the entire models and processes them in DFS at once.\n    \n- slices-skip\n    \n    Even with the above multi-processing, it takes more than 6 hours to ensemble a 4-fold training model. The ensemble of the 4-fold model was reduced to 1h40m by reducing the number of slices in this @yyyy0201 discussion(https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/578461).\n    \n    Prepare array of four randomly selected slices for every 4 slices and assign them to each 4-fold model.\n    \n    ```\n        selected_indices = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n        selected_indices2 = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n        selected_indices3 = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n        selected_indices4 = [random.choice(list(range(i, min(i+4, slen)))) for iin range(0, slen, 4)]\n    ```\n    \n     This resulted in a submission time of about 3hours for an ensemble of yolov8l and yolo11l 4-fold models (8models in total). and the PB score is LB0.840. this inference notebook is (https://www.kaggle.com/code/minfuka/byu-yolo-960-inference-fold4-slice-skip-random-v8l)\n    (but, this notebook could be described more compactly)\n\n    \n\n## Score Transition\n\nLB Score Transition. This score is the score before it was recalculated(https://www.kaggle.com/competitions/byu-locating-bacterial-flagellar-motors-2025/discussion/574729).\n\nAll scores are using yolov8L and hold-out(8:2) dataset and best.pt.\n\nInitially I was submitting best.pt but changed to best_dfl_epoch.pt due to unstable best.pt scores.\n\n- Change image size during training from 640 to 960 → LB 0.65\n- Change from BS=16 to BS=32 → LB 0.699\n- Increase target slice for data set creation in public notes to Train TRUST=8 Valid TRUST=4→ LB 0.76\n- vertical flipping,  horizontal flipping, and horizontal-vertical flipping data augmentation is performed on competition data → LB 0.80\n- Use publicly available external data → LB0.825\n\n## What didn't work\n\n- TTA\n- WBF",
    "3217459": "i tried trust = 6 with yolo 11m, my lb was not good. i think that is because i use batch size = 16 and image size = 640.",
    "3217463": "I also had extremely low LB just by setting trust = 7 or trust = 10 in BS=32 and imgsz=960. but trust = 4 was better. I did not know why until the end.",
    "3217774": "Hey @minfuka, that's massive engineering effort! Very impressive!",
    "3217790": "Thanks! it's only engineering but not data science,HAHAHA:D",
    "3218031": "Great job, and thanks for sharing the details of your approach!\n\nInterestingly, my solution was quite similar in many ways\nI also used **YOLOv8**, resized images to **960×960**, and relied on ** only competition data as the core dataset**\n\nHere are a few key differences in my pipeline:\n\n- **Base models**: I used both `yolov8l` and `yolov8x`.\n- **Positive slices**: For tomograms containing motors, I extracted **7 slices** (`trust_z=3`) around each motor.\n- **Box size**: Set to `int(500 / voxel_spacing)` instead of 1000.\n- **Negative samples**: I included **20 slices per no-motor tomogram** as background (empty labels) to help YOLO reduce false positives.\n- **No external data** was used in training.\n\n**Inference**: I ensembled two models and achieved a PB of **0.822**:\n\n```python\nmodel_path_841=\"yolo8x-models/max_recall_e37-p0.90-r0.90-m50.92-m590.63-b1.10_1.11-c0.27_0.32-d0.63_0.48.pt\"\nmodel_path_822=\"yolo8l-models/max_recall_e88-p0.74-r0.55-m50.61-m590.37-b1.32-c0.80-d0.53.pt\"\n\nmodels_config = [\n    {\"path\": model8_path_841, \"conf\": 0.55, \"start\": 0, \"step\": 2, \"imgsz\": 896,\"augment\":True, \"weight\": 1.0},\n    {\"path\": model_path_822, \"conf\": 0.55, \"start\": 0, \"step\": 2, \"imgsz\": 960,\"augment\":True, \"weight\": 1.0},\n]\n```",
    "3218151": "thanks for your approach!\n\nI have tow questons.\n\nDid you change the imgsz of predict by model? I did not specify the imgsz of predict.\nHow did you select the 20 slices of Negative samples?",
    "3218164": "yes i set the imgsz for each model based that trained, \nyolo8x train, predict with imgsz=896 get highest LB=0.841 , PB=0.802 \nyolo8l train, predict with imgsz=960 get highest LB=0.822 , PB=0.786 \n\n=====================\nHow did you select the 20 slices of Negative samples?\n```python\nnum_slice = 20\nstep = axis_shape_z // num_slice\nfor z in range(0, axis_shape_z, step):\n    ...\n\n```"
  },
  "source": "meta"
}