AI_Safety_Demo5 / config.py
neerajkalyank's picture
Update config.py
448c9e7 verified
import os
import subprocess
CONFIG = {
"MODEL_PATH": "static/yolov8_safety.pt",
"FALLBACK_MODEL": "static/yolov8n.pt",
"VIOLATION_LABELS": {
0: "no_helmet",
1: "no_harness",
2: "unsafe_posture",
3: "unsafe_zone",
4: "improper_tool_use"
},
"CLASS_COLORS": {
"no_helmet": (0, 0, 255),
"no_harness": (0, 165, 255),
"unsafe_posture": (0, 255, 0),
"unsafe_zone": (255, 0, 0),
"improper_tool_use": (255, 255, 0)
},
"DISPLAY_NAMES": {
"no_helmet": "No Helmet Violation",
"no_harness": "No Harness Violation",
"unsafe_posture": "Unsafe Posture",
"unsafe_zone": "Unsafe Zone Entry",
"improper_tool_use": "Improper Tool Use"
},
"PUBLIC_URL_BASE": "https://huggingface.co/spaces/neerajkalyank/AI_Safety_Demo3/resolve/main/static/output/",
"CONFIDENCE_THRESHOLDS": {
"no_helmet": 0.4,
"no_harness": 0.25,
"unsafe_posture": 0.25,
"unsafe_zone": 0.25,
"improper_tool_use": 0.25
},
"MIN_VIOLATION_FRAMES": 1,
"VIOLATION_COOLDOWN": 30.0,
"WORKER_TRACKING_DURATION": 5.0,
"MAX_PROCESSING_TIME": 60,
"FRAME_SKIP": 1,
"BATCH_SIZE": 4,
"TRACK_BUFFER": 150,
"TRACK_THRESH": 0.3,
"MATCH_THRESH": 0.5,
"SNAPSHOT_QUALITY": 95,
"MAX_WORKER_DISTANCE": 150,
"TARGET_RESOLUTION": (384, 384)
}
def check_ffmpeg():
try:
subprocess.run(["ffmpeg", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True)
return True
except (subprocess.CalledProcessError, FileNotFoundError):
return False