--- title: Farm Object Detection API emoji: 🔍 colorFrom: blue colorTo: indigo sdk: gradio sdk_version: 4.28.3 app_file: app.py pinned: false license: apache-2.0 short_description: Object detection for farm equipment, crops, and workers --- # 🔍 Farm Object Detection API High-performance object detection for agricultural environments using RT-DETR models. ## 🎯 Capabilities - **Farm Equipment Detection**: Tractors, harvesters, tools - **Crop Counting**: Automated inventory of plants and produce - **Worker Safety**: Personnel detection and activity monitoring - **Animal Detection**: Livestock and wildlife identification ## 🤖 Models - **RT-DETR R18VD**: Lightweight, fast inference (15-30 FPS) - **RT-DETR R34VD**: Balanced performance and accuracy - **RT-DETR R50VD**: High accuracy for detailed analysis ## 📡 API Usage ### Python ```python import requests import base64 def detect_objects(image_path, model="r50vd"): with open(image_path, "rb") as f: image_b64 = base64.b64encode(f.read()).decode() response = requests.post( "https://YOUR-USERNAME-farm-object-detection.hf.space/api/predict", json={"data": [image_b64, model]} ) return response.json() result = detect_objects("farm_image.jpg") print(result) ``` ### JavaScript ```javascript async function detectObjects(imageFile, model = 'r50vd') { const base64 = await fileToBase64(imageFile); const response = await fetch( 'https://YOUR-USERNAME-farm-object-detection.hf.space/api/predict', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ data: [base64, model] }) } ); return await response.json(); } ``` ## 📊 Response Format ```json { "objects_detected": 12, "detections": [ { "class": "tractor", "confidence": 0.95, "bbox": [100, 150, 400, 350], "area": 75000 } ], "processing_time": 0.8, "model_used": "rtdetr_r50vd" } ```