Spaces:
Running
Running
๐พ Agricultural AI System - Complete Setup Guide
โ Model Training Status Verification
All models have been trained and are ready:
Trained Models Location: trained_models/
- โ
Whisper Multilingual:
whisper_multilingual/(9 Indian languages) - โ
TinyLlama Agricultural:
tinyllama_agricultural/(Q&A chatbot) - โ
EfficientNet Crop Classification:
efficientnet_crop_classification/ - โ
Disease Detection:
disease_detection/(EfficientNet-V2 โ train and place checkpoint here) - โ
Market Prediction Models:
market_prediction/(3 ML models)
Pre-trained Models Location: models/
- โ
NLLB Translation:
models/translation/nllb_600m/(Multi-language translation)
๐ Complete System Setup
1. Backend API Setup
Install Backend Dependencies
cd backend
pip install -r requirements.txt
Start Backend Server
python api_complete.py
Backend will run on: http://localhost:8000
API Endpoints Available:
/health- Health check/chat- Agricultural Q&A/speech-to-text- Voice recognition/text-to-speech- Audio response generation/image-diagnosis- Disease detection/crop-classification- Crop identification/market-prediction- Price prediction/translate- Multi-language translation
2. Frontend Setup
Install Frontend Dependencies
cd Frontend
npm install
# or
pnpm install
Start Frontend Development Server
npm run dev
# or
pnpm dev
Frontend will run on: http://localhost:3000
๐ง System Architecture
Backend (FastAPI)
- File:
backend/api_complete.py - Port: 8000
- Features:
- All trained models loaded on startup
- CORS enabled for frontend connection
- GPU acceleration for inference
- Error handling and logging
Frontend (Next.js + React)
- File:
Frontend/ - Port: 3000
- Features:
- Modern UI with Tailwind CSS
- Real-time chat interface
- Image upload and diagnosis
- Voice input support
- Multi-language support
API Client
- File:
Frontend/lib/api.ts - Features:
- TypeScript interfaces
- Error handling
- File upload support
- All endpoints connected
๐ฏ How to Use the System
1. Start Both Servers
# Terminal 1 - Backend
cd backend
python api_complete.py
# Terminal 2 - Frontend
cd Frontend
npm run dev
2. Access the Application
Open browser: http://localhost:3000
3. Available Features
๐ค AI Assistant
- Ask questions in Hindi/English
- Get agricultural advice
- Real-time chat interface
๐ธ Image Diagnosis
- Upload plant images
- Get disease detection
- Treatment recommendations
๐ค Voice Input & Output
- Speech-to-Text: Speak in 9 Indian languages
- Text-to-Speech: AI responses as audio
- Voice Interaction: Complete voice-based conversation
๐ Market Prediction
- Enter crop details
- Get price predictions
- Market recommendations
๐ Translation
- Translate between languages
- Support for Indian languages
- NLLB model integration
๐ Model Details
1. Whisper Multilingual Speech Recognition
- Languages: Bengali, Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Tamil, Telugu
- Training Data: 67,072 samples
- Use: Voice input processing
2. TinyLlama Agricultural Q&A
- Training Data: 50,231 agricultural Q&A pairs
- Languages: Hindi + English responses
- Use: Chat assistant
3. EfficientNet Vision Models
- Crop Classification: Identifies crop types
- Disease Detection: Detects plant diseases
- Use: Image analysis
4. Market Prediction
- Models: Random Forest, Gradient Boosting, Linear Regression
- Use: Price forecasting
5. NLLB Translation
- Model: 600M parameters
- Languages: 200+ languages
- Use: Multi-language support
๐ ๏ธ Troubleshooting
Backend Issues
# Check if models are loaded
curl http://localhost:8000/health
# Check GPU availability
python -c "import torch; print(torch.cuda.is_available())"
Frontend Issues
Dependency Resolution Error
If you get ERESOLVE unable to resolve dependency tree:
# Clear cache and reinstall with legacy peer deps
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
Alternative Installation
# Use pnpm instead of npm
npm install -g pnpm
pnpm install
Force Clean Install
# Clear all caches
npm cache clean --force
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
Model Loading Issues
- Ensure all trained models exist in
trained_models/ - Check GPU memory (8GB RTX 4060 recommended)
- Verify Python dependencies are installed
๐ฑ System Requirements
Hardware
- GPU: NVIDIA RTX 4060 (8GB VRAM) or better
- RAM: 16GB+ recommended
- Storage: 10GB+ for models
Software
- Python: 3.8+
- Node.js: 18+
- CUDA: 11.8+ (for GPU acceleration)
๐ Success Indicators
Backend Ready
INFO: Uvicorn running on http://0.0.0.0:8000
โ
All models loaded successfully!
Frontend Ready
ready - started server on 0.0.0.0:3000
System Working
- Chat responds to agricultural questions
- Image upload shows disease detection
- Voice input transcribes correctly
- All pages load without errors
๐ API Testing
Test individual endpoints:
# Health check
curl http://localhost:8000/health
# Chat test
curl -X POST http://localhost:8000/chat -F "message=เคฎเฅเคฐเฅ เคเคฎเคพเคเคฐ เคฎเฅเค เคฐเฅเค เคนเฅ"
# Text-to-speech test
curl -X POST http://localhost:8000/text-to-speech -F "text=เคเคชเคเฅ เคชเฅเคงเฅ เคฎเฅเค เคฐเฅเค เคนเฅ" -F "language=hi" --output speech.wav
# Image diagnosis test
curl -X POST http://localhost:8000/image-diagnosis -F "image_file=@plant_image.jpg"
๐ Support
If you encounter issues:
- Check both backend and frontend logs
- Verify all models are in correct directories
- Ensure GPU drivers are updated
- Check network connectivity between frontend/backend
Your complete Agricultural AI System is now ready! ๐พ๐ค