Spaces:
Sleeping
Sleeping
metadata
title: Soil Classification Backend
emoji: π±
colorFrom: green
colorTo: yellow
sdk: docker
app_port: 7860
pinned: false
license: mit
tags:
- soil-classification
- cnn
- fastapi
- agriculture
- tensorflow
- crop-recommendation
short_description: Classify soil types from images and get crop recommendations
π± Soil Classification Backend
AI-powered soil image classifier built with FastAPI + TensorFlow. Upload a photo of soil and instantly receive:
- π·οΈ Soil type β one of Black Β· Clayey Β· Loamy Β· Red Β· Sandy
- πΎ Crop recommendations β sourced from 8 000+ soil-to-crop mappings
- π Multilingual explanations β English, Hindi, and Odia
π API
POST /api/classify
Request
{
"imageBase64": "data:image/jpeg;base64,...",
"language": "English"
}
Response
{
"soilType": "Sandy",
"explanation": "This soil appears to be Sandy soil...",
"recommendedCrops": ["Barley", "Maize", "Millets"]
}
GET /
Health check β returns model status and supported soil classes.
π§ Model
| Architecture | CNN (Convolutional Neural Network) |
| Framework | TensorFlow / Keras 2.16 |
| Input | 224 Γ 224 RGB image |
| Classes | Black, Clayey, Loamy, Red, Sandy |
π οΈ Stack
| Web Framework | FastAPI |
| ML | TensorFlow 2.16 (CPU) |
| Image Processing | Pillow |
| Data | pandas + CSV (8 000+ crop mappings) |
| Server | Uvicorn |
| Container | Docker |
π Files
βββ app.py # FastAPI app + CNN inference
βββ Dockerfile # Docker build
βββ requirements.txt # Python deps
βββ model/
β βββ soil_model007.keras
βββ data/
βββ data_core.csv # Soil β Crop mapping
π Languages Supported
| Language | Code |
|---|---|
| English | "English" |
| Hindi | "Hindi" |
| Odia | "Odia" |
Made with β€οΈ for Indian agriculture Β· NIELIT Internship