Real-Time Crowd Management System for train stations using sensor technology, AI-driven analytics, and real-time data processing to improve passenger flow, reduce congestion, and optimize train operations and scheduling
- Color grouping for passengers (dashboard)
- GET request from LSTM API (dashboard)
- Asymmetric Encryption
- Cabin exit gesture detection
- Use GET request to scrape ridership data (LSTM)
-
Install InfluxDB and extract the zip to
C:\Program Files\InfluxData\
, rename and move all files to parent folder -
Start InfluxDB
cd 'C:\Program Files\InfluxData' && ./influxd
-
Grant network access,
InfluxDB UI
can be viewed athttp://localhost:8086
-
In
InfluxDB UI
, setup user account with orgNextGen Hackathon
to obtainAll Access API Token
, save the token -
In
InfluxDB UI > Load Data > Buckets
, create 2 bucketsmain
andrasp-pi
-
Under
Dashboard
,Create Dashboard > Add a Template
, paste this URL -
Open new terminal, clone the repo and navigate to root directory
git clone https://github.com/Vincexodus/MetroMantap.git && cd .\MetroMantap\
-
Duplicate
.env.example
and rename the duplicated file to.env.local
, replace the values accordingly -
Install OpenSSL and generate self-signed ssl cert
# root directory cd assets && ./ssl_cert.sh
-
Copy generated folder called
ssl
to Raspberry PI. -
Create virtual python environment and activate it
virtualenv venv venv\Scripts\activate
-
Download required python modules
pip install -r requirements.txt
-
Run server script (recommend with PyTorch + Cuda installed)
py pc_server.py
-
Install telegraf
wget -q https://repos.influxdata.com/influxdata-archive_compat.key sudo apt-get update && sudo apt-get install telegraf
-
Add environment variables for Telegraf
export INFLUX_HOST=http://<PC-IP-ADDRESS>:8086 # PC IPv4 Address, NOT localhost export INFLUX_TOKEN=<ALL_ACCESS_API_TOKEN> export INFLUX_ORG="NextGen Hackathon"
-
Start Telegraf, command can be found
InfluxDB UI > Load Data > Telegraf > Setup Instructions
telegraf --config http://<PC-IP-ADDRESS>:8086/api/v2/telegrafs/...
-
Open new terminal, clone the repo and install python modules
git clone https://github.com/Vincexodus/MetroMantap.git && cd .\MetroMantap\ sudo pip install opencv-python spidev ssl
-
Enable SPI on the Raspberry Pi
sudo raspi-config
-
Navigate to Interfacing Options > SPI > Enable.
-
Run client script
raspberry_client.py
in Thonny IDE
-
Data Collection:
- Download the HTML file from data.gov.my dashboard
- Run the following commands to extract and scrape data:
cd ridership-LSTM python data-scraping/train-combination.py # Extract possible OD pair combinations python data-scraping/od-ridership.py # Scrape the latest daily OD ridership data python data-scraping/monthly-ridership.py # Query the OpenAPI for monthly ridership data
-
Data Preparation:
- Use
data-preparation/prepare-data.py
to process and prepare the collected data
- Use
-
Model Training:
model/lstm.py
is used to train the LSTM models for each OD pair
-
API:
api.py
provides an API interface for the trained models- Open a new terminal and navigate to
ridership-LSTM
directory - Start the app using
uvicorn api:app --reload
- This endpoint reads the
future_predictions.csv
file from each OD pair folder in themodel/lstm/
directory and returns the predictions as a JSON response - The API will be available at
http://0.0.0.0:8000/predictions/
- How to Setup a Raspberry Pi Pressure Pad (FSR)
- Monitoring Your Raspberry Pi System using InfluxDB Telegraf
- Easy Step-by-Step Guide to Installing CUDA for PyTorch
- Data source: data.gov.my
- This project was developed as part of the MMU ZTE 5G Hackathon