Spaces:
Running
Running
File size: 6,431 Bytes
041a776 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 | # 🌾 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**
```bash
cd backend
pip install -r requirements.txt
```
#### **Start Backend Server**
```bash
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**
```bash
cd Frontend
npm install
# or
pnpm install
```
#### **Start Frontend Development Server**
```bash
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**
```bash
# 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**
```bash
# 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`:
```bash
# Clear cache and reinstall with legacy peer deps
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
```
#### **Alternative Installation**
```bash
# Use pnpm instead of npm
npm install -g pnpm
pnpm install
```
#### **Force Clean Install**
```bash
# 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:
```bash
# 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:
1. Check both backend and frontend logs
2. Verify all models are in correct directories
3. Ensure GPU drivers are updated
4. Check network connectivity between frontend/backend
**Your complete Agricultural AI System is now ready! 🌾🤖**
|