Spaces:
Sleeping
Sleeping
File size: 2,532 Bytes
3091ffd | 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 84 85 86 87 88 89 90 91 92 93 94 | ---
title: Farm Human Recognition API
emoji: π₯
colorFrom: purple
colorTo: pink
sdk: gradio
sdk_version: 4.28.3
app_file: app.py
pinned: false
license: apache-2.0
short_description: Farm worker detection and safety analysis
---
# π₯ Farm Human Recognition API
Advanced farm worker detection and analysis using YOLOS models for workplace safety and productivity assessment.
## π― Capabilities
- **Worker Detection**: Precise identification of farm workers in images
- **Safety Analysis**: Workplace safety scoring and risk assessment
- **Activity Recognition**: Classification of farm work activities
- **Productivity Metrics**: Performance analysis and recommendations
## π€ Models
- **YOLOS Tiny**: Fastest processing for real-time applications
- **YOLOS Small**: Balanced accuracy and speed (recommended)
- **YOLOS Base**: Highest accuracy for detailed analysis
## π‘ API Usage
### Python
```python
import requests
import base64
def detect_farm_workers(image_path, model="yolos_small"):
with open(image_path, "rb") as f:
image_b64 = base64.b64encode(f.read()).decode()
response = requests.post(
"https://YOUR-USERNAME-farm-human-recognition.hf.space/api/predict",
json={"data": [image_b64, model]}
)
return response.json()
result = detect_farm_workers("farm_workers.jpg")
print(result)
```
## π Response Format
```json
{
"humans_detected": 3,
"detections": [
{
"class": "person",
"confidence": 0.92,
"bbox": [120, 45, 180, 200],
"activity": "ground_work",
"area": 7200
}
],
"safety_analysis": {
"status": "safe",
"score": 0.85,
"concerns": [],
"workers_detected": 3
},
"productivity_metrics": {
"active_workers": 3,
"productivity_score": 0.75,
"activity_breakdown": {
"ground_work": 2,
"operating_equipment": 1
},
"recommendations": [
"Consider team coordination for efficiency"
]
},
"processing_time": 1.5
}
```
## π Activity Classification
- **ground_work**: Field operations, planting, harvesting
- **close_work**: Inspection, detailed tasks, quality control
- **operating_equipment**: Tractor/machinery operation
- **general_activity**: Walking, standing, general movement
## π‘οΈ Safety Features
- Automatic detection of high worker density
- Equipment operation safety analysis
- Workplace hazard identification
- Safety score calculation (0-1) |