SoilVision is an integrated AI-driven agricultural assistant that analyzes soil images, retrieves real-time weather data, and generates data-driven crop recommendations tailored to Indian farming conditions.
Using Computer Vision, Machine Learning, CLIP embeddings, Random Forest classification, and LLM reasoning, SoilVision empowers farmers to make informed decisions instantly — without the need for laboratory testing.
Indian farmers face several critical challenges:
- ❗ Uncertain crop selection due to soil & climate mismatch
- 🧪 Expensive, time-consuming soil testing
- 🌧️ Lack of real-time weather insights
- 🧭 Regional soil variation (Black, Red, Loamy, Clay, Sandy soils)
- 🌦️ Climate unpredictability and erratic rainfall
SoilVision solves this by transforming a simple soil photo + location into actionable recommendations.
- User uploads a soil photo via the Streamlit UI
- Image is preprocessed using OpenCV (color, texture, morphological features)
-
Random Forest Classifier predicts one of 5 soil types:
- Loamy
- Clay
- Sandy
- Red
- Black
-
Confidence score (0–100%) provided
-
CLIP (OpenAI) model assists with cross-modal soil interpretation
-
Fetches location-based weather using:
- OpenWeatherMap OneCall API (3.0)
- Auto-fallback to 2.5/weather if needed
-
Retrieves temperature, humidity, rainfall forecast (7 days), wind, and more
The LLM generates a structured response including:
- 🌾 Top 5 suitable crops
- 🧪 Recommended NPK fertilizer ratios
- 💧 Irrigation schedule (rain-aware)
- 🐛 Pest & disease considerations
- 🌱 Season-based advice (Kharif, Rabi, Zaid)
Streamlit UI displays:
- Soil type + confidence badge
- Weather metrics
- 7-day rainfall forecast (Plotly)
- AI crop recommendations
- Soil image preview
- Pro tips for farmers
User Input (Image + Location + Season)
↓
Streamlit Frontend (app.py)
↓
Backend Logic (backend_logic.py)
┌─────────────────────────────────┐
│ 1. Image Processing (OpenCV) │
│ 2. Random Forest Soil Model │
│ 3. Weather API Integration │
│ 4. Data Fusion (soil+weather) │
│ 5. LLM Recommendation Engine │
└─────────────────────────────────┘
↓
Results Dashboard UI
Random Forest Soil Classifier
| Soil Type | Precision | Recall |
|---|---|---|
| Loamy | 0.92 | 0.89 |
| Clay | 0.85 | 0.87 |
| Sandy | 0.88 | 0.86 |
| Red Soil | 0.86 | 0.88 |
| Black Soil | 0.89 | 0.90 |
- Overall Test Accuracy: 87.6%
- Mean Confidence: 84%
- ✔️ AI-powered soil classification (CV + ML + CLIP)
- ✔️ Real-time weather integration with smart fallback
- ✔️ LLM-based structured crop recommendations
- ✔️ 7-day rainfall forecasting
- ✔️ Holographic UI theme with glass-morphism
- ✔️ Mobile-friendly interface
- ✔️ Multi-parameter fusion: soil + weather + season
- ✔️ GPS-based location detection
- Streamlit
- Streamlit-Lottie
- Plotly
- Python
- OpenCV
- scikit-learn
- scikit-image
- Transformers (CLIP model)
- PyTorch
- OpenWeatherMap API
- Joblib (model serialization)
📦 SoilVision
├── app.py # Streamlit Frontend
├── backend_logic.py # Processing + API + ML pipeline
├── soil_rf_model.pkl # Random Forest soil model
├── requirements.txt
├── gps.html # Geolocation utility
├── user_location.json # Cached coordinates
└── assets/ # Images, Lottie animations, UI assets
python -m venv soilvision_env
source soilvision_env/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
Create a .env file:
OPENWEATHER_API_KEY=your_api_key_here
streamlit run app.py
- Push code to GitHub
- Connect repo to Streamlit Cloud
- Add environment variable
OPENWEATHER_API_KEY - Deploy ✔️
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["streamlit", "run", "app.py"]- 📱 Mobile app (React Native)
- 🌐 Multilingual UI (Hindi, Tamil, Kannada, Telugu)
- 🐛 Pest detection via image classification
- 🧪 Soil pH & nutrient estimation model
- 🌾 Market price integration
- 🚁 Drone imagery support
- 📡 IoT sensor integration (soil moisture, NPK meters)
- 🌤️ Climate resilience scoring
SoilVision bridges the gap between farmers and expert-level soil analysis. By combining computer vision, machine learning, real-time weather APIs, and AI recommendations, the system enables farmers to make smarter crop decisions — instantly.
📈 Impact Potential:
- Improve yields by 15–25%
- Enable 1M+ Indian farmers to make data-driven decisions
- Reduce soil test waiting time from days to seconds