Spaces:
Sleeping
Sleeping
| 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" | |
| } | |
| ``` |