RF-Leaf-Freshness (rf-leaf-freshness.pkl)
A Random Forest classifier for Campus Leaf Freshness Classification, categorizing plant leaves into three physiological states: Healthy (Sehat), Yellowing (Menguning), and Dried (Kering).
Developed for the Digital Image Processing and Computer Vision (PCD-CV / CIF61339) final project at the Faculty of Computer Science, Universitas Brawijaya (UB), using a primary dataset collected across the UB campus environment.
Model Overview
| Component | Details |
|---|---|
| Algorithm | Random Forest Classifier (scikit-learn Pipeline) |
| PCD Pipeline Version | v2 (Aspect-ratio resize long_side=800, adaptive Gamma $L^*$ target_l=0.716, Bilateral Filter, CLAHE, Otsu ROI Segmentation) |
| Input Features | 28 handcrafted features (12 HSV & CIE-LAB color features + 16 GLCM & LBP texture features) |
| Consensus Hyperparameters | n_estimators=300, max_depth=6, max_features='sqrt', min_samples_leaf=2 |
| Final Training Data | 619 v2-preprocessed images (derived from 127 primary UB photos) |
| Target Classes | Kering, Menguning, Sehat |
Evaluation Performance (Anti-Leakage Nested 5-Fold CV)
Evaluated using StratifiedGroupKFold(groups=parent_id) so images originating from the same parent photo never leak across train and validation folds:
- Macro F1-Score:
92.70 Β± 4.70% - Accuracy:
92.89 Β± 4.57% - Model Inference Latency:
~0.93 ms / image
How to Use
Install dependencies:
pip install huggingface_hub joblib opencv-python scikit-learn==1.6.1 scikit-image numpy
Download the model bundle and inference.py helper from Hugging Face, preprocess a raw leaf image into the 28-feature vector X, and run predict(X):
import importlib.util
import joblib
from huggingface_hub import hf_hub_download
REPO_ID = "nadijfer/RF-Leaf-Freshness"
# 1. Download model bundle & preprocessing helper
model_path = hf_hub_download(repo_id=REPO_ID, filename="rf-leaf-freshness.pkl")
helper_path = hf_hub_download(repo_id=REPO_ID, filename="inference.py")
spec = importlib.util.spec_from_file_location("inference", helper_path)
inference = importlib.util.module_from_spec(spec)
spec.loader.exec_module(inference)
bundle = joblib.load(model_path)
pipeline = bundle["pipeline"]
# 2. Preprocess raw leaf image into 28-feature array X, then predict
X = inference.preprocess("path/to/image.jpg", feature_cols=bundle["feature_cols"], target_l=bundle["target_l"])
pred_label = pipeline.predict(X)[0]
probs = dict(zip(bundle["classes"], pipeline.predict_proba(X)[0]))
print(f"Prediction: {pred_label} | Probabilities: {probs}")
Project Team (FILKOM Universitas Brawijaya)
- Nadhif Rif'at Rasendriya (
235150201111074) β Data & PCD Lead - Nadhif Adita Fernanda (
235150201111033) β Feature Extraction & Classical ML Lead - Muzhaffar Ammar (
235150200111033) β Deep Learning & CV Integration Lead