A computer vision intelligence system for retail and mall environments — from model inference to business analytics.
Built as part of the Inside AI with Kayana YouTube channel. This project shows you how a standard camera network can be turned into an intelligent data system — one that feeds marketing, operations, and security teams with real, actionable insights.
This system layers five computer vision technologies on top of a standard mall camera network:
| Technology | What It Produces |
|---|---|
| Emotion Classification | Capture emotional state of shoppers |
| Multi-Camera ReID | Cross-camera identity matching and customer journey visualisation |
| Crowd Analysis | Zone-level occupancy counts and trend tracking |
| Intrusion Detection | Automated alerts when restricted zones are breached |
| BI Dashboard | Unified Streamlit dashboard connecting all data streams |
| Real-Time Notifications | Telegram alerts powered by Postgres LISTEN/NOTIFY |
📹 Video walkthrough coming soon on Inside AI with Kayana
| Layer | Tool |
|---|---|
| People Detection | NVIDIA PeopleNet (ONNX) |
| Re-Identification | OSNet via torchreid |
| Emotion Classification | DeepFace |
| Zone Configuration | Roboflow PolygonZone |
| Database | PostgreSQL (local) |
| Dashboard | Streamlit |
| Notifications | Telegram Bot API + Postgres LISTEN/NOTIFY |
| Demo Environment | Jupyter Notebook (VS Code) |
| Language | Python 3.13 |
retail-deep-dive-computer-vision/
├── .streamlit/
├── models/
│ └── peoplenet.onnx
├── Input_Videos/
│ ├── Emotion_Classification
│ ├── ReID
│ ├── Crowd_Analysis
│ ├── Intrusion_Detection
├── Output_Videos/
│ ├── Emotion_Classification
│ ├── ReID
│ ├── Crowd_Analysis
│ ├── Intrusion_Detection
├── zone_setup_frames/
├── alert_crops/
├── synthetic_data_export/
├── demo_code.ipynb ← main notebook (inference pipeline)
├── dashboard_combined_app.py ← Streamlit analytics dashboard with real and synthetic data combined
├── dashboard_real_app.py ← Streamlit analytics dashboard with real data only
├── notification_service.py ← real-time Telegram alert service
└── README.md
Five PostgreSQL tables store all CV outputs:
zones ← polygon zone definitions per camera
rules ← notification trigger rules
detection_events ← all detection metadata from every use case
emotion_events ← DeepFace results linked to detection_events
notifications ← triggered alerts linked to rules and detections
reid_features ← feature vectors for multicamera reidentification
git clone https://github.com/elmayana/computer-vision-for-retail.git
cd computer-vision-for-retailpython -m venv venv
venv\Scripts\activate # Windows
source venv/bin/activate # macOS/Linuxinstall requirements.txt file here
pip install -r requirements.txtpip install torch torchvision --index-url https://download.pytorch.org/whl/cuXXX where [XXX] is the CUDA version (check using nvidia-smi command)
- Install PostgreSQL from https://www.postgresql.org/download/
- Create a database
- Update
DB_PASSWORDandDB_USERNAMEwith your password and username in demo-code.ipynb - in the .streamlit folder, create a secrets.toml file
[connections.postgresql]
dialect = "postgresql"
host = "localhost"
port = "your_port"
database = "your_database"
username = "your_username"
password = "your_password"- Download
deployable_quantized_onnx_v2.6.3from the PeopleNet NGC page - Place it in the
models/folder
| Section | Download |
|---|---|
| Emotion Classification | Emotion Video 1 Emotion Video 2 |
| ReID (2 camera views) | Download ReID videos |
| Crowd Analysis | Pexels — Book Shop Time Lapse |
| Intrusion Detection | Pexels — Corridor Video |
Place all videos in the Input_Videos/ folder and update the file paths
To receive real-time alerts on Telegram:
- Message @BotFather on Telegram and create a new bot — you'll receive a bot token
- Start a conversation with your new bot, then retrieve your chat ID by visiting:
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates - Add both values to
notification_service.py:TELEGRAM_BOT_TOKEN = "your_bot_token" TELEGRAM_CHAT_ID = "your_chat_id"
Open the notebook in VS Code (or Jupyter Lab) and run the cells section by section.
Once the inference pipeline has run and your CSVs or database are populated:
streamlit run dashboard_combined_app.pyThe dashboard opens in your browser at http://localhost:8501. It includes:
- Customer journey Sankey diagram (cross-zone flow)
- Emotion composition by zone and hour
- Floor plan heatmap
- Crowd and intrusion trend charts
- Sidebar date range filter
Run this in a separate terminal while the inference pipeline is active:
python notification_service.pyThis service listens to Postgres for new events and sends a Telegram message whenever a configured rule is triggered. Security alerts (intrusion) and operational alerts (crowd thresholds) have separate debounce windows to prevent alert fatigue.
- NVIDIA PeopleNet on NGC
- NVIDIA TAO DetectNet_v2 Documentation
- DeepFace GitHub
- Roboflow PolygonZone
- Pexels — Royalty Free Retail Footage
This project is licensed under the GPL-3.0 License.