Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation

🌱 SoilVision — AI-Powered Soil Analysis & Crop Recommendation System

By Team: The Debug Dynasty

24-Hour Hackathon Project (December 2025)

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.


🚜 Why SoilVision?

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.


⚙️ How It Works

1️⃣ Upload Soil Image

  • User uploads a soil photo via the Streamlit UI
  • Image is preprocessed using OpenCV (color, texture, morphological features)

2️⃣ Soil Type Classification

  • 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

3️⃣ Weather Data Integration

  • 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

4️⃣ AI Recommendation Engine

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)

5️⃣ Dashboard Visualization

Streamlit UI displays:

  • Soil type + confidence badge
  • Weather metrics
  • 7-day rainfall forecast (Plotly)
  • AI crop recommendations
  • Soil image preview
  • Pro tips for farmers

🏗️ System Architecture

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

📊 Model Performance

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%

💡 Key Features

  • ✔️ 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

🧪 Tech Stack

Frontend

  • Streamlit
  • Streamlit-Lottie
  • Plotly

Backend

  • Python
  • OpenCV
  • scikit-learn
  • scikit-image
  • Transformers (CLIP model)
  • PyTorch

Data & APIs

  • OpenWeatherMap API
  • Joblib (model serialization)

📁 Project Structure

📦 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

🚀 Installation & Setup

1. Create virtual environment

python -m venv soilvision_env
source soilvision_env/bin/activate   # Windows: venv\Scripts\activate

2. Install dependencies

pip install -r requirements.txt

3. Add your API key

Create a .env file:

OPENWEATHER_API_KEY=your_api_key_here

4. Run the application

streamlit run app.py

☁️ Deployment

Streamlit Cloud

  1. Push code to GitHub
  2. Connect repo to Streamlit Cloud
  3. Add environment variable OPENWEATHER_API_KEY
  4. Deploy ✔️

Docker

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"]

🔮 Future Roadmap

  • 📱 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

🏁 Conclusion

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages