$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Dataset description
The WinterCropWeedDB dataset consists of 1,136 high-resolution (red, green, blue) RGB images of six winter crop species (wheat, chickpea, pea, lentil, mustard, and grass pea) and four weed species (common vetch, lesser canary grass, goosefoot (Chenopodium album), and Euphorbia clementei) taken from winter agricultural fields in the state of Chhattisgarh, India (Figure 1). The images were taken under natural conditions, including varying illumination, growth stages, and background complexity. All images were initially unannotated and used only for self-supervised pretraining. For supervised fine-tuning, the images were manually annotated and split using stratified sampling into training (70%) and validation (30%) sets. The validation set was used only for internal model evaluation and was not augmented. To address class imbalance and robustness issues during training, data augmentation was performed only on the training set. The augmentation techniques involved random rotations (+/-20°), horizontal flipping, scaling, translation, brightness changes, and mild affine transformations. The training samples were augmented to a target of 150 images per class, resulting in a total of 1,500 training images, while the validation set consisted of 347 original images. No augmented or synthetic images were included in the validation set to prevent evaluation bias. Besides the hold-out evaluation, a stratified five-fold cross-validation was also performed on the original labeled dataset as a secondary analysis. In each fold, data augmentation was done only on the training sets, and the validation sets were kept unchanged to maintain consistency with the main evaluation scheme.
Computational workflow for self-supervised and supervised model training
A two-step computational pipeline was used to investigate the viability of integrating self-supervised representation learning and supervised fine-tuning for winter crop vs. weed image classification (Figure 2). This pipeline involves: (i) self-supervised pretraining with unlabeled images, and (ii) supervised fine-tuning with a labeled sample of the images. All images were resized to 300 × 300 pixels and normalized before training. Evaluations of the models were conducted only on one internal split, without using an external test set.
Stage 1 - self-supervised pretraining
In the initial stage, the EfficientNet-B3 architecture was employed as the backbone network in a self-supervised learning setup inspired by SimCLR. The two-layer projection head reduced the backbone representation to a 128-dimensional embedding space. For self-supervised learning, each image was converted into two views using random resized cropping, horizontal flipping, color transformation, Gaussian blurring, and converting to grayscale. The two views were processed together to jointly optimize the contrastive loss function. The self-supervised learning process was performed for 30 epochs, where one epoch denotes a complete pass of the entire training dataset through the model during optimization, with a batch size of 16 images using the Adam optimizer (an adaptive gradient-based optimization algorithm that estimates first- and second-order moments of the gradients to adjust learning rates during training). Gradient clipping with a maximum norm of 1.0 was used to ensure stable training. Additionally, model checkpoints were saved after every epoch to facilitate reproducibility. The temperature value of 0.5 was used while computing the InfoNCE loss during self-supervised learning.
Stage 2 - supervised fine-tuning
After self-supervised pretraining, the projection head was removed, and the pretrained backbone weights were used for supervised fine-tuning. A fully connected classifier head was added to the backbone for multi-class classification. Fine-tuning was done using only the labeled images from the training set. Supervised training used cross-entropy loss with class weighting and label smoothing to handle class imbalance. The Adam optimizer was used with different learning rates for the backbone (1 × 10⁻⁵) and classifier (1 × 10⁻⁴). A learning rate scheduler was used to decrease the learning rate when the validation accuracy plateaued. Training was done for 20 epochs, and the model checkpoint with the highest validation accuracy was saved for evaluation.
In addition to the main hold-out evaluation, a stratified five-fold cross-validation was carried out as an additional analysis on the labeled set. In each fold, the augmentation was only done on the training sets, and the validation sets were left unchanged. The results of the cross-validation were presented separately and were not used for model selection or optimization of the checkpoints. The performance metrics presented in this study are based solely on the internal validation split and represent the results of the observed performance under the current experimental setup.
Grad-CAM and Grad-CAM++ visualization
For the qualitative analysis of attention in the model, gradient-based class activation mapping methods (Grad-CAM and Grad-CAM++) were used on the fine-tuned model. The feature maps and the gradients were obtained from the final convolutional layer of the base network, and class-specific heatmaps were obtained for chosen validation images. These were used only for the purpose of qualitative analysis of the model and were not validated. The Table of materials lists all the hardware, software libraries, datasets, and custom training scripts used in this workflow.