--- 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** ```json { "imageBase64": "data:image/jpeg;base64,...", "language": "English" } ``` **Response** ```json { "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