--- title: Crop Classifier API emoji: 🌾 colorFrom: green colorTo: yellow sdk: docker pinned: false app_port: 7860 tags: - agriculture - computer-vision - image-classification - api - fast-api - farming short_description: Free REST API to classify 50 crop varieties from images. --- # 🌾 Crop Classifier API AI-powered REST API that classifies **50 crop varieties** from images using EfficientNetB3 (93.48% accuracy) + LLaMA-3.2-90B Vision expert verification. ## 🔑 Get your free API Key **👉 [Click here to generate your free API Key](https://vdx-0-crop-classifier-api.hf.space/portal)** 👈 Generate a completely free, unique API key instantly. No approval needed. --- ## 📡 Base URL ``` https://vdx-0-crop-classifier-api.hf.space ``` ## 🚀 Quick Start ### JavaScript ```javascript const formData = new FormData(); formData.append("file", imageFile); // your image file const response = await fetch("https://vdx-0-crop-classifier-api.hf.space/predict", { method: "POST", headers: { "x-api-key": "YOUR_API_KEY_HERE" }, body: formData }); const result = await response.json(); console.log(result.final_answer.crop_name); // "Wheat" console.log(result.final_answer.quality); // "Excellent" console.log(result.final_answer.explanation); // "Full description..." ``` ### Python ```python import requests with open("crop.jpg", "rb") as f: res = requests.post( "https://vdx-0-crop-classifier-api.hf.space/predict", headers={"x-api-key": "YOUR_API_KEY_HERE"}, files={"file": f} ) print(res.json()["final_answer"]) ``` ### cURL ```bash curl -X POST "https://vdx-0-crop-classifier-api.hf.space/predict" \ -H "x-api-key: YOUR_API_KEY_HERE" \ -F "file=@crop_image.jpg" ``` --- ## 📦 Response Example ```json { "final_answer": { "crop_name": "Wheat", "quality": "Excellent", "market_grade": "Grade A", "characteristics": "Golden stalks with dry grain heads...", "explanation": "High quality mature wheat crop...", "storage_tip": "Store in cool, dry place in sealed bags", "confidence_label": "High" } } ``` ## ⚡ Endpoints | Endpoint | Description | |---|---| | `POST /predict` | Full analysis (model + AI expert) | | `POST /predict/fast` | Model only, instant response | | `GET /crops` | List all 50 supported crops | | `GET /docs` | Interactive API documentation |