salahkhenfer/pear-pests-dataset
๐ Pear Leaf Pest & Disease Detection Dataset This dataset supports object detection for pear leaf health monitoring: locating and classifying an insect pest and fungal/bacterial disease lesions directly on pear leaf images. It targets the timely detection and localization of foliar pear pests and diseases central to precision agriculture, where manual agronomist inspection is labor-intensive, subjective, and hard to scale. The dataset consists of 2,210 annotated images (1,542โฆ See the full description on the dataset page: https://huggingface.co/datasets/salahkhenfer/pear-pests-dataset.
๐ Pear Leaf Pest & Disease Detection Dataset
This dataset supports object detection for pear leaf health monitoring: locating and classifying an insect pest and fungal/bacterial disease lesions directly on pear leaf images. It targets the timely detection and localization of foliar pear pests and diseases central to precision agriculture, where manual agronomist inspection is labor-intensive, subjective, and hard to scale.
The dataset consists of 2,210 annotated images (1,542 train / 668 validation) with 3,386 bounding-box annotations across 6 classes: one pest (beetle) and four diseases (black block, dry blight, rust, scab), plus a health class for undamaged leaves. Images were aggregated from publicly available online sources across multiple websites and depict pear leaves under natural field conditions with varied illumination, backgrounds, and leaf orientations. Near-duplicate images were removed by manual visual inspection before the train/validation split (no image appears in both partitions), and every retained image was re-annotated from scratch by the authors with axis-aligned bounding boxes directly in COCO format โ source annotations, where any existed, were not reused.
This dataset is the benchmark used in "Low-rank adaptation of frozen vision foundation models for object detection: a plant disease case study" (Liu, Khenfer, Mekhalfi & Shi, SPIE, 2026 โ see Citation), which compares LoRA-adapted vision foundation-model backbones (self-supervised DINOv2 and the DaViT encoder of Florence-2) against conventional YOLO26 detectors for six-category pear leaf pest/disease detection. The best reported configuration (DaViT-base, LoRA rank 32) reaches an F1-score of 0.8769 and mAP@0.5 of 0.9171 while training under 3% of the backbone weights.
๐๏ธ Classes & annotation counts
Each instance contains:
- image: an RGB photo of a pear leaf.
- image_id / file_name: identifiers for the source image.
- width / height: original image dimensions in pixels.
- objects: a list of bounding-box annotations for that image, each with:
id: annotation idbbox:[x_min, y_min, width, height]in absolute pixel coordinates (COCO format)area: box area in pixelsยฒcategory: class label (see table above)
๐ท๏ธ Annotation Format
Annotations were authored directly in COCO bounding-box format by the dataset's authors โ not sourced or reused from any origin site โ and converted 1:1 into this release: bbox values here are unchanged [x, y, w, h] pixel coordinates, so no rescaling is needed beyond what your training pipeline already expects.
๐งช How to read and display examples
from datasets import load_dataset
from PIL import ImageDraw
DATASET_NAME = "salahkhenfer/pear-pests-dataset"
SAMPLE_INDEX = 0
OUTPUT_IMAGE = "annotated_pear.png"
if __name__ == "__main__":
dataset = load_dataset(DATASET_NAME)
split = "train" if "train" in dataset else list(dataset.keys())[0]
sample = dataset[split][SAMPLE_INDEX]
class_names = dataset[split].features["objects"].feature["category"].names
image = sample["image"].convert("RGB")
draw = ImageDraw.Draw(image)
for bbox, category in zip(sample["objects"]["bbox"], sample["objects"]["category"]):
x, y, w, h = bbox
draw.rectangle([x, y, x + w, y + h], outline=(255, 0, 0), width=3)
draw.text((x, max(0, y - 12)), class_names[category], fill=(255, 0, 0))
image.save(OUTPUT_IMAGE)
print(f"Annotated image saved as {OUTPUT_IMAGE}")๐๏ธ Training
Two small, function-by-function reference scripts reproduce the paper's core recipe โ a frozen vision backbone with LoRA adapters, feeding a COCO-pretrained Deformable-DETR head โ for its two backbone families. Both default to the paper's best-reported configuration for their family. See `requirements-train.txt` and each script's own docstring for setup notes and the simplifications made versus the full paper pipeline.
- `train_lora_pear.py` โ DINOv2 backbone (paper's best DINO config:
dinov2-small, rank 32 โ mAP@0.5 0.8768). - `train_lora_pear_florence.py` โ Florence-2/DaViT backbone (paper's best overall config: DaViT-base, rank 32 โ F1 0.8769, mAP@0.5 0.9171). This one is more fragile: Florence-2's DaViT ships as custom Hub "remote code" with no stable API for pulling out multi-scale features, so getting the real Florence-2 weights running may need a small manual fix โ see the script's docstring and its
--debugflag. A more reliable (but ImageNet- rather than Florence-2-pretrained) fallback is built in via--source timm.
pip install -r requirements-train.txt
python train_lora_pear.py --rank 32 --epochs 10
python train_lora_pear_florence.py --source florence2 --rank 32 --epochs 10 # or --source timm for the reliable fallback๐ Citation
If you use this dataset, please cite the accompanying paper:
@article{liu2026lora,
title = {Low-rank adaptation of frozen vision foundation models for object detection: a plant disease case study},
author = {Liu, Fuyong and Khenfer, Salah Eddine and Mekhalfi, Mohamed Lamine and Shi, Mingdeng},
journal = {SPIE},
year = {2026}
}