{
  "id": 704890,
  "title": "Learning Spectral Representations with SimMIM and Swin Transformer V2",
  "url": "/competitions/beyond-visible-spectrum-ai-for-agriculture-2026p2/discussion/704890",
  "author_name": "Jeki Wan Taufik",
  "post_date": "2026-06-07T06:08:09.550000",
  "votes": 1,
  "comment_count": 0,
  "views": 0,
  "content": "<h2>Overview</h2>\n<p>Our solution follows a two-stage training strategy combining self-supervised learning and supervised fine-tuning. Since the competition dataset contains multispectral Sentinel imagery with limited labeled samples, we first learned general spectral representations using a SimMIM-style masked image modeling task and then fine-tuned the pretrained encoder for disease classification.</p>\n<p>The final pipeline consists of:</p>\n<ol>\n<li>Multispectral preprocessing and normalization</li>\n<li>Self-supervised pretraining with SimMIM</li>\n<li>Supervised fine-tuning using class-weighted cross-entropy</li>\n<li>Test-time augmentation (TTA) during inference</li>\n</ol>\n<hr>\n<h2>Data Preparation</h2>\n<p>The dataset consists of Sentinel imagery containing 12 spectral bands:</p>\n<p>B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B11, and B12.</p>\n<p>Each band was resized to 256×256 using bilinear interpolation. Band-specific normalization was applied using predefined mean and standard deviation statistics.</p>\n<p>For robustness, missing or unreadable bands were replaced with zero-valued arrays.</p>\n<p>During training, only spatial augmentations were used:</p>\n<ul>\n<li>Horizontal Flip</li>\n<li>Vertical Flip</li>\n<li>Random Rotation</li>\n</ul>\n<p>No spectral perturbation was applied because preserving physically meaningful spectral information was considered important for multispectral imagery.</p>\n<hr>\n<h2>Model Architecture</h2>\n<p>The backbone of the solution is Swin Transformer V2 Tiny (swinv2_tiny_window16_256).</p>\n<p>The original ImageNet-pretrained model accepts RGB input (3 channels). Since Sentinel imagery contains 12 channels, the patch embedding layer was modified to accept 12-band input.</p>\n<p>Instead of random initialization, pretrained RGB weights were replicated across all spectral channels. This provided a stable starting point and allowed the model to benefit from ImageNet pretraining despite the different input modality.</p>\n<hr>\n<h2>Self-Supervised Learning (SimMIM)</h2>\n<p>Before supervised training, a SimMIM-inspired masked image modeling stage was performed.</p>\n<h3>Masking Strategy</h3>\n<p>A random mask ratio of 60% was used. Masked regions were removed from the input image while visible regions remained unchanged.</p>\n<p>The encoder was required to reconstruct the missing multispectral content.</p>\n<h3>Reconstruction Head</h3>\n<p>A lightweight convolutional decoder was attached to the Swin encoder. PixelShuffle was used to recover full image resolution.</p>\n<h3>Loss Function</h3>\n<p>Only masked regions contributed to the reconstruction objective.</p>\n<p>An L1 reconstruction loss was computed between the reconstructed image and the original image:</p>\n<ul>\n<li>Loss evaluated only on masked pixels</li>\n<li>Visible pixels ignored during optimization</li>\n</ul>\n<h3>Training Configuration</h3>\n<ul>\n<li>Optimizer: AdamW</li>\n<li>Learning Rate: 5e-4</li>\n<li>Epochs: 30</li>\n</ul>\n<p>After pretraining, only the encoder weights were retained. The decoder was discarded.</p>\n<hr>\n<h2>Supervised Fine-Tuning</h2>\n<p>The pretrained encoder weights were loaded into a classification model.</p>\n<p>A new classification head was attached for the four disease categories:</p>\n<ul>\n<li>Aphid</li>\n<li>Blast</li>\n<li>RPH</li>\n<li>Rust</li>\n</ul>\n<h3>Class Imbalance Handling</h3>\n<p>The dataset exhibited noticeable class imbalance. To address this issue, weighted cross-entropy loss was used:</p>\n<ul>\n<li>Aphid: 1.0</li>\n<li>Blast: 4.0</li>\n<li>RPH: 0.6</li>\n<li>Rust: 12.0</li>\n</ul>\n<p>Higher weights were assigned to minority classes to improve their contribution during optimization.</p>\n<h3>Training Configuration</h3>\n<ul>\n<li>Optimizer: AdamW</li>\n<li>Learning Rate: 1e-4</li>\n<li>Scheduler: Cosine Annealing</li>\n<li>Epochs: 20</li>\n</ul>\n<p>The entire labeled dataset was used for supervised training.</p>\n<hr>\n<h2>Inference</h2>\n<p>For inference, Test Time Augmentation (TTA) was applied.</p>\n<p>Predictions were generated from six transformed versions of each image:</p>\n<ol>\n<li>Original image</li>\n<li>Horizontal flip</li>\n<li>Vertical flip</li>\n<li>90° rotation</li>\n<li>180° rotation</li>\n<li>270° rotation</li>\n</ol>\n<p>Softmax probabilities from all transformations were averaged, and the final class prediction was obtained using argmax.</p>\n<hr>\n<h2>Final Pipeline</h2>\n<p>Sentinel-2 Multispectral Images</p>\n<p>→ Band Normalization</p>\n<p>→ SimMIM Self-Supervised Pretraining</p>\n<p>→ Swin Transformer Encoder</p>\n<p>→ Supervised Fine-Tuning</p>\n<p>→ Class-Weighted Cross-Entropy</p>\n<p>→ Test Time Augmentation</p>\n<p>→ Final Prediction</p>\n<hr>\n<h2>Conclusion</h2>\n<p>The most important component of the solution was the self-supervised pretraining stage. By leveraging all available imagery through masked image modeling, the Swin encoder learned useful spectral representations before receiving class labels.</p>\n<p>Combined with class-weighted fine-tuning and test-time augmentation, this approach produced a robust classification pipeline for multispectral crop disease recognition.</p>",
  "messages": [
    {
      "id": 3467709,
      "postDate": "2026-06-07T06:08:09.550Z",
      "content": "<h2>Overview</h2>\n<p>Our solution follows a two-stage training strategy combining self-supervised learning and supervised fine-tuning. Since the competition dataset contains multispectral Sentinel imagery with limited labeled samples, we first learned general spectral representations using a SimMIM-style masked image modeling task and then fine-tuned the pretrained encoder for disease classification.</p>\n<p>The final pipeline consists of:</p>\n<ol>\n<li>Multispectral preprocessing and normalization</li>\n<li>Self-supervised pretraining with SimMIM</li>\n<li>Supervised fine-tuning using class-weighted cross-entropy</li>\n<li>Test-time augmentation (TTA) during inference</li>\n</ol>\n<hr>\n<h2>Data Preparation</h2>\n<p>The dataset consists of Sentinel imagery containing 12 spectral bands:</p>\n<p>B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B11, and B12.</p>\n<p>Each band was resized to 256×256 using bilinear interpolation. Band-specific normalization was applied using predefined mean and standard deviation statistics.</p>\n<p>For robustness, missing or unreadable bands were replaced with zero-valued arrays.</p>\n<p>During training, only spatial augmentations were used:</p>\n<ul>\n<li>Horizontal Flip</li>\n<li>Vertical Flip</li>\n<li>Random Rotation</li>\n</ul>\n<p>No spectral perturbation was applied because preserving physically meaningful spectral information was considered important for multispectral imagery.</p>\n<hr>\n<h2>Model Architecture</h2>\n<p>The backbone of the solution is Swin Transformer V2 Tiny (swinv2_tiny_window16_256).</p>\n<p>The original ImageNet-pretrained model accepts RGB input (3 channels). Since Sentinel imagery contains 12 channels, the patch embedding layer was modified to accept 12-band input.</p>\n<p>Instead of random initialization, pretrained RGB weights were replicated across all spectral channels. This provided a stable starting point and allowed the model to benefit from ImageNet pretraining despite the different input modality.</p>\n<hr>\n<h2>Self-Supervised Learning (SimMIM)</h2>\n<p>Before supervised training, a SimMIM-inspired masked image modeling stage was performed.</p>\n<h3>Masking Strategy</h3>\n<p>A random mask ratio of 60% was used. Masked regions were removed from the input image while visible regions remained unchanged.</p>\n<p>The encoder was required to reconstruct the missing multispectral content.</p>\n<h3>Reconstruction Head</h3>\n<p>A lightweight convolutional decoder was attached to the Swin encoder. PixelShuffle was used to recover full image resolution.</p>\n<h3>Loss Function</h3>\n<p>Only masked regions contributed to the reconstruction objective.</p>\n<p>An L1 reconstruction loss was computed between the reconstructed image and the original image:</p>\n<ul>\n<li>Loss evaluated only on masked pixels</li>\n<li>Visible pixels ignored during optimization</li>\n</ul>\n<h3>Training Configuration</h3>\n<ul>\n<li>Optimizer: AdamW</li>\n<li>Learning Rate: 5e-4</li>\n<li>Epochs: 30</li>\n</ul>\n<p>After pretraining, only the encoder weights were retained. The decoder was discarded.</p>\n<hr>\n<h2>Supervised Fine-Tuning</h2>\n<p>The pretrained encoder weights were loaded into a classification model.</p>\n<p>A new classification head was attached for the four disease categories:</p>\n<ul>\n<li>Aphid</li>\n<li>Blast</li>\n<li>RPH</li>\n<li>Rust</li>\n</ul>\n<h3>Class Imbalance Handling</h3>\n<p>The dataset exhibited noticeable class imbalance. To address this issue, weighted cross-entropy loss was used:</p>\n<ul>\n<li>Aphid: 1.0</li>\n<li>Blast: 4.0</li>\n<li>RPH: 0.6</li>\n<li>Rust: 12.0</li>\n</ul>\n<p>Higher weights were assigned to minority classes to improve their contribution during optimization.</p>\n<h3>Training Configuration</h3>\n<ul>\n<li>Optimizer: AdamW</li>\n<li>Learning Rate: 1e-4</li>\n<li>Scheduler: Cosine Annealing</li>\n<li>Epochs: 20</li>\n</ul>\n<p>The entire labeled dataset was used for supervised training.</p>\n<hr>\n<h2>Inference</h2>\n<p>For inference, Test Time Augmentation (TTA) was applied.</p>\n<p>Predictions were generated from six transformed versions of each image:</p>\n<ol>\n<li>Original image</li>\n<li>Horizontal flip</li>\n<li>Vertical flip</li>\n<li>90° rotation</li>\n<li>180° rotation</li>\n<li>270° rotation</li>\n</ol>\n<p>Softmax probabilities from all transformations were averaged, and the final class prediction was obtained using argmax.</p>\n<hr>\n<h2>Final Pipeline</h2>\n<p>Sentinel-2 Multispectral Images</p>\n<p>→ Band Normalization</p>\n<p>→ SimMIM Self-Supervised Pretraining</p>\n<p>→ Swin Transformer Encoder</p>\n<p>→ Supervised Fine-Tuning</p>\n<p>→ Class-Weighted Cross-Entropy</p>\n<p>→ Test Time Augmentation</p>\n<p>→ Final Prediction</p>\n<hr>\n<h2>Conclusion</h2>\n<p>The most important component of the solution was the self-supervised pretraining stage. By leveraging all available imagery through masked image modeling, the Swin encoder learned useful spectral representations before receiving class labels.</p>\n<p>Combined with class-weighted fine-tuning and test-time augmentation, this approach produced a robust classification pipeline for multispectral crop disease recognition.</p>",
      "rawMarkdown": "## Overview\n\nOur solution follows a two-stage training strategy combining self-supervised learning and supervised fine-tuning. Since the competition dataset contains multispectral Sentinel imagery with limited labeled samples, we first learned general spectral representations using a SimMIM-style masked image modeling task and then fine-tuned the pretrained encoder for disease classification.\n\nThe final pipeline consists of:\n\n1. Multispectral preprocessing and normalization\n2. Self-supervised pretraining with SimMIM\n3. Supervised fine-tuning using class-weighted cross-entropy\n4. Test-time augmentation (TTA) during inference\n\n---\n\n## Data Preparation\n\nThe dataset consists of Sentinel imagery containing 12 spectral bands:\n\nB1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B11, and B12.\n\nEach band was resized to 256×256 using bilinear interpolation. Band-specific normalization was applied using predefined mean and standard deviation statistics.\n\nFor robustness, missing or unreadable bands were replaced with zero-valued arrays.\n\nDuring training, only spatial augmentations were used:\n\n* Horizontal Flip\n* Vertical Flip\n* Random Rotation\n\nNo spectral perturbation was applied because preserving physically meaningful spectral information was considered important for multispectral imagery.\n\n---\n\n## Model Architecture\n\nThe backbone of the solution is Swin Transformer V2 Tiny (swinv2_tiny_window16_256).\n\nThe original ImageNet-pretrained model accepts RGB input (3 channels). Since Sentinel imagery contains 12 channels, the patch embedding layer was modified to accept 12-band input.\n\nInstead of random initialization, pretrained RGB weights were replicated across all spectral channels. This provided a stable starting point and allowed the model to benefit from ImageNet pretraining despite the different input modality.\n\n---\n\n## Self-Supervised Learning (SimMIM)\n\nBefore supervised training, a SimMIM-inspired masked image modeling stage was performed.\n\n### Masking Strategy\n\nA random mask ratio of 60% was used. Masked regions were removed from the input image while visible regions remained unchanged.\n\nThe encoder was required to reconstruct the missing multispectral content.\n\n### Reconstruction Head\n\nA lightweight convolutional decoder was attached to the Swin encoder. PixelShuffle was used to recover full image resolution.\n\n### Loss Function\n\nOnly masked regions contributed to the reconstruction objective.\n\nAn L1 reconstruction loss was computed between the reconstructed image and the original image:\n\n* Loss evaluated only on masked pixels\n* Visible pixels ignored during optimization\n\n### Training Configuration\n\n* Optimizer: AdamW\n* Learning Rate: 5e-4\n* Epochs: 30\n\nAfter pretraining, only the encoder weights were retained. The decoder was discarded.\n\n---\n\n## Supervised Fine-Tuning\n\nThe pretrained encoder weights were loaded into a classification model.\n\nA new classification head was attached for the four disease categories:\n\n* Aphid\n* Blast\n* RPH\n* Rust\n\n### Class Imbalance Handling\n\nThe dataset exhibited noticeable class imbalance. To address this issue, weighted cross-entropy loss was used:\n\n* Aphid: 1.0\n* Blast: 4.0\n* RPH: 0.6\n* Rust: 12.0\n\nHigher weights were assigned to minority classes to improve their contribution during optimization.\n\n### Training Configuration\n\n* Optimizer: AdamW\n* Learning Rate: 1e-4\n* Scheduler: Cosine Annealing\n* Epochs: 20\n\nThe entire labeled dataset was used for supervised training.\n\n---\n\n## Inference\n\nFor inference, Test Time Augmentation (TTA) was applied.\n\nPredictions were generated from six transformed versions of each image:\n\n1. Original image\n2. Horizontal flip\n3. Vertical flip\n4. 90° rotation\n5. 180° rotation\n6. 270° rotation\n\nSoftmax probabilities from all transformations were averaged, and the final class prediction was obtained using argmax.\n\n---\n\n## Final Pipeline\n\nSentinel-2 Multispectral Images\n\n→ Band Normalization\n\n→ SimMIM Self-Supervised Pretraining\n\n→ Swin Transformer Encoder\n\n→ Supervised Fine-Tuning\n\n→ Class-Weighted Cross-Entropy\n\n→ Test Time Augmentation\n\n→ Final Prediction\n\n---\n\n## Conclusion\n\nThe most important component of the solution was the self-supervised pretraining stage. By leveraging all available imagery through masked image modeling, the Swin encoder learned useful spectral representations before receiving class labels.\n\nCombined with class-weighted fine-tuning and test-time augmentation, this approach produced a robust classification pipeline for multispectral crop disease recognition.\n",
      "votes": 1
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "3467709": "## Overview\n\nOur solution follows a two-stage training strategy combining self-supervised learning and supervised fine-tuning. Since the competition dataset contains multispectral Sentinel imagery with limited labeled samples, we first learned general spectral representations using a SimMIM-style masked image modeling task and then fine-tuned the pretrained encoder for disease classification.\n\nThe final pipeline consists of:\n\n1. Multispectral preprocessing and normalization\n2. Self-supervised pretraining with SimMIM\n3. Supervised fine-tuning using class-weighted cross-entropy\n4. Test-time augmentation (TTA) during inference\n\n---\n\n## Data Preparation\n\nThe dataset consists of Sentinel imagery containing 12 spectral bands:\n\nB1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B11, and B12.\n\nEach band was resized to 256×256 using bilinear interpolation. Band-specific normalization was applied using predefined mean and standard deviation statistics.\n\nFor robustness, missing or unreadable bands were replaced with zero-valued arrays.\n\nDuring training, only spatial augmentations were used:\n\n* Horizontal Flip\n* Vertical Flip\n* Random Rotation\n\nNo spectral perturbation was applied because preserving physically meaningful spectral information was considered important for multispectral imagery.\n\n---\n\n## Model Architecture\n\nThe backbone of the solution is Swin Transformer V2 Tiny (swinv2_tiny_window16_256).\n\nThe original ImageNet-pretrained model accepts RGB input (3 channels). Since Sentinel imagery contains 12 channels, the patch embedding layer was modified to accept 12-band input.\n\nInstead of random initialization, pretrained RGB weights were replicated across all spectral channels. This provided a stable starting point and allowed the model to benefit from ImageNet pretraining despite the different input modality.\n\n---\n\n## Self-Supervised Learning (SimMIM)\n\nBefore supervised training, a SimMIM-inspired masked image modeling stage was performed.\n\n### Masking Strategy\n\nA random mask ratio of 60% was used. Masked regions were removed from the input image while visible regions remained unchanged.\n\nThe encoder was required to reconstruct the missing multispectral content.\n\n### Reconstruction Head\n\nA lightweight convolutional decoder was attached to the Swin encoder. PixelShuffle was used to recover full image resolution.\n\n### Loss Function\n\nOnly masked regions contributed to the reconstruction objective.\n\nAn L1 reconstruction loss was computed between the reconstructed image and the original image:\n\n* Loss evaluated only on masked pixels\n* Visible pixels ignored during optimization\n\n### Training Configuration\n\n* Optimizer: AdamW\n* Learning Rate: 5e-4\n* Epochs: 30\n\nAfter pretraining, only the encoder weights were retained. The decoder was discarded.\n\n---\n\n## Supervised Fine-Tuning\n\nThe pretrained encoder weights were loaded into a classification model.\n\nA new classification head was attached for the four disease categories:\n\n* Aphid\n* Blast\n* RPH\n* Rust\n\n### Class Imbalance Handling\n\nThe dataset exhibited noticeable class imbalance. To address this issue, weighted cross-entropy loss was used:\n\n* Aphid: 1.0\n* Blast: 4.0\n* RPH: 0.6\n* Rust: 12.0\n\nHigher weights were assigned to minority classes to improve their contribution during optimization.\n\n### Training Configuration\n\n* Optimizer: AdamW\n* Learning Rate: 1e-4\n* Scheduler: Cosine Annealing\n* Epochs: 20\n\nThe entire labeled dataset was used for supervised training.\n\n---\n\n## Inference\n\nFor inference, Test Time Augmentation (TTA) was applied.\n\nPredictions were generated from six transformed versions of each image:\n\n1. Original image\n2. Horizontal flip\n3. Vertical flip\n4. 90° rotation\n5. 180° rotation\n6. 270° rotation\n\nSoftmax probabilities from all transformations were averaged, and the final class prediction was obtained using argmax.\n\n---\n\n## Final Pipeline\n\nSentinel-2 Multispectral Images\n\n→ Band Normalization\n\n→ SimMIM Self-Supervised Pretraining\n\n→ Swin Transformer Encoder\n\n→ Supervised Fine-Tuning\n\n→ Class-Weighted Cross-Entropy\n\n→ Test Time Augmentation\n\n→ Final Prediction\n\n---\n\n## Conclusion\n\nThe most important component of the solution was the self-supervised pretraining stage. By leveraging all available imagery through masked image modeling, the Swin encoder learned useful spectral representations before receiving class labels.\n\nCombined with class-weighted fine-tuning and test-time augmentation, this approach produced a robust classification pipeline for multispectral crop disease recognition.\n"
  }
}