# CMC PlantWild_v2 reproducibility package

Reproducibility materials for the study:

**Resolution–Compression Trade-Offs in In-the-Wild Plant Disease Classification: Accuracy, Reliability, and Inference Efficiency**

Author: **Seweryn Lipiński**  
Affiliation: Faculty of Technical Sciences, University of Warmia and Mazury in Olsztyn, Poland

Version: **1.0.0**  
Release date: **2026-11-10**

## Purpose

This package contains the code, processed split information, duplicate-audit records, benchmark metadata, and compact result tables needed to reproduce the experimental protocol and the revision analyses reported in the associated manuscript.

The package does **not** redistribute PlantWild_v2 images, trained model checkpoints, or full prediction/logit archives.

## Source dataset

PlantWild / PlantWild_v2 is available from the original repository:

https://huggingface.co/datasets/uqtwei2/PlantWild

The source dataset is distributed by its creators under **CC BY-NC-ND 4.0**. Users of this package must obtain PlantWild_v2 from the original source and comply with its license terms.

## Experimental scope

The study evaluates:

- MobileNetV3-Small, EfficientNet-B0, and ResNet-18;
- input resolutions 64, 96, 128, 160, and 224 px;
- training seeds 42, 123, and 2026;
- nominal evaluation and JPEG Q100, Q75, Q50, Q25, and Q10;
- accuracy, macro-F1, and balanced accuracy;
- ECE, Brier score, NLL, temperature scaling, and selective prediction;
- encoded image size, MACs/FLOPs, parameter count, checkpoint size, GPU latency, throughput, and Pareto analysis;
- paired class-stratified atomic-group bootstrap uncertainty analysis;
- class-specific JPEG degradation and calibration by class-support group.

## Directory structure

```text
CMC_PlantWildV2_Reproducibility_v1.0.0/
├── README.md
├── CITATION.cff
├── requirements.txt
├── environment_final.json
├── ZENODO_METADATA.md
├── LICENSE_CODE.txt
├── LICENSE_RESULTS.txt
├── LICENSE_PLANTWILD_METADATA.txt
├── SHA256SUMS.txt
├── scripts/
├── audit/
└── results/
```

### `scripts/`

- `02_check_duplicates.py` — image readability checks, SHA-256 exact duplicates, dHash near-duplicate candidates.
- `03_prepare_duplicate_review.py` — prepares the manual cross-class near-duplicate review workbook.
- `04_finalize_clean_split.py` — applies exact/near-duplicate decisions and generates the deterministic group-aware 70/15/15 split.
- `05_baseline_effnet_b0.py` — original EfficientNet-B0 baseline run.
- `06_train_matrix.py` — full 3-architecture × 5-resolution × 3-seed training matrix.
- `07_jpeg_evaluation.py` — nominal/JPEG post-hoc evaluation and encoded-size measurement.
- `08_calibration_selective.py` — temperature scaling, calibration metrics, and selective-prediction analysis.
- `09_efficiency_benchmark.py` — model-forward GPU efficiency benchmark.
- `10_final_tradeoff_analysis.py` — aggregation, Pareto analysis, and final trade-off figures/tables.
- `10_bootstrap_statistics.py` — paired class-stratified atomic-group bootstrap used in the revision.
- `11_class_specific_degradation.py` — class-specific JPEG degradation, support analysis, and calibration-by-support analysis used in the revision.

Scripts `05`–`10_final_tradeoff_analysis.py` preserve the project root used for the reported experiments (`C:\Research\CMC`) in their source. For reproduction on another system, update the `BASE_DIR` constant. Scripts `02`–`04` expose a `--base` option, and the revision scripts `10_bootstrap_statistics.py` and `11_class_specific_degradation.py` also accept `--base`.

### `audit/`

The audit directory contains both the inputs to the cleaning/splitting pipeline and the final processed split information.

Key files:

- `dataset_manifest.csv` — initial image manifest generated from PlantWild_v2.
- `duplicates_exact.csv` — exact duplicate groups detected with SHA-256.
- `near_duplicate_candidates.csv` — dHash candidate pairs.
- `near_cross_class_review_completed.xlsx` — completed manual decisions for the 129 cross-class candidate pairs.
- `cross_class_review_applied.csv` — reconstructed review table and decisions used by the final split script.
- `excluded_final.csv` — images excluded because of exact-label conflicts, redundant exact copies, or confirmed cross-class near duplicates.
- `manifest_final_clean.csv` — full cleaned manifest.
- `split_manifest.csv` — full cleaned manifest with atomic duplicate-group IDs and deterministic split assignment.
- `split_indices.csv` — compact canonical split file (`filepath`, class, atomic group, group size, split).
- `split_groups.csv` — atomic-group table.
- `split_by_class.csv` — class-wise split counts.
- `class_mapping.csv` — alphabetical class-to-index mapping used by the training scripts.
- `final_split_summary.txt` — audit and split summary.

Final cleaning/splitting outcome:

- initial images: 11,488;
- excluded images: 736;
- final images: 10,752;
- classes: 115;
- atomic split groups: 10,327;
- train: 7,534 images;
- validation: 1,609 images;
- test: 1,609 images;
- split seed: 42;
- no `duplicate_group_id` crosses split boundaries.

The released audit tables contain relative filenames/labels and reproducibility metadata only; source images are not included.

### `results/`

Compact outputs supporting the manuscript and revision are included, notably:

- nominal predictive performance by seed and mean ± SD;
- JPEG evaluation summaries;
- temperature-scaling and reliability summaries;
- selective-prediction operating points and summaries;
- hardware benchmark table and system metadata;
- transmission and computation Pareto frontiers;
- paired-bootstrap contrast and configuration summaries;
- class-level degradation tables;
- calibration by class-support group;
- partial rank-correlation analysis controlling for nominal class recall.

The much larger model checkpoints and per-image logit archives are intentionally omitted. They can be regenerated by running the training and evaluation scripts.

## Reproducing the split

1. Download `plantwild_v2` from the original PlantWild repository.
2. Place it under a project root, e.g. `<PROJECT>/plantwild_v2/`.
3. Copy `audit/dataset_manifest.csv`, `audit/duplicates_exact.csv`, `audit/near_duplicate_candidates.csv`, and `audit/near_cross_class_review_completed.xlsx` to `<PROJECT>/audit/` (or regenerate the first three with scripts 02–03).
4. Run:

```bash
python scripts/04_finalize_clean_split.py --base <PROJECT> --review <PROJECT>/audit/near_cross_class_review_completed.xlsx
```

The script should reproduce the reported counts and deterministic split assignment.

## Reproducing model experiments

After creating the split, place/copy the scripts in the project root or adjust `BASE_DIR` in scripts 05–10. The main execution order is:

```text
06_train_matrix.py
07_jpeg_evaluation.py
08_calibration_selective.py
09_efficiency_benchmark.py
10_final_tradeoff_analysis.py
10_bootstrap_statistics.py
11_class_specific_degradation.py
```

`10_bootstrap_statistics.py` and `11_class_specific_degradation.py` require the saved test/validation logits generated by the preceding stages.

## Statistical revision analyses

The paired bootstrap uses 5,000 replicates, true-class stratification, and `duplicate_group_id` as the resampling unit. The same bootstrap realization is applied to all compared configurations and training seeds. Confidence intervals are percentile 95% intervals for paired macro-F1 differences.

The class-specific analysis evaluates recall degradation for all 115 classes under JPEG conditions and examines its association with test support. Partial Spearman correlations additionally control for nominal class recall. Calibration is evaluated across quartiles of class support using temperature values fitted only on nominal validation logits.

## Hardware benchmark scope

The final benchmark environment is recorded in `environment_final.json` and `results/benchmark_system_info.json`. The reported latency measurements cover **model forward pass only** with inputs already resident on the GPU. They exclude JPEG decoding, resizing/cropping, disk I/O, host-to-device transfer, network latency, and energy use.

## Licensing

This is a mixed-license reproducibility package:

- Python source code: **MIT License** (`LICENSE_CODE.txt`).
- Original aggregate result tables and documentation produced for this study: **CC BY 4.0** (`LICENSE_RESULTS.txt`).
- Audit/split metadata derived from PlantWild_v2 identifiers and labels: distributed for reproducibility under the terms stated in `LICENSE_PLANTWILD_METADATA.txt`; the original PlantWild dataset remains **CC BY-NC-ND 4.0**.

No PlantWild_v2 image files are redistributed.

## Citation

Please cite the associated manuscript and this Zenodo record. A `CITATION.cff` file is included; the Zenodo DOI can be added after publication of the record.
