Skip to content

Machine learning project for predicting type of rice using CNN using pytorch

Notifications You must be signed in to change notification settings

almohsinkhan/Rice-Image-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍚 Rice Type Classification using CNN

This project focuses on classifying rice grain images into different varieties using a Convolutional Neural Network (CNN). The model is trained on the Kaggle Rice Image Dataset and demonstrates strong performance in distinguishing visually similar rice types.

πŸ“Œ Dataset

Source: Kaggle – Rice Image Dataset

The dataset contains five different rice varieties:

🌾 Arborio

🌾 Basmati

🌾 Ipsala

🌾 Jasmine

🌾 Karacadag

Each class consists of high-quality rice grain images captured under controlled conditions, making it suitable for image classification tasks.

🧠 Model Architecture

A custom CNN-based classifier was designed and trained from scratch.

Architecture Overview:

Multiple Convolutional layers with ReLU activation

Batch Normalization for stable training

MaxPooling layers for spatial downsampling

Adaptive Average Pooling

Fully Connected (Linear) layer for final classification

Model Summary:

Total Parameters: 94,341

Trainable Parameters: 94,341

Output Classes: 5

The final output layer uses Softmax (via CrossEntropyLoss) for multi-class classification.

βš™οΈ Training Details

Framework: PyTorch

Loss Function: CrossEntropyLoss

Optimizer: Adam

Batch Size: 32

Epochs: 5

Input Image Size: 224 Γ— 224

πŸ“Š Results & Performance

Loss Curve

Training loss steadily decreased across epochs

Test loss showed initial fluctuation but stabilized with training

Accuracy Curve

Training Accuracy: ~98%

Test Accuracy: ~93–95%

These results indicate good generalization with minimal overfitting.

πŸ“ˆ Visualizations

image

Plots clearly show model convergence and improved performance over epochs.

🏁 Conclusion

This project demonstrates how CNNs can effectively classify rice varieties based on visual features. Despite the similarity between rice grains, the model achieves high accuracy, proving the effectiveness of deep learning in agricultural image analysis

About

Machine learning project for predicting type of rice using CNN using pytorch

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published