title | emoji | colorFrom | colorTo | sdk | app_port |
---|---|---|---|---|---|
LeafLense - AI-Powered Agricultural Assistant |
π± |
green |
blue |
docker |
7860 |
LeafLense is an advanced agricultural intelligence platform that combines machine learning, computer vision, and AI agents to provide comprehensive farming solutions. The platform offers plant disease detection, fertilizer recommendations, crop yield predictions, and proactive farming alerts through an intelligent agent system.
... (the rest of your great README continues here)
LeafLense is an advanced agricultural intelligence platform that combines machine learning, computer vision, and AI agents to provide comprehensive farming solutions. The platform offers plant disease detection, fertilizer recommendations, crop yield predictions, and proactive farming alerts through an intelligent agent system.
- AI-Powered Diagnosis: Upload plant leaf images for instant disease identification
- 38+ Disease Classes: Supports detection across multiple crops (Apple, Tomato, Corn, Grape, etc.)
- Treatment Recommendations: Provides organic and chemical treatment options
- Confidence Scoring: Reliable predictions with confidence percentages
- Real-time Weather Integration: Continuous weather monitoring and analysis
- Risk Assessment Engine: Predicts disease and pest risks based on environmental conditions
- Automated Alerts: Daily notifications via WhatsApp for farming recommendations
- Farmer Management: Complete farmer profile and location management system
- AI Chat Interface: Contextual farming advice through intelligent conversations
- Soil Analysis: NPK (Nitrogen, Phosphorus, Potassium) level optimization
- Environmental Factors: Considers temperature, humidity, and moisture
- Crop-Specific: Tailored recommendations for different crop types
- Natural Language Processing: Accept recommendations via plain text descriptions
- Data-Driven Insights: Predict crop yields based on historical and current data
- Market Intelligence: Price prediction and market trend analysis
- Decision Support: Help farmers optimize planting and harvesting decisions
- Multi-language Support: Communicate in local languages
- Voice Integration: Speech-to-text and text-to-speech capabilities
- Context-Aware: Understands farmer-specific context and location
- 24/7 Availability: Always available farming assistance
backend/
βββ main.py # Main FastAPI application
βββ FarmAgent/ # Proactive farming agent
β βββ app/
β β βββ agents/ # Weather, risk, chat agents
β β βββ clients/ # Firebase, weather API clients
β β βββ utils/ # Utility functions
β βββ routes.py # FarmAgent API endpoints
βββ Plant_Disease/ # Disease detection module
β βββ routes.py # Disease detection endpoints
β βββ trained_model_savedmodel/ # Pre-trained ML model
βββ FertilizerSuggestor/ # Fertilizer recommendation
β βββ routes.py # Fertilizer API endpoints
βββ PricePrediction/ # Crop price prediction
βββ app.py # Price prediction service
frontend/
βββ src/
β βββ components/ # Reusable UI components
β β βββ layout/ # Layout components
β βββ pages/ # Application pages
β βββ config/ # Configuration files
β βββ assets/ # Static assets
βββ public/ # Public assets
βββ package.json # Dependencies and scripts
- Python: 3.8+
- FastAPI: 0.115.0+
- TensorFlow: 2.17+ (for disease detection)
- Firebase Admin SDK: For database and authentication
- Google Generative AI: For AI-powered responses
- Node.js: 18+
- React: 18.3.1+
- Vite: 6.0.1+
- Tailwind CSS: For styling
- Firebase: Database and authentication
- Google Gemini API: AI language model
- OpenWeather API: Weather data
- WhatsApp Business API: Alert notifications
git clone https://github.com/yourusername/LeafLense.git
cd LeafLense
cd backend
pip install -r requirements.txt
Create a .env
file in the backend/
directory:
# Google APIs
GOOGLE_API_KEY=your_google_api_key_here
GEMINI_API_KEY=your_gemini_api_key_here
# OpenWeather API
OPENWEATHER_API_KEY=your_openweather_api_key
# Application Settings
PORT=8000
ENVIRONMENT=development
# Database
DATABASE_URL=your_database_url_if_needed
- Create a Firebase project at Firebase Console
- Enable Firestore Database
- Generate a service account key
- Save the key as
serviceAccountKey.json
in thebackend/
directory
# From the backend directory
python main.py
The backend server will start at: http://localhost:8000
cd frontend
npm install
Create a .env
file in the frontend/
directory:
VITE_API_BASE_URL=http://localhost:8000
VITE_FIREBASE_API_KEY=your_firebase_config
VITE_FIREBASE_AUTH_DOMAIN=your_firebase_config
VITE_FIREBASE_PROJECT_ID=your_firebase_config
VITE_FIREBASE_STORAGE_BUCKET=your_firebase_config
VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_config
VITE_FIREBASE_APP_ID=your_firebase_config
# From the frontend directory
npm run dev
The frontend will be available at: http://localhost:3000
GET /farm/farmagent/
- Service statusPOST /farm/farmagent/run-now
- Trigger immediate pipeline executionPOST /farm/farmagent/farmers
- Register new farmerGET /farm/farmagent/farmers
- Get all farmersGET /farm/farmagent/alerts
- Get all alertsGET /farm/farmagent/alerts/{farmer_id}
- Get farmer-specific alertsPOST /farm/farmagent/api/chat
- Chat with AI assistant
POST /plant/disease/predict
- Upload image for disease detection
POST /fertilizer/predict
- Get fertilizer recommendation (structured data)POST /fertilizer/predict_from_text
- Get recommendation from natural language
-
Start Backend:
cd backend && python main.py
-
Start Frontend:
cd frontend && npm run dev
-
Access Application: Open
http://localhost:3000
in your browser
cd backend
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app --bind 0.0.0.0:8000
cd frontend
npm run build
npm run preview
The plant disease detection requires a trained TensorFlow model:
- Ensure the model is in
backend/Plant_Disease/trained_model_savedmodel/
- The model should support 38 plant disease classes
- Expected input shape: (None, 128, 128, 3)
- Set up Firestore collections:
farmers
: Farmer profiles and locationsalerts
: Generated alerts and recommendationschat_messages
: Chat history
- Register at OpenWeatherMap
- Add your API key to the
.env
file - The system fetches weather data every 6 hours
- Navigate to
/disease-detection
- Upload a clear image of a plant leaf
- Get instant diagnosis with confidence score
- Receive treatment recommendations
- Go to
/fertilizer
- Input soil conditions and crop information
- Receive NPK recommendations
- Alternative: Use natural language input
- Register farmers through
/farm/farmagent/farmers
- System automatically monitors weather conditions
- Receives daily alerts at 6:00 AM IST
- Chat interface available for real-time advice
# Backend Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
- Backend: Deploy on Google Cloud Run, AWS Lambda, or Heroku
- Frontend: Deploy on Vercel, Netlify, or AWS S3 + CloudFront
- Database: Use Firebase Firestore or MongoDB Atlas
- File Storage: Google Cloud Storage or AWS S3
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email [email protected] or join our Discord community.
- TensorFlow team for the machine learning framework
- Google for Gemini AI and Firebase services
- OpenWeatherMap for weather data
- The agricultural research community for disease datasets
Built with β€οΈ for the farming community πΎ