Spaces:
Sleeping
Sleeping
File size: 2,108 Bytes
4dd6a7a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
---
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"
}
``` |