Source code of paddylitex-disease-detection, also published at https://github.com/WAYTECHG/paddylitex-disease-detection

PaddyLiteX — Efficient Paddy Leaf Disease Detection

A lightweight dense backbone for nine-class paddy leaf disease detection.

Custom model design · controlled architecture comparisons · browser-based inference

Live demo on Render PaddyLiteX on Hugging Face Final year thesis research
Example setup: Python 3.10 Example setup: PyTorch 2.5.1 YOLOv8n-based detector Custom DenseLiteX backbone ONNX Runtime Web

Overview · Architecture · Results · Ablations · Dataset · Quick start · Demo

Wilbert Andrew Yonathan
Bachelor of Engineering in Artificial Intelligence · Xiamen University Malaysia

Overview

PaddyLiteX studies how to retain useful disease-detection performance while reducing the cost of a DenseNet121-based YOLOv8n integration. Its proposed detector combines a custom DenseLiteX backbone, Spatial Pyramid Pooling Fast (SPPF) and C2PSA attention, followed by a YOLOv8-style neck and three-scale detection head.

The repository brings together custom model modules, architecture configurations, training and evaluation scripts, component ablations and an interactive website for comparing predictions on the same uploaded image.

Architecture research Measured comparison Interactive application
Reduced dense-block depth, growth rate and bottleneck expansion Precision, recall, mAP, parameters and GFLOPs Baseline, initial proposed and final proposed predictions on one image
DenseLiteX with SPPF and C2PSA refinement Baseline, initial proposed model and two component-ablation groups Annotated boxes, metric charts and class-level comparisons
P3, P4 and P5 features for three-scale detection 803 test images and 2,466 annotated objects Exported ONNX models executed in the browser

The central result: compared with the initial proposed YOLOv8n + DenseNet121 model, the final proposed detector uses 68.01% fewer parameters and 72.59% lower reported GFLOPs, with 0.98 percentage points higher mAP@0.5. This is a measured trade-off: it does not outperform every reference model on every metric.

Architecture

Proposed detector: DenseLiteX + SPPF + C2PSA

Model configuration: YOLOv8n_DenseLiteX_SPPF_C2PSA.

The dense backbone reuses features through concatenation. Its three projected outputs enter the YOLOv8-style feature pyramid; the deepest output is refined by SPPF and C2PSA before aggregation.

flowchart LR
    I["Rice leaf image<br/>640 × 640 × 3"] --> B["DenseLiteX backbone<br/>blocks 6 / 8 / 12 / 6 · growth rate 20"]
    B --> P3["P3 · stride 8<br/>80 × 80 × 64"]
    B --> P4["P4 · stride 16<br/>40 × 40 × 128"]
    B --> P5["P5 · stride 32<br/>20 × 20 × 256"]
    P5 --> S["SPPF"] --> A["C2PSA"]
    P3 --> N["YOLOv8 neck<br/>top-down + bottom-up aggregation"]
    P4 --> N
    A --> N
    N --> H["Three-scale detect head<br/>strides 8 / 16 / 32"]
    H --> O["Bounding boxes<br/>+ nine-class predictions"]
    classDef input fill:#F2F6F0,stroke:#879B7C,color:#26372C
    classDef backbone fill:#E4F2E8,stroke:#39835B,color:#173F2D
    classDef refinement fill:#FFF2D2,stroke:#C9A348,color:#624C1B
    classDef detector fill:#EAEFF8,stroke:#7089AF,color:#263E60
    class I,O input
    class B,P3,P4,P5 backbone
    class S,A refinement
    class N,H detector

Proposed DenseLiteX backbone with four dense blocks, P3/P4/P5 projections, SPPF, C2PSA, YOLOv8 neck and three-scale detection head

Proposed architecture supplied with the thesis. Select the image to inspect the full-resolution diagram. Diagrams illustrate the design; the model YAMLs and custom modules define the executable implementation.

Component Proposed configuration Purpose
DenseLiteX Blocks [6, 8, 12, 6]; growth rate 20 Dense feature reuse with reduced backbone size
Dense layers Bottleneck multiplier 2; dropout 0.0 Compact intermediate feature transformations
Output projections 64 / 128 / 256 channels at strides 8 / 16 / 32 Match the three neck inputs
SPPF Deepest P5 feature map Spatial context aggregation
C2PSA After SPPF Attention-based feature refinement
Neck Top-down and bottom-up paths; C2f × 1 per aggregation block Fuse features across scales
Detection head Three scales; nine classes Predict bounding boxes and class scores

Implementation: custom dense modules · proposed model YAML.

Baseline and initial proposed architectures

Baseline — YOLOv8n · expand architecture

The original YOLOv8n detector provides the reference for a compact, conventional backbone with its feature pyramid and three-scale detection head.

Baseline YOLOv8n backbone, SPPF, neck and three-scale detection head

Architecture configuration.

Initial proposed — YOLOv8n + DenseNet121 · expand architecture

This integration uses dense blocks [6, 12, 24, 16] and growth rate 32. Projected P3/P4/P5 features feed the detection neck. Its larger backbone provides the principal comparison for the proposed reduction in parameters and GFLOPs.

DenseNet121-based YOLOv8n integration with dense blocks, transition layers and output projections

Architecture configuration.

Contribution boundary: DenseLiteX is the backbone configuration developed in this project. SPPF, C2PSA, dense connectivity and the underlying YOLO components are existing methods. The thesis evaluates their integration and resulting performance–complexity trade-off.

Reported results

Evaluation covers nine classes, 803 test images and 2,466 annotated objects. Custom-model results correspond to the updated C2f × 1 configurations. Higher precision, recall and mAP are better; lower parameters and GFLOPs indicate lower reported model complexity.

Model Precision (%) Recall (%) mAP@0.5 (%) mAP@0.5:0.95 (%) Parameters GFLOPs
YOLOv8n · Baseline 81.24 78.45 80.94 54.72 3,007,403 8.1
YOLOv8n + DenseNet121 · Initial proposed 84.71 74.79 80.69 56.08 9,002,123 51.8
DenseLiteX + SPPF + C2PSA (PaddyLiteX) · Final proposed 83.29 75.67 81.67 55.83 2,879,917 14.2

What the comparison shows

Final proposed model compared with mAP@0.5 mAP@0.5:0.95 Parameters Reported GFLOPs
YOLOv8n baseline +0.73 pp +1.11 pp 4.24% fewer 75.31% higher
Initial proposed (DenseNet121) +0.98 pp −0.25 pp 68.01% fewer 72.59% lower

The proposed model offers lower complexity than the DenseNet121 integration. Against the original YOLOv8n, it has slightly fewer parameters and higher mAP, but higher GFLOPs, lower recall (75.67% vs 78.45%), though higher precision (83.29% vs 81.24%). GFLOPs do not establish wall-clock inference speed; no measured latency or FPS advantage is claimed here.

Ablation studies

DenseLiteX components

Configuration Precision (%) Recall (%) mAP@0.5 (%) mAP@0.5:0.95 (%) Parameters GFLOPs
DenseLiteX 82.67 71.84 78.82 49.16 2,467,373 13.9
DenseLiteX + SPPF 83.67 73.82 79.94 53.92 2,631,597 14.0
DenseLiteX + C2PSA 78.95 73.47 78.39 50.82 2,715,693 14.1
DenseLiteX + SPPF + C2PSA 83.29 75.67 81.67 55.83 2,879,917 14.2

The combined configuration leads this group in recall and both mAP metrics. C2PSA alone reduces mAP@0.5 relative to DenseLiteX, while adding it after SPPF improves the score. This suggests a possible component interaction; one run per architecture does not establish a reliable mechanism or statistical significance.

DenseNet121 components · expand the second ablation group
Configuration Precision (%) Recall (%) mAP@0.5 (%) mAP@0.5:0.95 (%) Parameters GFLOPs
DenseNet121 84.71 74.79 80.69 56.08 9,002,123 51.8
DenseNet121 + SPPF 85.46 77.80 81.92 57.18 9,166,347 51.9
DenseNet121 + C2PSA 87.19 76.51 82.55 57.75 9,250,443 52.0
DenseNet121 + SPPF + C2PSA 83.81 79.01 82.25 58.30 9,414,667 52.1

DenseNet121 + C2PSA has the highest mAP@0.5 in this group; the combined variant has the highest mAP@0.5:0.95. These variants remain substantially larger than the proposed model. The proposed detector is selected for its performance–complexity balance, not the highest score across every evaluated architecture.

Evaluation boundaries

  • Single reported run per architecture. Training-seed variability and confidence intervals are unavailable.
  • Percentages versus percentage points. Metric differences use percentage points; parameter and GFLOP changes use relative percentages.
  • Profiling consistency matters. Parameter and GFLOP values come from the reported model summaries. Reproduction should confirm input size, fusion policy and operation-counting convention.
  • No timing claim. Model-forward latency, full-pipeline latency and website loading time are different measurements; none is established by the GFLOP table.
  • Completed versus exploratory work. The tables identify reported evaluations. An available YAML does not establish that its experiment was completed.

Dataset

The task includes nine labelled classes, including Healthy.

Class ID Label
0 Rice__BacterialLeafBlight
1 Rice__BrownSpot
2 Rice__Healthy
3 Rice__Hispa
4 Rice__LeafBlast
5 Rice__LeafScald
6 Rice__LeafSmut
7 Rice__NarrowBrownLeafSpot
8 Rice__NeckBlast
Split Images / label files Annotated objects
Training 5,567 17,451
Validation 1,587 5,279
Test 803 2,466
Total 7,957 25,196

Example source images are available from the Rice Leaf Diseases dataset on Kaggle. Reproducing the reported detection results also requires the same bounding-box annotations and split assignments. Downloading source images alone is insufficient.

Expected local dataset layout
datasets/rice_yolo_split/
├── images/
│   ├── train/
│   ├── val/
│   └── test/
└── labels/
    ├── train/
    ├── val/
    └── test/

Each image needs a corresponding YOLO .txt label file, with class IDs matching the table. data/paddy.yaml uses the relative path datasets/rice_yolo_split, so run the scripts from the repository root, or edit that path: line to point elsewhere. Dataset images are not included in this repository. Trained weights are published separately (see Trained weights).

Quick start

1. Clone and prepare the environment

git clone https://github.com/WAYTECHG/paddylitex-disease-detection.git
cd paddylitex-disease-detection

Reuse the existing paddy_yolo environment if available. Otherwise, the following is an example Python 3.10 / CUDA 12.1 setup, not a recovered lockfile of the original training environment. The version badges refer to this example.

conda create -n paddylitex python=3.10 -y
conda activate paddylitex
$env:PYTHONNOUSERSITE = "1"

python -m pip install torch==2.5.1 torchvision==0.20.1 --index-url https://download.pytorch.org/whl/cu121
python -m pip install -r requirements.txt
python -m pip check

For different hardware, use the official PyTorch installation selector. Preserve the versions in an already working research environment where possible.

Verify that Python loads the repository's customized Ultralytics package:

python -c "import torch, ultralytics; print('Ultralytics:', ultralytics.__file__); print('CUDA:', torch.cuda.is_available())"

The package path should resolve inside this clone. Run commands from the repository root and retain the custom modules rather than substituting an unrelated pip Ultralytics installation. Use --device 0 for a supported GPU or --device cpu.

2. Train the proposed model

Configure data/paddy.yaml first. This command illustrates 300 epochs, 640-pixel inputs, batch size 8, seed 42 and early stopping disabled (--patience 0). Other settings follow the thesis training set-up.

python train.py --model cfg/training/yolov8n_denselitex_sppf_c2psa.yaml --data data/paddy.yaml --epochs 300 --imgsz 640 --batch 8 --device 0 --seed 42 --patience 0 --name yolov8n_denselitex_sppf_c2psa
Train the baseline and initial proposed model
python train.py --model cfg/training/yolov8n.yaml --data data/paddy.yaml --epochs 300 --imgsz 640 --batch 8 --device 0 --seed 42 --patience 0 --name yolov8n

python train.py --model cfg/training/yolov8n_densenet121.yaml --data data/paddy.yaml --epochs 300 --imgsz 640 --batch 8 --device 0 --seed 42 --patience 0 --name yolov8n_densenet121

The examples initialize from architecture YAMLs without --pretrained. Keep settings consistent across comparisons. For an ablation, substitute its YAML and choose a distinct run name.

3. Evaluate and predict

python test.py --weights runs/train/yolov8n_denselitex_sppf_c2psa/weights/best.pt --data data/paddy.yaml --split test --imgsz 640 --batch 1 --workers 4 --device 0 --name yolov8n_denselitex_sppf_c2psa

python detect.py --weights runs/train/yolov8n_denselitex_sppf_c2psa/weights/best.pt --source datasets/rice_yolo_split/images/test --imgsz 640 --conf 0.25 --device 0 --name proposed_demo

Use the actual checkpoint path printed by training: an existing run directory can cause a numbered suffix. train.py and test.py use data/paddy.yaml by default.

Trained weights

The best.pt checkpoint and results.csv training log of each of the nine architectures in the thesis are attached to the v1.0 release. Each model was trained from scratch for 300 epochs (batch size 8, seed 42, early stopping disabled), one run per architecture.

Release file Architecture
yolov8n.pt YOLOv8n baseline
yolov8n_densenet121.pt YOLOv8n + DenseNet121 (initial proposed)
yolov8n_densenet121_sppf.pt, ..._c2psa.pt, ..._sppf_c2psa.pt DenseNet121 with SPPF, C2PSA, or both
yolov8n_denselitex.pt DenseLiteX backbone only
yolov8n_denselitex_sppf.pt, ..._c2psa.pt DenseLiteX with SPPF or C2PSA
yolov8n_denselitex_sppf_c2psa.pt PaddyLiteX (final proposed)

These checkpoints load only with the customized ultralytics/ folder in this repository, because they contain the custom dense-backbone classes. Run from the repository root so Python imports the local copy; the pip ultralytics package cannot read them.

python -c "import ultralytics; print(ultralytics.__file__)"   # must print a path inside this repository
python test.py --weights yolov8n_denselitex_sppf_c2psa.pt --data data/paddy.yaml --split test --imgsz 640 --batch 1 --device 0 --name verify_proposed

The proposed model should report precision 0.8329, recall 0.7567, mAP50 0.8167 and mAP50-95 0.5583 (2,879,917 parameters, 14.2 GFLOPs) on the 803-image test subset. Parameter counts are those of the fused model, as printed by the Ultralytics summary.

Reproduction and environment notes

The supplied README records a dependency-resolution dry run for CPython 3.11 on Windows x86-64 on 12 October 2026. It did not install dependencies or execute training/inference. A resolver check is not an end-to-end reproduction.

Interactive demo

Open Render · Open Hugging Face

The static comparison application runs exported ONNX models in the visitor's browser through ONNX Runtime Web. It supports same-image predictions from the baseline, the initial proposed model and the final proposed model, with annotated detections, aggregate charts, performance–complexity plots, class-level comparisons and ablation results.

Research workflow Browser demonstration
Customized Python / Ultralytics implementation Static HTML, JavaScript and ONNX Runtime Web
Train and evaluate .pt checkpoints Execute exported ONNX models
Requires the matching dataset, annotations and environment Requires the exported models and runtime assets
Produces the reported evaluation metrics Displays predictions and previously measured results

Serve the existing static website locally:

python -m http.server 8000 --directory PaddyLiteX_HF_Static

Open http://localhost:8000. Python research dependencies are unnecessary for serving the static files; model/runtime assets must still be available for detection. Updating chart data does not replace an ONNX model. A single uploaded image produces predictions, not a new measurement of dataset-level mAP.

Repository guide

Path Purpose
cfg/training/ Baseline, proposed, ablation and DenseLiteX exploration-trial model YAMLs
ultralytics/ Customized framework and dense-backbone implementation
data/paddy.yaml Dataset root and class labels
train.py Training entry point
test.py Validation/test evaluation entry point
detect.py Local predictions and saved annotations
audit.py Filename/label consistency inspection; configure its local dataset root
PaddyLiteX_HF_Static/ Static demo, evaluation data and browser ONNX assets
requirements.txt Research/runtime dependency definitions
assets/ README banner and three architecture diagrams

DenseLiteX exploration trials

Five backbone settings were tried while developing DenseLiteX (thesis Table 4.8). The selected one is E03, which is the configuration of yolov8n_denselitex.yaml and has no separate E03 file. The other four have their own YAMLs. Each trial was trained once (300 epochs, batch size 8, seed 42, no early stopping), and the selection used validation results and model complexity, not the testing subset.

Trial Dense blocks Bottleneck factor Growth rate Config file
E01 6, 12, 24, 16 4 20 E01_yolov8n_dense_b6_12_24_16_bn4.yaml
E02 6, 8, 12, 6 4 20 E02_yolov8n_dense_b6_8_12_6_bn4.yaml
E03 (selected) 6, 8, 12, 6 2 20 yolov8n_denselitex.yaml
E04 6, 8, 12, 6 1 20 E04_yolov8n_dense_b6_8_12_6_bn1.yaml
E05 4, 6, 8, 4 2 20 E05_yolov8n_dense_b4_6_8_4_bn2.yaml

The trials are not part of the nine reported architectures, and no result in this README depends on them.

Author and acknowledgments

Wilbert Andrew Yonathan · Xiamen University Malaysia
Bachelor of Engineering in Artificial Intelligence · Final Year Thesis

Project contributions include the custom DenseNet-based detector integration, DenseLiteX configuration, SPPF/C2PSA experiments and their evaluation. The browser demo is included for demonstration only and is not part of the research contribution. The work builds on Ultralytics YOLO, DenseNet and ONNX Runtime Web. Upstream modules remain credited to their original authors.

Licensing

See the author's MIT license and the bundled Ultralytics AGPL-3.0 license. The root MIT license does not relicense upstream code. Preserve third-party notices; dataset terms apply separately to images and annotations.


PaddyLiteX
Dense feature reuse. Measured trade-offs. Reproducible research.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for Wizzas/paddylitex-disease-detection