Spaces:
Sleeping
Sleeping
| 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) |