How gopisam1126/agricultural-crop-classifier works
Project Type and Purpose
• This is a machine-learning image classification pipeline for agricultural crops.
• It combines handcrafted computer-vision descriptors (LBP, GLCM, Gabor, ORB+BoVW) with deep embeddings from a pretrained VGG16, then applies feature selection (PCA, RFE) and trains an SVM classifier.
File Structure
• Top-level directories:
• Agricultural-crops/… (one subfolder per crop class, containing the raw images)
• Top-level files:
• image_classifier_model.py (the orchestration script that builds the pipeline, trains, evaluates, and saves the model)
• README.md (describes the pipeline components)
Main Components
a. Data Source
– “Agricultural-crops” directory with per-class image folders.
b. Preprocessing & Augmentation (if any)
– Resizing, normalization, any augmentation steps before feature extraction.
c. Handcrafted Feature Extractors (parallel branch)
– Local Binary Patterns (LBP)
– Gray-Level Co-occurrence Matrix (GLCM)
– Gabor filter bank responses
– ORB feature detection + Bag-of-Visual-Words model
d. Deep Feature Extractor (parallel branch)
– PyTorch’s pretrained VGG16 up to a penultimate layer to produce deep embeddings
e. Feature Aggregation
– Concatenate handcrafted vectors with deep embeddings into a single feature vector
f. Feature Selection & Dimensionality Reduction
– Principal Component Analysis (PCA)
– Recursive Feature Elimination (RFE)
g. Classifier
– Support Vector Machine (SVM) from scikit-learn
h. Model Persistence & Prediction
– Save trained SVM model (e.g., joblib/pickle)
– Inference flow: load model, extract features, predict class label
Relationships and Data Flow
1. Data Source → Preprocessing
2. Preprocessing → (split) → Handcrafted Extractors
3. Preprocessing → (split) → Deep Extractor (VGG16)
4. Handcrafted Features + Deep Embeddings → Aggregation
5. Aggregated Features → Feature Selection (PCA → RFE)
6. Selected Features → SVM Training → Trained Model
7. Inference Path: New Image → Full Pipeline → Model → Prediction
Important Architectural Patterns and Design Principles
• Pipeline pattern with clearly separated stages
• Parallel feature-extraction branches for classic vs. deep features
• Modularity: each extractor is its own component/module
• Reusability: image_classifier_model.py orchestrates end-to-end flow
• Separation of training vs. inference logic
Technologies, Frameworks, and Libraries
• Python 3.x
• OpenCV / scikit-image for LBP, GLCM, Gabor filters
• OpenCV for ORB + custom BoVW
• PyTorch for pretrained VGG16 embeddings
• scikit-learn for PCA, RFE, SVM
• joblib or pickle for model serialization
How to Proceed
1. Sketch the overall pipeline on paper, grouping related steps.
2. Two lanes: Training vs. Inference.