File size: 5,158 Bytes
91d687e
 
f8b925c
91d687e
 
 
 
 
f8b925c
91d687e
 
f8b925c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39b9e39
f8b925c
 
 
 
 
39b9e39
f8b925c
 
 
 
 
39b9e39
f8b925c
 
 
 
 
39b9e39
f8b925c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39b9e39
f8b925c
 
 
 
 
 
 
 
 
39b9e39
f8b925c
 
 
 
 
 
 
 
 
 
 
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
---
title: Murderer Detector
emoji: πŸ”ͺ
sdk: gradio
sdk_version: 6.0.1
app_file: app.py
pinned: false
license: apache-2.0
short_description: Detect suspicious individuals lurking behind you with AI!
---

# πŸ”ͺ Murderer Detector

[![Gradio](https://img.shields.io/badge/Gradio-6.0.1-orange)](https://gradio.app/)
[![Python](https://img.shields.io/badge/Python-3.10+-blue)](https://www.python.org/)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](LICENSE)

> **WARNING:** This app uses HIGHLY ADVANCED AI TECHNOLOGY to detect potential murderers lurking behind you!

## What is This?

A humorous real-time person detection app that detects suspicious individuals lurking **behind** you. Built with Gradio 6.0.1 and YOLOv8.

**This is for funs.** No actual threat detection occurs. Don't call the cops on your roommates.

## Features

- **Real-time webcam streaming** with unified display (no separate input/output)
- **Smart user detection** - filters out the user (largest person) and only flags people behind them
- **Person detection** with YOLOv8-nano
- **Hilarious single-line labels** with emojis and threat percentages:
  - πŸ₯£ SERIAL BREAKFAST SKIPPER (87%)
  - πŸ“š DANGEROUS BOOK READER (92%)
  - πŸ›οΈ FITTED SHEET FOLDER (76%)
  - β˜• NOTORIOUS TEA DRINKER (95%)
  - πŸ”Œ OWNS MULTIPLE USB-C CABLES (83%)
  - ...and 15 more!
- **Color-coded threat levels** (red/orange/yellow based on percentage)
- **Large, readable text** optimized for webcam viewing
- **Running suspect count** in header

## Quick Start

### Run Locally

```bash
# Install dependencies
pip install -r requirements.txt

# Run the app (includes share=True for instant public URL)
python app.py
```

The app will launch at http://localhost:7860 and provide a public shareable link!

### Deploy to Hugging Face Spaces

1. Create a new Space on Hugging Face
2. Upload these files:
   - `app.py`
   - `requirements.txt`
   - `README.md`
3. Your app will automatically deploy!

## For Developers

This app is intentionally structured to be easily modified for **serious computer vision applications**. The code is organized into clear modules:

### Architecture

```
PersonDetector      β†’ Detection Module (swap YOLO for any model)
MurdererClassifier  β†’ Classification Logic (replace with real ML)
FrameAnnotator      β†’ Annotation Layer (customize visuals)
MurdererDetector    β†’ Main Pipeline (orchestrates everything)
```

### Modify for Serious Use Cases

**Security Monitoring:**

- Replace `MurdererClassifier` with anomaly detection
- Add action recognition (violence, falls, intrusions)
- Integrate alerts and logging

**PPE Detection:**

- Modify `PersonDetector` to detect helmets, vests, masks
- Add compliance scoring in `MurdererClassifier`
- Update annotations to show violations

**Customer Analytics:**

- Track people counting and dwell time
- Add age/gender classification
- Generate heatmaps in `FrameAnnotator`

**Social Distancing:**

- Calculate distances between detected persons
- Flag violations with visual warnings
- Log statistics over time

### Key Components

**app.py:53** - `PersonDetector.detect_persons()` - Swap detection models here

**app.py:127** - `MurdererClassifier.classify()` - Replace with real ML inference

**app.py:183** - `FrameAnnotator.annotate_frame()` - Customize visualization

**app.py:342** - `MurdererDetector._filter_user()` - Logic to exclude the user (largest person)

All classes are well-documented with inline comments explaining modification points.

## Technical Details

- **Detection**: YOLOv8-nano (fast, lightweight, ~6MB model)
- **Streaming**: Gradio 6.x Image streaming with unified input/output
- **Processing**: Real-time with OpenCV
- **User Filtering**: Excludes largest person (assumed to be the user)
- **Deployment**: Optimized for Hugging Face Spaces with share=True enabled

## How to Use

1. **Run the app** - It launches with a public shareable link
2. **Enable webcam** - Click the webcam button in the interface
3. **Position someone behind you** - The app needs at least 2 people (you + someone behind you)
4. **Watch the detection** - Only people behind you get flagged as "threats"
5. **Share the link** - Use the Gradio share link to show friends

**Note:** If you're the only person in frame, nothing will be detected (by design!)

## License

Apache 2.0 - Use this code for anything! Education, commercial projects, world domination, etc.

## Credits

Built with:

- [Gradio 6.0.1](https://gradio.app/) for the UI and streaming
- [Ultralytics YOLOv8](https://github.com/ultralytics/ultralytics) for person detection
- Excessive amounts of coffee and true crime documentaries

## Contributing

Found a funnier label? Want to improve the detection? Open a PR!

Ideas for improvements:

- More emoji labels (currently 20, could add 50+)
- Sound effects when new suspects appear
- Threat level history/tracking
- Better user filtering (depth detection, face recognition)
- Multiple webcam angles
- Export "suspect reports" as PDF
- Multiple language support

---

**Remember:** The real murderers are the friends we made along the way. Stay safe out there! πŸ”ͺ