DOI: 10.5281/zenodo.17653873
title: Annotation-Efficient Weed Mapping in Sorghum Fields Using Two-Stage U-Net Crop Segmentation and HSV Greenness Analysis

description: my-project/│├── README.md                  ← General description and usage│├── install/│   ├── install.sh             ← Script to install Anaconda│   └── installEnv.sh          ← Create environment and install dependencies│├── dataset/│   ├── trainval/              ← Training + validation patches (BBCH 17, 256×256, augmented)│   │   ├── img/               ← 31,680 RGB patches (JPG)│   │   ├── mask/              ← 31,680 multiclass RGB masks (PNG)│   │   │                          Classes: crop, weed, background│   │   │                          COLOR_CROP       = (31, 119, 180)│   │   │                          COLOR_BACKGROUND = (199, 199, 199)│   │   │                          COLOR_WEED       = (14, 127, 255)│   │   ├── mask_crop/         ← 31,680 crop binary masks (PNG)│   │   └── mask_weed/         ← 31,680 weed binary masks (PNG)│   ││   ├── test/                  ← Test patches (BBCH 17)│   │   ├── img/               ← 2,310 RGB patches (JPG)│   │   ├── mask/              ← 2,310 multiclass RGB masks (PNG)│   │   ├── mask_crop/         ← 2,310 crop binary masks (PNG)│   │   └── mask_weed/         ← 2,310 weed binary masks (PNG)│   ││   └── test_different_bbch/│       ├── bbch15_patch/│       │   ├── img/           ← 110 RGB patches (JPG)│       │   ├── mask/          ← 110 multiclass masks (PNG)│       │   ├── mask_crop/     ← 110 crop binary masks (PNG)│       │   └── mask_weed/     ← 110 weed binary masks (PNG)│       └── bbch19_patch/│           ├── img/           ← 110 RGB patches (JPG)│           ├── mask/          ← 110 multiclass masks (PNG)│           ├── mask_crop/     ← 110 crop binary masks (PNG)│           └── mask_weed/     ← 110 weed binary masks (PNG)│├── models/│   ├── resnet.py              ← U-Net with ResNet encoders (18, 34, 50, 101, 152)│   ├── densenet.py            ← U-Net with DenseNet encoders (121, 161, 169, 201)│   ├── efficientnet.py        ← U-Net with EfficientNet encoders (B0–B7)│   ├── swin.py                ← U-Net with Swin Transformer encoders (swin_t, swin_s)│   └── vit.py                 ← U-Net with Vision Transformer encoders (ViT_B_16, ViT_B_32)│├── dataloader.py              ← Dataloaders, batch size, train/validation splits├── metrics.py                 ← Focal loss, accuracy, recall, precision, F1-score, IoU, Dice score│├── train.py                   ← Sequential training of all backbones with cross-validation;│                               best model selected by validation focal loss│├── test_binary_crop.py        ← Evaluate best crop model on BBCH 17 test set and save predicted│                               crop binary masks and crop-removed RGB images│├── HSV_filtering.py           ← Apply HSV thresholding and small-object removal on crop-removed│                               images to detect weeds and save weed masks + metrics│├── combining_masks.py         ← Combine predicted crop and weed binary masks into a single│                               multiclass RGB mask (crop, weed, background) using:│                               COLOR_CROP       = (31, 119, 180)│                               COLOR_BACKGROUND = (199, 199, 199)│                               COLOR_WEED       = (14, 127, 255)│└── test_multi_class.py        ← Evaluate reconstructed multiclass predictions against ground truth                                and report macro-averaged metrics + confusion matrix (%)