Skip to content

A simulation of industrial-grade AI-powered vegetable sorting system with real-time conveyor belt simulation. This system uses MobileNetV2 deep learning model to classify 15 different vegetable types with high accuracy and provides an interactive web interface for monitoring and control.

License

Notifications You must be signed in to change notification settings

amithpdn/ai-veg-sort-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

    _    ___   __     __         ____             _   
   / \  |_ _|  \ \   / /__  __ _/ ___|  ___  _ __| |_ 
  / _ \  | |____\ \ / / _ \/ _` \___ \ / _ \| '__| __|
 / ___ \ | |_____\ V /  __/ (_| |___) | (_) | |  | |_ 
/_/   \_\___|     \_/ \___|\__, |____/ \___/|_|   \__|
                           |___/                      

πŸ₯• AI-Powered Vegetable Classification & Sorting πŸ€–

AI Vegetable Sorting System

Python Django React TensorFlow

A simulation of industrial-grade AI-powered vegetable sorting system with real-time conveyor belt simulation. This system uses MobileNetV2 deep learning model to classify 15 different vegetable types with high accuracy and provides an interactive web interface for monitoring and control.

Simulation

AI-VegSort-In-Action

πŸš€ Features

Core AI Capabilities

  • Real-time Image Classification: MobileNetV2-based deep learning model
  • 15 Vegetable Types Support: Bean, Bitter Gourd, Bottle Gourd, Brinjal, Broccoli, Cabbage, Capsicum, Carrot, Cauliflower, Cucumber, Papaya, Potato, Pumpkin, Radish, Tomato
  • High Accuracy: 95%+ classification accuracy with confidence scoring
  • Edge Computing Ready: On-device processing for industrial applications

Interactive Simulation

  • Conveyor Belt Animation: Real-time vegetable movement simulation
  • AI Vision System: Industrial camera simulation with detection zones
  • Automated Sorting: Pneumatic actuator simulation based on AI predictions
  • Speed Control: Variable belt speed (0.1x to 3x) with automatic item spacing

Advanced Analytics

  • Session Management: Track sorting sessions with detailed statistics
  • Performance Metrics: Real-time throughput, confidence scores, processing times
  • Data Export: CSV export of classification results
  • Historical Analysis: Trend analysis and quality metrics

Production Features

  • Responsive Design: Works on desktop, tablet, and mobile devices
  • RESTful API: Complete backend API for integration
  • Database Integration: PostgreSQL/SQLite with session tracking
  • Comprehensive Logging: Django-integrated logging system
  • Error Handling: Robust error handling and recovery

πŸ“ Project Structure

vegetable-sorter/
β”œβ”€β”€ vegetable_sorter_backend/          # Django Backend
β”‚   β”œβ”€β”€ vegetable_sorter/              # Django Project Settings
β”‚   β”‚   β”œβ”€β”€ settings.py                # Configuration
β”‚   β”‚   β”œβ”€β”€ urls.py                    # URL routing
β”‚   β”‚   └── wsgi.py                    # WSGI config
β”‚   β”œβ”€β”€ vegsim/                        # Main Django App
β”‚   β”‚   β”œβ”€β”€ models.py                  # Database models
β”‚   β”‚   β”œβ”€β”€ views.py                   # API endpoints
β”‚   β”‚   β”œβ”€β”€ serializers.py             # Data serialization
β”‚   β”‚   β”œβ”€β”€ urls.py                    # App URLs
β”‚   β”‚   └── utils/                     # Utilities
β”‚   β”‚       └── data_preprocessing.py   # ML preprocessing
β”‚   β”œβ”€β”€ notebooks/                     # Training Scripts
β”‚   β”‚   └── train_vegetable_classifier.py
β”‚   β”œβ”€β”€ models/                        # Trained Models
β”‚   β”‚   β”œβ”€β”€ vegetable_classifier.h5    # TensorFlow model
β”‚   β”‚   └── vegetable_classes.pkl      # Class labels
β”‚   β”œβ”€β”€ data/                          # Training Data
β”‚   β”‚   └── raw/                       # Dataset structure
β”‚   β”‚       β”œβ”€β”€ train/
β”‚   β”‚       β”œβ”€β”€ validation/
β”‚   β”‚       └── test/
β”‚   β”œβ”€β”€ logs/                          # Application logs
β”‚   └── requirements.txt               # Python dependencies
β”œβ”€β”€ vegetable_sorter_frontend/         # React Frontend
β”‚   β”œβ”€β”€ public/                        # Static assets
β”‚   β”œβ”€β”€ src/                           # React source code
β”‚   β”‚   β”œβ”€β”€ components/                # React components
β”‚   β”‚   β”‚   └── VegetableSorter.jsx    # Main component
β”‚   β”‚   β”œβ”€β”€ services/                  # API services
β”‚   β”‚   β”‚   └── api.js                 # Backend API client
β”‚   β”‚   β”œβ”€β”€ hooks/                     # React hooks
β”‚   β”‚   β”‚   └── useVegetableSorter.js  # Custom hooks
β”‚   β”‚   β”œβ”€β”€ utils/                     # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ constants.js           # Constants
β”‚   β”‚   β”‚   └── generateSessionName.js # Session naming
β”‚   β”‚   └── App.js                     # Main App component
β”‚   β”œβ”€β”€ package.json                   # Node dependencies
β”‚   └── tailwind.config.js             # Tailwind CSS config
β”œβ”€β”€ docs/                              # Documentation
β”‚   β”œβ”€β”€ backend-architecture.md        # Backend README
β”‚   β”œβ”€β”€ frontend-architecture.md       # Frontend README
β”‚   β”œβ”€β”€ frontend-architecture.md       # Logging Strategy README
β”‚   └── logging_readme.md              # Deployment README
└── README.md                          # This file

πŸ› οΈ Technology Stack

Backend

  • Framework: Django 4.2+ with Django REST Framework
  • Database: PostgreSQL (production) / SQLite (development)
  • AI/ML: TensorFlow 2.10+, MobileNetV2, OpenCV, PIL
  • Data Processing: NumPy, Pandas, scikit-learn
  • API: RESTful API with JSON responses

Frontend

  • Framework: React 18+ with functional components and hooks
  • Styling: Tailwind CSS with responsive design
  • Icons: Lucide React icons
  • State Management: React useState and useReducer
  • HTTP Client: Axios for API communication

AI/ML Pipeline

  • Model Architecture: MobileNetV2 with transfer learning
  • Input Processing: 224x224 RGB image preprocessing
  • Training: Data augmentation, early stopping, learning rate scheduling
  • Deployment: TensorFlow SavedModel format

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 19.1+
  • npm or yarn
  • Git

1. Clone Repository

git clone https://github.com/your-username/vegetable-sorter.git
cd vegetable-sorter

2. Backend Setup

cd vegetable_sorter_backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Database setup
python manage.py makemigrations
python manage.py migrate

# Create superuser (optional)
python manage.py createsuperuser

# Train the AI model (required)
python notebooks/train_vegetable_classifier.py

# Start backend server
python manage.py runserver

3. Frontend Setup

cd ../vegetable_sorter_frontend

# Install dependencies
npm install

# Start development server
npm start

4. Access Application

πŸ“Š Dataset Preparation

Required Dataset Structure

data/raw/
β”œβ”€β”€ train/
β”‚   β”œβ”€β”€ Bean/
β”‚   β”œβ”€β”€ Bitter_Gourd/
β”‚   β”œβ”€β”€ Bottle_Gourd/
β”‚   └── ... (15 vegetable classes)
β”œβ”€β”€ validation/
β”‚   β”œβ”€β”€ Bean/
β”‚   └── ... (same 15 classes)
└── test/
    β”œβ”€β”€ Bean/
    └── ... (same 15 classes)

Recommended Dataset Size

  • Training: 1000+ images per class
  • Validation: 200+ images per class
  • Testing: 200+ images per class
  • Format: JPG, PNG (224x224 recommended)

πŸ”§ API Usage

Classification Endpoint

# Single image classification
curl -X POST http://localhost:8000/api/classify/ \
  -F "image=@vegetable.jpg" \
  -F "session_id=your-session-id"

# Bulk classification
curl -X POST http://localhost:8000/api/classify/bulk/ \
  -F "images=@veg1.jpg" \
  -F "images=@veg2.jpg"

Session Management

# Start new session
curl -X POST http://localhost:8000/api/sessions/start_session/ \
  -H "Content-Type: application/json" \
  -d '{"session_name": "Production Run 1"}'

# Get active session
curl http://localhost:8000/api/sessions/active_session/

Statistics

# Get comprehensive stats
curl http://localhost:8000/api/stats/

# Export classifications
curl http://localhost:8000/api/export-classifications/ > classifications.csv

🀝 Contributing

We welcome contributions! Please see our contributing guidelines below.

Development Workflow

  1. Fork the repository

  2. Create a feature branch

    git checkout -b feature/your-feature-name
  3. Make your changes

    • Follow existing code style
    • Add tests for new features
    • Update documentation
  4. Run tests

    # Backend tests
    cd vegetable_sorter_backend
    python manage.py test
    
    # Frontend tests
    cd vegetable_sorter_frontend
    npm test
  5. Commit your changes

    git commit -m "feat: add new sorting algorithm"
  6. Push and create PR

    git push origin feature/your-feature-name

Code Style Guidelines

Python (Backend)

  • Follow PEP 8
  • Use Black for formatting
  • Use type hints where appropriate
  • Write docstrings for functions and classes

JavaScript (Frontend)

  • Use ESLint and Prettier
  • Follow React best practices
  • Use functional components with hooks
  • Write JSDoc comments for complex functions

Git Commit Messages

Use conventional commit format:

  • feat: New features
  • fix: Bug fixes
  • docs: Documentation updates
  • style: Code formatting
  • refactor: Code restructuring
  • test: Testing updates
  • chore: Maintenance tasks

What to Contribute

High Priority

  • Additional vegetable classification classes
  • Performance optimizations for mobile devices
  • Real-time video stream processing
  • Advanced analytics dashboards
  • Docker containerization

Medium Priority

  • Unit test coverage improvements
  • API rate limiting
  • Caching mechanisms
  • Internationalization (i18n)
  • Accessibility improvements

Low Priority

  • Theme customization
  • Additional export formats
  • Plugin architecture
  • Progressive Web App features

Issue Reporting

When reporting issues, please include:

  • OS and browser version
  • Steps to reproduce
  • Expected vs actual behavior
  • Screenshots (if applicable)
  • Console error messages

Feature Requests

For feature requests, please provide:

  • Use case description
  • Proposed solution
  • Alternative approaches considered
  • Implementation complexity estimate

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • TensorFlow Team for the MobileNetV2 architecture
  • Django Community for the excellent web framework
  • React Team for the frontend library
  • Contributors who have helped improve this project

πŸ“ž Support

  • Documentation: Check the /docs folder for detailed guides
  • Issues: Use GitHub Issues for bug reports
  • Discussions: Use GitHub Discussions for questions
  • Email: hello.appkiddo@gmail.com

πŸ—ΊοΈ Potential Roadmap

Version 2.0

  • Real-time video processing
  • Multi-camera support
  • Advanced quality metrics
  • Cloud deployment options

Version 3.0

  • IoT sensor integration
  • Predictive maintenance
  • Advanced reporting dashboard
  • Mobile app companion

Built with ❀️ for the agricultural technology community

About

A simulation of industrial-grade AI-powered vegetable sorting system with real-time conveyor belt simulation. This system uses MobileNetV2 deep learning model to classify 15 different vegetable types with high accuracy and provides an interactive web interface for monitoring and control.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published