_ ___ __ __ ____ _
/ \ |_ _| \ \ / /__ __ _/ ___| ___ _ __| |_
/ _ \ | |____\ \ / / _ \/ _` \___ \ / _ \| '__| __|
/ ___ \ | |_____\ V / __/ (_| |___) | (_) | | | |_
/_/ \_\___| \_/ \___|\__, |____/ \___/|_| \__|
|___/
π₯ AI-Powered Vegetable Classification & Sorting π€
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.
- 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
- 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
- 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
- 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
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
- 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
- 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
- Model Architecture: MobileNetV2 with transfer learning
- Input Processing: 224x224 RGB image preprocessing
- Training: Data augmentation, early stopping, learning rate scheduling
- Deployment: TensorFlow SavedModel format
- Python 3.11+
- Node.js 19.1+
- npm or yarn
- Git
git clone https://github.com/your-username/vegetable-sorter.git
cd vegetable-sortercd 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 runservercd ../vegetable_sorter_frontend
# Install dependencies
npm install
# Start development server
npm start- Frontend: http://localhost:3000
- Backend API: http://localhost:8000/api
- Django Admin: http://localhost:8000/admin
data/raw/
βββ train/
β βββ Bean/
β βββ Bitter_Gourd/
β βββ Bottle_Gourd/
β βββ ... (15 vegetable classes)
βββ validation/
β βββ Bean/
β βββ ... (same 15 classes)
βββ test/
βββ Bean/
βββ ... (same 15 classes)
- Training: 1000+ images per class
- Validation: 200+ images per class
- Testing: 200+ images per class
- Format: JPG, PNG (224x224 recommended)
# 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"# 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/# Get comprehensive stats
curl http://localhost:8000/api/stats/
# Export classifications
curl http://localhost:8000/api/export-classifications/ > classifications.csvWe welcome contributions! Please see our contributing guidelines below.
-
Fork the repository
-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Follow existing code style
- Add tests for new features
- Update documentation
-
Run tests
# Backend tests cd vegetable_sorter_backend python manage.py test # Frontend tests cd vegetable_sorter_frontend npm test
-
Commit your changes
git commit -m "feat: add new sorting algorithm" -
Push and create PR
git push origin feature/your-feature-name
- Follow PEP 8
- Use Black for formatting
- Use type hints where appropriate
- Write docstrings for functions and classes
- Use ESLint and Prettier
- Follow React best practices
- Use functional components with hooks
- Write JSDoc comments for complex functions
Use conventional commit format:
feat:New featuresfix:Bug fixesdocs:Documentation updatesstyle:Code formattingrefactor:Code restructuringtest:Testing updateschore:Maintenance tasks
- Additional vegetable classification classes
- Performance optimizations for mobile devices
- Real-time video stream processing
- Advanced analytics dashboards
- Docker containerization
- Unit test coverage improvements
- API rate limiting
- Caching mechanisms
- Internationalization (i18n)
- Accessibility improvements
- Theme customization
- Additional export formats
- Plugin architecture
- Progressive Web App features
When reporting issues, please include:
- OS and browser version
- Steps to reproduce
- Expected vs actual behavior
- Screenshots (if applicable)
- Console error messages
For feature requests, please provide:
- Use case description
- Proposed solution
- Alternative approaches considered
- Implementation complexity estimate
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
- 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
- Real-time video processing
- Multi-camera support
- Advanced quality metrics
- Cloud deployment options
- IoT sensor integration
- Predictive maintenance
- Advanced reporting dashboard
- Mobile app companion
Built with β€οΈ for the agricultural technology community
