A comprehensive AI-powered plant disease detection platform that enables farmers and agricultural professionals to identify plant diseases from leaf images using advanced deep learning models, with full user management, prediction history, and cloud storage integration.
System Architecture:
Full-Stack ML Application (1 Repository)
- Frontend: Next.js 16 (App Router) with TypeScript and Tailwind CSS
- Backend: FastAPI (Python) with ONNX Runtime for optimized inference
- Machine Learning: PyTorch with ResNet50/EfficientNet-B0 architectures
- Model Deployment: ONNX Runtime for production-ready inference
- Authentication: NextAuth.js with email/password and session management
- Database: PostgreSQL with Prisma ORM for user data and prediction history
- Storage: AWS S3 for scalable image storage with presigned URLs
- UI Components: Shadcn/ui with Radix UI primitives
Intelligent Disease Detection Flow:
User Journey
- Image Upload: Users upload plant leaf images via drag-and-drop interface
- AI Analysis: Deep learning model analyzes images using ONNX Runtime for fast inference
- Disease Classification: Model predicts from 40+ plant disease classes with confidence scores
- Results Display: Detailed prediction results with top-k probabilities and disease information
- History Management: All predictions saved to user history with filtering and search
- Cloud Storage: Images automatically uploaded to AWS S3 for persistent storage
Advanced Features:
Machine Learning & AI
- Deep Learning Models: ResNet50 and EfficientNet-B0 architectures with transfer learning
- ONNX Optimization: Production-ready model export for fast inference
- Multi-Class Classification: Supports 40+ plant disease classes across multiple crop types
- Confidence Scoring: Detailed probability distributions for top predictions
- Model Training Pipeline: Complete training infrastructure with data augmentation and checkpointing
Image Processing & Storage
- AWS S3 Integration: Scalable cloud storage with presigned URL generation
- Image Preprocessing: Automated image normalization and resizing for model input
- Drag-and-Drop Upload: Intuitive file upload interface with preview
- Asset Management: Organized storage with S3 key tracking and metadata
User Experience
- Prediction History: Complete history tracking with filtering by disease, plant type, and date
- Dashboard Analytics: User dashboard with quick actions and model information
- Responsive Design: Fully mobile-optimized interface with dark/light mode support
- Real-Time Feedback: Loading states and progress indicators during analysis
Technical Implementation:
Frontend
- Modern Stack: Next.js 16 with React 19 and TypeScript
- UI Framework: Tailwind CSS with Shadcn/ui component library
- Animations: Framer Motion for smooth transitions and interactions
- State Management: React hooks with server-side data fetching
- Form Handling: React Hook Form with Zod validation
Backend & ML
- FastAPI: High-performance Python API with async support
- ONNX Runtime: Optimized inference engine for production deployment
- PyTorch: Deep learning framework for model training and development
- Model Export: Automated ONNX conversion pipeline with shape validation
- Image Processing: PIL/Pillow for preprocessing and normalization
Database & Storage
- PostgreSQL: Relational database for structured data storage
- Prisma ORM: Type-safe database queries and migrations
- AWS S3: Object storage for images with lifecycle management
- Indexed Queries: Optimized database indexes for fast history retrieval
Machine Learning Pipeline:
Training Infrastructure
- Data Pipeline: ImageFolder dataset loader with train/validation splits
- Data Augmentation: Random transforms for improved model generalization
- Model Architectures: Support for ResNet50, ResNet18, EfficientNet-B0, and custom ResNet-10
- Transfer Learning: Pretrained ImageNet weights for faster convergence
- Checkpointing: Best model saving with metadata and class information
- Metrics Tracking: Training metrics exported to CSV for analysis
Model Deployment
- ONNX Export: Automated model conversion with shape validation
- Runtime Optimization: ONNX Runtime for CPU/GPU inference
- Label Management: Dynamic class label loading and prettification
- Model Rebuilding: Automatic ONNX regeneration when class counts mismatch
Supported Plant Diseases:
The platform detects diseases across multiple crop categories:
- Fruits: Apple, Cherry, Grape, Peach, Strawberry
- Vegetables: Tomato, Potato, Pepper, Corn
- Specialty Crops: Coffee, Chili
Each category includes healthy plant detection and multiple disease types (e.g., Apple Scab, Black Rot, Cedar Apple Rust, etc.), totaling 40+ distinct classes.
Administrative Features:
- User Authentication: Secure login/registration with NextAuth.js
- Session Management: Persistent sessions with database-backed storage
- Prediction History: Complete CRUD operations for user predictions
- Filtering & Search: Advanced filtering by disease, plant type, date range
- Image Management: S3-based image storage with automatic cleanup
- Model Information: API endpoints for model version and class information
Advanced System Features:
User Experience
- Dark/Light Theme: System-aware theming with next-themes
- Interactive UI: Shadcn/ui components with Radix UI primitives
- Mobile-First Design: Responsive layouts optimized for all devices
- Loading States: Skeleton loaders and progress indicators
- Error Handling: Comprehensive error messages and validation
Deployment & Scaling
- Production Ready: Optimized ONNX models for fast inference
- Cloud Infrastructure: AWS S3 for scalable storage
- Database Migrations: Prisma-based schema management
- API Documentation: FastAPI auto-generated OpenAPI docs
Business Impact:
Plant Disease Prediction transforms agricultural diagnostics by providing instant, accurate disease detection through AI. Farmers and agricultural professionals can quickly identify plant diseases from mobile devices, enabling early intervention and reducing crop losses. The platform combines cutting-edge deep learning with a user-friendly interface, making advanced AI accessible to the agricultural community.
This project showcases expertise in deep learning, computer vision, full-stack development, cloud infrastructure, and production ML deployment with Next.js and Python.