🛡️ PPE Detection with YOLO
Upload a video to detect Personal Protective Equipment using your custom YOLO model
0.1 1
📋 Model Information
Available classes: Glass, Gloves, Goggles, Helmet, No-Helmet, No-Vest, Person, Safety-Boot, Safety-Vest, Vest, helmet, no helmet, no vest, no_helmet, no_vest, protective_suit, vest, worker
🔗 API Usage
cURL Example (2-step process):
# Step 1: Upload video file
VIDEO_HANDLE=$(curl -X POST \
-F "files=@your_video.mp4" \
https://rohannair-ppe.hf.space/upload -s | python3 -c "import sys, json; print(json.load(sys.stdin)[0])")
# Step 2: Make prediction request and poll for results
curl -X POST https://rohannair-ppe.hf.space/gradio_api/call/predict \
-s -H "Content-Type: application/json" \
-d "{\"data\": [{\"video\": \"$VIDEO_HANDLE\"}, 0.8]}" \
| python3 -c "import sys, json; r=json.load(sys.stdin); print(r.get('event_id', ''))" \
| read EVENT_ID; curl -N https://rohannair-ppe.hf.space/gradio_api/call/predict/$EVENT_ID
Python Example (using requests):
import requests
import time
# Step 1: Upload video
with open("video.mp4", "rb") as f:
upload_response = requests.post(
"https://rohannair-ppe.hf.space/upload",
files={"files": ("video.mp4", f, "video/mp4")}
)
video_handle = upload_response.json()[0]
# Step 2: Make prediction
response = requests.post(
"https://rohannair-ppe.hf.space/gradio_api/call/predict",
json={"data": [{"video": video_handle}, 0.8]},
headers={"Content-Type": "application/json"}
)
event_id = response.json().get("event_id")
# Step 3: Poll for results
while True:
result_response = requests.get(
f"https://rohannair-ppe.hf.space/gradio_api/call/predict/{event_id}"
)
result = result_response.json()
if result.get("status") == "complete":
print(result["data"])
break
time.sleep(2)
Python Example (using Gradio Client - easiest):
from gradio_client import Client
client = Client("https://rohannair-ppe.hf.space/")
result = client.predict(
"path/to/video.mp4", # video input
0.8, # conf_threshold
api_name="/predict"
)
print(result)