CoolFace
Datasetpublic

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.

sourceHugging Facecc-by-4.0updated 1mo agoView on Hugging Face
0likes122downloads
Dataset Card

๐Ÿ 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

#ClassTrain boxesValidation boxes
0beetle16167
1black block901387
2dry blight359147
3health419139
4rust314165
5scab191136

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 id
  • โ€”bbox: [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

python
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 --debug flag. A more reliable (but ImageNet- rather than Florence-2-pretrained) fallback is built in via --source timm.
bash
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:

bibtex
@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}
}