--- title: Rice Classification CNN emoji: 🌾 colorFrom: green colorTo: yellow sdk: streamlit app_file: src/streamlit_app.py pinned: false short_description: Rice image classifier CNN. license: mit --- # Rice Classification using CNN (From Scratch) This project implements a **Convolutional Neural Network (CNN) from scratch** to classify rice grain images into five different types: - Arborio - Basmati - Ipsala - Jasmine - Karacadag The model was trained without transfer learning and achieves **very high accuracy** on the validation dataset. --- ## 📁 Dataset - Total images: **75,000** - Classes: **5** - Train / Validation Split: **80% / 20%** - Image size: **160 × 160** - Batch size: **16** - Background: Black (single rice grain per image) --- ## 🧠 Model Overview The CNN architecture includes: - 5 Convolutional Layers - 3 MaxPooling Layers - Batch Normalization - L2 Regularization - Data Augmentation (Flip, Rotation, Zoom) - Global Average Pooling - Dense Layer with Dropout - Softmax Output Layer (5 classes) --- ## ⚙️ Training Setup - Loss Function: **Sparse Categorical Crossentropy** - Optimizer: **Adam (learning rate = 0.0001)** - Metrics: **Accuracy** - Epochs: **40** - Callbacks: - EarlyStopping - ReduceLROnPlateau - ModelCheckpoint --- ## 📊 Results - ✅ **Validation Accuracy:** **99.94%** - ✅ **Validation Loss:** **0.0179** - ✅ **Precision, Recall, F1-Score:** **1.00 for all classes** - ✅ **Only 9 misclassifications out of 75,000 images** The confusion matrix shows nearly perfect classification performance. --- ## 🚀 Future Work - Test the model on real-world images - Apply stronger data augmentation - Compare with a **Transfer Learning model (e.g. ResNet50)** - Deploy as a **Streamlit Web App** --- ## 👤 Author **Name:** Enes Yamac **Date:** 05.12.2025 **Project Type:** Deep Learning – CNN Image Classification --- ## 📄 Files in this Project - `best_rice_cnn.keras` → Trained CNN model - `rice_cnn_training.ipynb` → Jupyter Notebook (training & evaluation) - `Rice_CNN_Report_Enes_Yamac.pdf` → Technical Report - `README.md` → Project description --- ✅ **Status:** Project completed successfully.