{
  "id": 674259,
  "title": "1st Place Solution ",
  "content": "<p>السلام عليكم ورحمة الله وبركاته،\nFirst and foremost, I would like to sincerely thank the organizers for hosting such a challenging and well-structured competition.\nMy solution is a two-stage iterative pseudo-labeling pipeline: a <strong>DDQ-DETR detector</strong> (Swin-L, MMDetection) handles bounding boxes, and a <strong>binary right-place classifier</strong> (EfficientNet-B0 → ConvNeXt-Tiny) handles the F1 component. Each model bootstraps the other across two pseudo-labeling rounds. Final predictions are refined through geometric spatial filtering, cross-fold merging, and similarity-based label propagation.</p>\n<p><strong>Final Score = 0.5 × mAP@[0.5:0.95] + 0.5 × F1</strong></p>\n<hr>\n<h2>Data Preparation</h2>\n<p>Training images were annotated with YOLO-format bounding boxes (class 0 = head, class 1 = shemagh) and a <code>right_place</code> binary label in <code>train_labels.csv</code>. Annotations were converted from YOLO normalized coordinates to absolute pixels (for MMDetection), then to COCO JSON format.</p>\n<p>Splitting used <strong>stratified sampling</strong> on a composite key: <code>right_place</code> value + has_head + has_shemagh + object-count bucket (none/few/many). This preserved rare combinations (e.g., shemagh-only images) in both train and validation. An <strong>80/20 split</strong> was used for the initial model, and a <strong>5-fold stratified split</strong> was created for the final ensemble.</p>\n<hr>\n<h2>Object Detector: DDQ-DETR</h2>\n<p><strong>Architecture:</strong> DDQ-DETR with 4-scale FPN and Swin-L backbone, initialized from COCO pretrained weights. Input resolution 1280×1280, batch size 1, up to 50 epochs, best checkpoint saved by <code>bbox_mAP</code>.</p>\n<p><strong>Augmentation:</strong> Random flip, ColorJitter, CLAHE, Gaussian blur, RandomAffine (scale ±10%, rotate ±20°), image sharpening, and a multi-scale resize strategy — either resize directly to 1280×1280 or resize large then random-crop (384–640px) then resize back, to simulate objects at different scales.</p>\n<p><strong>Inference:</strong> Confidence thresholds of <strong>0.30 for head</strong> and <strong>0.15 for shemagh</strong> (lower because the distinctive checkered pattern makes lower-confidence detections reliable), NMS IoU = 0.40.</p>\n<p><strong>Validation:</strong> <code>bbox_mAP@[.5:.95] ≈ 0.85–0.90</code>, <code>bbox_mAP@50 ≈ 0.93–0.97</code>.</p>\n<hr>\n<h2>Two-Stage Pseudo-Labeling</h2>\n<p>The labeled training set is small, but the test set is large and unlabeled. Pseudo-labeling uses the test set images to enrich classifier training.</p>\n<h3>Round 1</h3>\n<ol>\n<li><p>The initial DDQ-DETR model ran on the test set. Images where both a head and shemagh were detected got <code>right_place = 1</code> (co-occurrence rule), then a <strong>geometric spatial check</strong> filtered false positives: the shemagh's bounding box must overlap horizontally with the closest head box, and the shemagh center must sit above the head's bottom edge. Failures were corrected to <code>right_place = 0</code>.</p></li>\n<li><p>Test images predicted as <code>right_place = 1</code> were added to the training set as <strong>pseudo-positive labels</strong> and pooled with the original training images.</p></li>\n<li><p>An <strong>EfficientNet-B0</strong> binary classifier was trained on this expanded set with 5-fold CV (input 240×240, lr=5e-5, 25 epochs, early stopping patience=5, class weights + WeightedRandomSampler, dropout=0.4). Augmentations: random flips, rotation ±20°, ColorJitter, random erasing.</p></li>\n<li><p>Inference used a 5-fold mean probability threshold of <strong>0.653</strong>. Wherever the detector said <code>right_place = 0</code> but the classifier said 1, the label was flipped to 1. This corrects cases where the geometric heuristic was too strict (unusual angles, occlusions).</p></li>\n</ol>\n<h3>Round 2</h3>\n<ol>\n<li><p>The classifier-corrected labels became the new pseudo-label set — cleaner than the raw detector output.</p></li>\n<li><p>A <strong>ConvNeXt-Tiny</strong> (<code>convnext_tiny.fb_in22k_ft_in1k</code>) classifier was trained on this refined set with 5-fold CV (input 256×256, lr=3e-5, 30 epochs, patience=7). Key additions: <strong>label smoothing=0.1</strong> (prevents overconfidence on noisy pseudo labels), <strong>Mixup alpha=0.2</strong> (interpolates image pairs and labels for better generalization), TrivialAugmentWide, random erasing.</p></li>\n<li><p>Inference used <strong>Test-Time Augmentation</strong> (original + horizontal flip + small rotation), averaged across all TTA variants and all 5 folds, threshold <strong>0.63</strong>.</p></li>\n<li><p>A second flip pass was applied: detector labels of 0 where ConvNeXt said 1 were flipped again. This doubly-refined label set was used to train the final 5-fold detector.</p></li>\n</ol>\n<p><strong>ConvNeXt-Tiny CV results:</strong> Mean AUC ≈ <strong>0.854 ± 0.035</strong>, per-fold F1 = 0.60–0.69.</p>\n<hr>\n<h2>Final 5-Fold Detector Ensemble</h2>\n<p>Five DDQ-DETR models were trained on the 5-fold splits (same architecture and augmentations, max 50 epochs each). Each fold model produced its own prediction CSV on the test set. A <code>problematic_cases.txt</code> list was generated for images where fold predictions conflicted.</p>\n<p><strong>Merging strategy for problematic cases:</strong></p>\n<ul>\n<li><em>Simple</em> (≤1 box per class per fold): take the highest-confidence head box and highest-confidence shemagh box across all folds.</li>\n<li><em>Complex</em> (multiple boxes per class): pick the fold prediction with the most boxes and highest average confidence (folds 2–5 preferred).</li>\n<li><em>Missing class recovery</em>: if any fold had a class at confidence &gt; 0.5 that the merged result dropped, that box was added back.</li>\n</ul>\n<hr>\n<h2>Geometric Spatial Filter (Re-applied)</h2>\n<p>The same spatial check from Round 1 was re-applied on the final 5-fold ensemble results to remove any remaining false positives before the similarity post-processing step.</p>\n<hr>\n<h2>Similarity-Based Post-Processing</h2>\n<p>Pairwise visual similarity was computed across all test images using three fused descriptors:</p>\n<ul>\n<li><strong>Deep features:</strong> EfficientNet-B4 @ 480px → 1792-D cosine similarity (weight: 0.50)</li>\n<li><strong>Color histogram:</strong> HSV bins 16×8×8 (weight: 0.25)</li>\n<li><strong>Texture:</strong> Local Binary Patterns, radius=3, 24 points (weight: 0.25)</li>\n</ul>\n<p>The top-4 most similar images were stored per test image. For the most ambiguous cases — images predicted <code>right_place = 0</code> that had a shemagh detection but <strong>no head detection</strong> — neighbors were consulted:</p>\n<ul>\n<li>If the top-4 neighbors also had head detections → flip the target to <code>right_place = 1</code>.</li>\n<li>If neighbors also lacked head detections → force any of those positive neighbors to 0 (the whole visual cluster is treated as negative).</li>\n</ul>\n<p>You can find the full implementation on GitHub: <a href=\"https://github.com/TheKing020/Dal-Shemagh-Object-Detection-Challenge.git\" target=\"_blank\">https://github.com/TheKing020/Dal-Shemagh-Object-Detection-Challenge.git</a></p>",
  "comments": [
    {
      "id": 3408122,
      "author_name": "Mohamed Eltayeb",
      "author_url": "",
      "post_date": "2026-02-19T21:19:17.310000",
      "content": "<p><a href=\"https://www.kaggle.com/kagglertw\" target=\"_blank\">@kagglertw</a> \nAmazing writeup Mashallah :) Realllllly liked it</p>\n<p>btw sorry, would appreicate if u can fill the form we sent so we finalize everything. Thanks!</p>",
      "votes": 1,
      "replies": []
    }
  ],
  "comment_count": 1,
  "messages": [
    {
      "id": 3407952,
      "postDate": "2026-02-19T13:53:18.780Z",
      "content": "<p>السلام عليكم ورحمة الله وبركاته،\nFirst and foremost, I would like to sincerely thank the organizers for hosting such a challenging and well-structured competition.\nMy solution is a two-stage iterative pseudo-labeling pipeline: a <strong>DDQ-DETR detector</strong> (Swin-L, MMDetection) handles bounding boxes, and a <strong>binary right-place classifier</strong> (EfficientNet-B0 → ConvNeXt-Tiny) handles the F1 component. Each model bootstraps the other across two pseudo-labeling rounds. Final predictions are refined through geometric spatial filtering, cross-fold merging, and similarity-based label propagation.</p>\n<p><strong>Final Score = 0.5 × mAP@[0.5:0.95] + 0.5 × F1</strong></p>\n<hr>\n<h2>Data Preparation</h2>\n<p>Training images were annotated with YOLO-format bounding boxes (class 0 = head, class 1 = shemagh) and a <code>right_place</code> binary label in <code>train_labels.csv</code>. Annotations were converted from YOLO normalized coordinates to absolute pixels (for MMDetection), then to COCO JSON format.</p>\n<p>Splitting used <strong>stratified sampling</strong> on a composite key: <code>right_place</code> value + has_head + has_shemagh + object-count bucket (none/few/many). This preserved rare combinations (e.g., shemagh-only images) in both train and validation. An <strong>80/20 split</strong> was used for the initial model, and a <strong>5-fold stratified split</strong> was created for the final ensemble.</p>\n<hr>\n<h2>Object Detector: DDQ-DETR</h2>\n<p><strong>Architecture:</strong> DDQ-DETR with 4-scale FPN and Swin-L backbone, initialized from COCO pretrained weights. Input resolution 1280×1280, batch size 1, up to 50 epochs, best checkpoint saved by <code>bbox_mAP</code>.</p>\n<p><strong>Augmentation:</strong> Random flip, ColorJitter, CLAHE, Gaussian blur, RandomAffine (scale ±10%, rotate ±20°), image sharpening, and a multi-scale resize strategy — either resize directly to 1280×1280 or resize large then random-crop (384–640px) then resize back, to simulate objects at different scales.</p>\n<p><strong>Inference:</strong> Confidence thresholds of <strong>0.30 for head</strong> and <strong>0.15 for shemagh</strong> (lower because the distinctive checkered pattern makes lower-confidence detections reliable), NMS IoU = 0.40.</p>\n<p><strong>Validation:</strong> <code>bbox_mAP@[.5:.95] ≈ 0.85–0.90</code>, <code>bbox_mAP@50 ≈ 0.93–0.97</code>.</p>\n<hr>\n<h2>Two-Stage Pseudo-Labeling</h2>\n<p>The labeled training set is small, but the test set is large and unlabeled. Pseudo-labeling uses the test set images to enrich classifier training.</p>\n<h3>Round 1</h3>\n<ol>\n<li><p>The initial DDQ-DETR model ran on the test set. Images where both a head and shemagh were detected got <code>right_place = 1</code> (co-occurrence rule), then a <strong>geometric spatial check</strong> filtered false positives: the shemagh's bounding box must overlap horizontally with the closest head box, and the shemagh center must sit above the head's bottom edge. Failures were corrected to <code>right_place = 0</code>.</p></li>\n<li><p>Test images predicted as <code>right_place = 1</code> were added to the training set as <strong>pseudo-positive labels</strong> and pooled with the original training images.</p></li>\n<li><p>An <strong>EfficientNet-B0</strong> binary classifier was trained on this expanded set with 5-fold CV (input 240×240, lr=5e-5, 25 epochs, early stopping patience=5, class weights + WeightedRandomSampler, dropout=0.4). Augmentations: random flips, rotation ±20°, ColorJitter, random erasing.</p></li>\n<li><p>Inference used a 5-fold mean probability threshold of <strong>0.653</strong>. Wherever the detector said <code>right_place = 0</code> but the classifier said 1, the label was flipped to 1. This corrects cases where the geometric heuristic was too strict (unusual angles, occlusions).</p></li>\n</ol>\n<h3>Round 2</h3>\n<ol>\n<li><p>The classifier-corrected labels became the new pseudo-label set — cleaner than the raw detector output.</p></li>\n<li><p>A <strong>ConvNeXt-Tiny</strong> (<code>convnext_tiny.fb_in22k_ft_in1k</code>) classifier was trained on this refined set with 5-fold CV (input 256×256, lr=3e-5, 30 epochs, patience=7). Key additions: <strong>label smoothing=0.1</strong> (prevents overconfidence on noisy pseudo labels), <strong>Mixup alpha=0.2</strong> (interpolates image pairs and labels for better generalization), TrivialAugmentWide, random erasing.</p></li>\n<li><p>Inference used <strong>Test-Time Augmentation</strong> (original + horizontal flip + small rotation), averaged across all TTA variants and all 5 folds, threshold <strong>0.63</strong>.</p></li>\n<li><p>A second flip pass was applied: detector labels of 0 where ConvNeXt said 1 were flipped again. This doubly-refined label set was used to train the final 5-fold detector.</p></li>\n</ol>\n<p><strong>ConvNeXt-Tiny CV results:</strong> Mean AUC ≈ <strong>0.854 ± 0.035</strong>, per-fold F1 = 0.60–0.69.</p>\n<hr>\n<h2>Final 5-Fold Detector Ensemble</h2>\n<p>Five DDQ-DETR models were trained on the 5-fold splits (same architecture and augmentations, max 50 epochs each). Each fold model produced its own prediction CSV on the test set. A <code>problematic_cases.txt</code> list was generated for images where fold predictions conflicted.</p>\n<p><strong>Merging strategy for problematic cases:</strong></p>\n<ul>\n<li><em>Simple</em> (≤1 box per class per fold): take the highest-confidence head box and highest-confidence shemagh box across all folds.</li>\n<li><em>Complex</em> (multiple boxes per class): pick the fold prediction with the most boxes and highest average confidence (folds 2–5 preferred).</li>\n<li><em>Missing class recovery</em>: if any fold had a class at confidence &gt; 0.5 that the merged result dropped, that box was added back.</li>\n</ul>\n<hr>\n<h2>Geometric Spatial Filter (Re-applied)</h2>\n<p>The same spatial check from Round 1 was re-applied on the final 5-fold ensemble results to remove any remaining false positives before the similarity post-processing step.</p>\n<hr>\n<h2>Similarity-Based Post-Processing</h2>\n<p>Pairwise visual similarity was computed across all test images using three fused descriptors:</p>\n<ul>\n<li><strong>Deep features:</strong> EfficientNet-B4 @ 480px → 1792-D cosine similarity (weight: 0.50)</li>\n<li><strong>Color histogram:</strong> HSV bins 16×8×8 (weight: 0.25)</li>\n<li><strong>Texture:</strong> Local Binary Patterns, radius=3, 24 points (weight: 0.25)</li>\n</ul>\n<p>The top-4 most similar images were stored per test image. For the most ambiguous cases — images predicted <code>right_place = 0</code> that had a shemagh detection but <strong>no head detection</strong> — neighbors were consulted:</p>\n<ul>\n<li>If the top-4 neighbors also had head detections → flip the target to <code>right_place = 1</code>.</li>\n<li>If neighbors also lacked head detections → force any of those positive neighbors to 0 (the whole visual cluster is treated as negative).</li>\n</ul>\n<p>You can find the full implementation on GitHub: <a href=\"https://github.com/TheKing020/Dal-Shemagh-Object-Detection-Challenge.git\" target=\"_blank\">https://github.com/TheKing020/Dal-Shemagh-Object-Detection-Challenge.git</a></p>",
      "rawMarkdown": "السلام عليكم ورحمة الله وبركاته،\nFirst and foremost, I would like to sincerely thank the organizers for hosting such a challenging and well-structured competition.\nMy solution is a two-stage iterative pseudo-labeling pipeline: a **DDQ-DETR detector** (Swin-L, MMDetection) handles bounding boxes, and a **binary right-place classifier** (EfficientNet-B0 → ConvNeXt-Tiny) handles the F1 component. Each model bootstraps the other across two pseudo-labeling rounds. Final predictions are refined through geometric spatial filtering, cross-fold merging, and similarity-based label propagation.\n\n**Final Score = 0.5 × mAP@[0.5:0.95] + 0.5 × F1**\n\n---\n\n## Data Preparation\n\nTraining images were annotated with YOLO-format bounding boxes (class 0 = head, class 1 = shemagh) and a `right_place` binary label in `train_labels.csv`. Annotations were converted from YOLO normalized coordinates to absolute pixels (for MMDetection), then to COCO JSON format.\n\nSplitting used **stratified sampling** on a composite key: `right_place` value + has_head + has_shemagh + object-count bucket (none/few/many). This preserved rare combinations (e.g., shemagh-only images) in both train and validation. An **80/20 split** was used for the initial model, and a **5-fold stratified split** was created for the final ensemble.\n\n---\n\n## Object Detector: DDQ-DETR\n\n**Architecture:** DDQ-DETR with 4-scale FPN and Swin-L backbone, initialized from COCO pretrained weights. Input resolution 1280×1280, batch size 1, up to 50 epochs, best checkpoint saved by `bbox_mAP`.\n\n**Augmentation:** Random flip, ColorJitter, CLAHE, Gaussian blur, RandomAffine (scale ±10%, rotate ±20°), image sharpening, and a multi-scale resize strategy — either resize directly to 1280×1280 or resize large then random-crop (384–640px) then resize back, to simulate objects at different scales.\n\n**Inference:** Confidence thresholds of **0.30 for head** and **0.15 for shemagh** (lower because the distinctive checkered pattern makes lower-confidence detections reliable), NMS IoU = 0.40.\n\n**Validation:** `bbox_mAP@[.5:.95] ≈ 0.85–0.90`, `bbox_mAP@50 ≈ 0.93–0.97`.\n\n---\n\n## Two-Stage Pseudo-Labeling\n\nThe labeled training set is small, but the test set is large and unlabeled. Pseudo-labeling uses the test set images to enrich classifier training.\n\n### Round 1\n\n1. The initial DDQ-DETR model ran on the test set. Images where both a head and shemagh were detected got `right_place = 1` (co-occurrence rule), then a **geometric spatial check** filtered false positives: the shemagh's bounding box must overlap horizontally with the closest head box, and the shemagh center must sit above the head's bottom edge. Failures were corrected to `right_place = 0`.\n\n2. Test images predicted as `right_place = 1` were added to the training set as **pseudo-positive labels** and pooled with the original training images.\n\n3. An **EfficientNet-B0** binary classifier was trained on this expanded set with 5-fold CV (input 240×240, lr=5e-5, 25 epochs, early stopping patience=5, class weights + WeightedRandomSampler, dropout=0.4). Augmentations: random flips, rotation ±20°, ColorJitter, random erasing.\n\n4. Inference used a 5-fold mean probability threshold of **0.653**. Wherever the detector said `right_place = 0` but the classifier said 1, the label was flipped to 1. This corrects cases where the geometric heuristic was too strict (unusual angles, occlusions).\n\n### Round 2\n\n1. The classifier-corrected labels became the new pseudo-label set — cleaner than the raw detector output.\n\n2. A **ConvNeXt-Tiny** (`convnext_tiny.fb_in22k_ft_in1k`) classifier was trained on this refined set with 5-fold CV (input 256×256, lr=3e-5, 30 epochs, patience=7). Key additions: **label smoothing=0.1** (prevents overconfidence on noisy pseudo labels), **Mixup alpha=0.2** (interpolates image pairs and labels for better generalization), TrivialAugmentWide, random erasing.\n\n3. Inference used **Test-Time Augmentation** (original + horizontal flip + small rotation), averaged across all TTA variants and all 5 folds, threshold **0.63**.\n\n4. A second flip pass was applied: detector labels of 0 where ConvNeXt said 1 were flipped again. This doubly-refined label set was used to train the final 5-fold detector.\n\n**ConvNeXt-Tiny CV results:** Mean AUC ≈ **0.854 ± 0.035**, per-fold F1 = 0.60–0.69.\n\n---\n\n## Final 5-Fold Detector Ensemble\n\nFive DDQ-DETR models were trained on the 5-fold splits (same architecture and augmentations, max 50 epochs each). Each fold model produced its own prediction CSV on the test set. A `problematic_cases.txt` list was generated for images where fold predictions conflicted.\n\n**Merging strategy for problematic cases:**\n- *Simple* (≤1 box per class per fold): take the highest-confidence head box and highest-confidence shemagh box across all folds.\n- *Complex* (multiple boxes per class): pick the fold prediction with the most boxes and highest average confidence (folds 2–5 preferred).\n- *Missing class recovery*: if any fold had a class at confidence > 0.5 that the merged result dropped, that box was added back.\n\n---\n\n## Geometric Spatial Filter (Re-applied)\n\nThe same spatial check from Round 1 was re-applied on the final 5-fold ensemble results to remove any remaining false positives before the similarity post-processing step.\n\n---\n\n## Similarity-Based Post-Processing\n\nPairwise visual similarity was computed across all test images using three fused descriptors:\n- **Deep features:** EfficientNet-B4 @ 480px → 1792-D cosine similarity (weight: 0.50)\n- **Color histogram:** HSV bins 16×8×8 (weight: 0.25)\n- **Texture:** Local Binary Patterns, radius=3, 24 points (weight: 0.25)\n\nThe top-4 most similar images were stored per test image. For the most ambiguous cases — images predicted `right_place = 0` that had a shemagh detection but **no head detection** — neighbors were consulted:\n- If the top-4 neighbors also had head detections → flip the target to `right_place = 1`.\n- If neighbors also lacked head detections → force any of those positive neighbors to 0 (the whole visual cluster is treated as negative).\n\nYou can find the full implementation on GitHub: https://github.com/TheKing020/Dal-Shemagh-Object-Detection-Challenge.git",
      "votes": 6
    },
    {
      "id": 3408122,
      "postDate": "2026-02-19T21:19:17.310Z",
      "content": "<p><a href=\"https://www.kaggle.com/kagglertw\" target=\"_blank\">@kagglertw</a> \nAmazing writeup Mashallah :) Realllllly liked it</p>\n<p>btw sorry, would appreicate if u can fill the form we sent so we finalize everything. Thanks!</p>",
      "rawMarkdown": "@kagglertw \nAmazing writeup Mashallah :) Realllllly liked it\n\nbtw sorry, would appreicate if u can fill the form we sent so we finalize everything. Thanks!",
      "votes": 1
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-19T10:47:38Z",
  "competition_id": 129750,
  "competition_slug": "dal-shemagh-detection-challenge",
  "team_id": 15246994,
  "solution_url": ""
}