A repository for intelligent vision scenarios, with two implementations:
baseline: Image classification and visualization client based on TensorFlow/Keras + MQTT + DearPyGui.Advanced: Multi-model real-time detection and state/direction publishing system based on YOLOv7 + SORT.
This project implements a real-time monitoring robot system based on YOLOv7 for specialized surveillance scenarios. It focuses on multi-class behavior/object detection (e.g., smoking, fighting, falling, and littering), stable multi-target tracking, and an end-to-end deployment pipeline connecting robots, edge devices, and cloud-side services.
Core engineering work includes:
- Multi-class dataset collection, cleaning, preprocessing, and YOLOv7 fine-tuning for improved detection accuracy and inference speed.
- A multi-model detection pipeline integrated with SORT to maintain stable target persistence in complex scenes.
- Continuous video behavior recognition through temporal decision logic over streaming frames.
- An End-Edge-Cloud architecture over MQTT for low-latency messaging between robot-side components and backend services.
- A DearPyGui monitoring client supporting the workflow from video input and model inference to real-time visualization.
NUS-SOC/
├── baseline/
│ ├── backend/ # MQTT inference server + test sender/listener scripts
│ ├── client/ # DearPyGui client (model switching, result browsing, status display)
│ ├── utils/ # Training, data processing, and prediction scripts
│ └── requirements.txt
├── Advanced/
│ ├── advanced_final/ # Main multi-model real-time detection program (smoke/litter/fall/fight)
│ ├── dataset_preprocess/ # YOLO dataset merge tools and sample datasets
│ ├── docs/
│ └── yolov7/ # YOLOv7 code and data
└── README.md
- MQTT inference workflow: publish image payloads to
Group19/IMAGE/classify, receive results fromGroup19/IMAGE/predict. - Supports flower test classification and cat breed classification (requires local model files).
- DearPyGui client supports:
- Model switching and refresh
- Result image browsing and prediction display
- Cat status tracking panel
- Auto-archiving
resultsandresult_image.jsonon exit
- YOLOv7 multi-model parallel detection:
smoke/litter/fall/fight - SORT object tracking and direction decision (
left/right/no_action) - Supports local camera and Flask video stream (Raspberry Pi scenario)
- Publishes state and direction via MQTT:
Group19/CONTROL/stateGroup19/CONTROL/direction
- Python 3.9+ (3.10 recommended)
- An available MQTT broker (default port
1883) - A camera device (for running
Advanced) - Optional GPU (
Advancedperforms better with CUDA)
Run from the project root:
cd baseline
pip install -r requirements.txt
pip install dearpygui pillowBoth baseline/backend and baseline/client read mqtt.pwd in this format (username and password on one line, separated by a space):
username password
Large model files are ignored in this repo (e.g., client/model/* in .gitignore).
Place trained models in the paths below (filenames must match the code):
baseline/client/model/cats_efficientnetb0-Noise-Brightness-V1.kerasbaseline/client/model/cat_classifier_xception.h5baseline/client/model/cats_insection.kerasbaseline/client/model/cats_efficientnetb0-Noise-Brightness-V3-bright-05.kerasbaseline/client/model/cats_efficientnetb0-Noise-Brightness-V3-dark-05.kerasbaseline/client/model/cats_matching.kerasbaseline/client/model/flowers.keras(test model)
cd baseline/client
python app.pyNotes:
- The client initializes
MQTTInferenceServerwhen importingsystem. - The default broker address is hardcoded in
baseline/client/system/server_sys.py. For local setup, change it to127.0.0.1.
cd baseline/backend
python server.py # Inference service
python carsender.py # Batch-send test images
python monitor.py # Listen for prediction results onlycd Advanced/advanced_final
pip install -r requirements.txt
pip install paho-mqttDefault model paths:
trained_model/smoke.pttrained_model/new_trash_best.pttrained_model/fall.pttrained_model/fight.pt
Create mqtt.pwd in Advanced/advanced_final:
username password
cd Advanced/advanced_final
python main.py --camera 0 --device cpu --mqtt-host 127.0.0.1Arguments:
--camera 0: local camera--camera 1: Flask video stream (default URL inrun_multi_model.pyasFLASK_URL)--conf-thres: confidence threshold (default0.5)--iou-thres: NMS threshold (default0.45)--device:cpuor GPU index (e.g.,0)--mqtt-host: MQTT broker address
Advanced/dataset_preprocess/YoloDatasetMerger.py merges multiple YOLO-format datasets and automatically resolves class IDs.
Example:
cd Advanced/dataset_preprocess
python YoloDatasetMerger.py --datasets stand_fall_dataset violence3 --output merged_dataset- Publish images for classification:
Group19/IMAGE/classify - Publish classification results:
Group19/IMAGE/predict
- Subscribe control status:
Group19/CONTROL - Publish state:
Group19/CONTROL/state - Publish direction:
Group19/CONTROL/direction
- Model not found at startup: verify filenames in
baseline/client/modelorAdvanced/advanced_final/trained_model. - MQTT connection failed: check
mqtt.pwdformat, broker address, port1883, and account permissions. - Client failed to launch: ensure
dearpyguiandtensorfloware installed. - Slow
Advancedinference: prefer GPU, reduce input resolution, or increase frame interval.