This repo now contains the first starter build for the 36-hour proof of concept.
The goal of this POC is simple:
- connect a live camera feed
- run computer vision inference on each frame
- highlight detections on screen
- trigger a threat alert for configured classes
- save evidence frames and short clips when a threat is detected
- webcam input
- RTSP stream input
- video file input as a safe demo fallback
- configurable YOLO weights
- configurable threat classes
- evidence saving for detections
If you use standard pretrained YOLO weights such as yolov8n.pt, you will usually only get common object classes from public datasets.
That means:
- the pipeline itself can be proven immediately
- true
knife,gun,fight, orstealingdetection will likely require custom weights or a more specialized model
So the fastest path is:
- prove the live pipeline works
- test with
personor other available classes first - swap in custom weights as soon as you have them
- run the detector on a webcam
- verify overlays and alerts work
- verify evidence files are saved
- test the same app with a video file
- test the same app with an RTSP stream when available
- use Colab only for quick model experimentation or fine-tuning
- keep live inference local for the demo
- do not block the POC on Jetson or Jetson-like deployment work
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
pip install -r requirements.txtThis proves the live pipeline works.
python detector.py --source 0 --weights yolov8n.pt --threat-classes person --showThis is not your final threat logic. It is just the fastest way to validate:
- camera capture
- frame inference
- bounding box rendering
- alerting
- evidence saving
python detector.py --source "rtsp://username:password@camera-ip:554/stream" --weights yolov8n.pt --threat-classes person --showpython detector.py --source "demo.mp4" --weights yolov8n.pt --threat-classes person --showWhen you have custom weights for classes like knife, gun, or fight, run:
python detector.py --source 0 --weights "models\best.pt" --threat-classes knife,gun,fight --showThe detector now supports a second layer of rule-based threat assessment on top of raw detections.
Useful arguments:
--person-classes: labels treated as people by the rule engine--weapon-classes: labels treated as dangerous objects--threat-classes: explicit classes that should still trigger an alert directly--assault-distance-ratio: controls how close an armed person must be to another person before the app flagsPOSSIBLE ASSAULT
Example with custom weapon weights:
python detector.py --source 0 --weights "models\best.pt" --person-classes person --weapon-classes knife,gun --threat-classes knife,gun --showExample with separate person and weapon models:
python detector.py --source 0 --weights yolov8n.pt --person-weights yolov8n.pt --weapon-weights "models\weapon_best.pt" --weapon-loader yolov5 --person-classes person --weapon-classes knife,gun --threat-classes knife,gun --showThis is the best same-day setup when your custom checkpoint only knows weapon classes.
Useful live-tuning flags:
--weapon-conf 0.65or higher to reduce false positives--debug-weaponto print exact weapon detections and confidences--min-threat-frames 3to ignore one-frame blips before raising a threat
Example with stricter live tuning:
python detector.py --source 0 --weights yolov8n.pt --person-weights yolov8n.pt --weapon-weights "models\weapon_best.pt" --weapon-loader yolov5 --person-classes person --weapon-classes knife,gun --threat-classes knife,gun --weapon-conf 0.80 --min-threat-frames 3 --debug-weapon --showThe detector now also supports a pose-based heuristic violence layer.
This is not a trained action-recognition model. It uses:
- person proximity
- wrist motion speed
- arm extension
- weapon-to-hand attachment heuristics
New high-level states:
VIOLENCE SUSPECTEDPOSSIBLE STABBINGPOSSIBLE ARMED ASSAULT
Recommended violence test command:
python detector.py --source 0 --weights yolov8n.pt --person-weights yolov8n.pt --weapon-weights "models\weapon_best.pt" --weapon-loader yolov5 --pose-weights yolov8n-pose.pt --person-classes person --weapon-classes knife,gun --threat-classes knife,gun --weapon-conf 0.80 --min-threat-frames 3 --violence-min-frames 4 --debug-weapon --debug-violence --showIf you want to temporarily disable pose-based violence logic:
python detector.py --source 0 --weights yolov8n.pt --person-weights yolov8n.pt --weapon-weights "models\weapon_best.pt" --weapon-loader yolov5 --pose-weights "" --person-classes person --weapon-classes knife,gun --threat-classes knife,gun --showExpected on-screen states:
DANGEROUS OBJECT: dangerous item visibleARMED PERSON: a weapon appears spatially attached to a detected personPOSSIBLE ASSAULT: an armed person is close to another detected person
Important:
- these higher-level states are currently heuristic
- they are meant for the same-day POC demo layer, not as final action-recognition claims
Detections are saved under runs\detect\.
Each event can produce:
- an annotated image
- a short annotated clip
- Run the webcam smoke test first.
- Confirm the pipeline works locally on your machine.
- Add your rented RTSP camera as the second test source.
- Obtain or train weapon-aware weights for
knifeandgun. - Use the new threat-rule layer to demo
ARMED PERSONandPOSSIBLE ASSAULT. - Use Colab only if you need quick training or fine-tuning.
For this first deadline, do not try to solve all threat categories at once.
The best milestone is:
- one working detector app
- one live input
- one or two detectable threat classes
- one clean demo for your co-founder