Skip to content

A desktop program based on pyside2 is implemented, which uses yolov5 and KNN algorithm to detect falls.实现了一个基于pyside2的桌面程序, 使用yolov5以及KNN算法进行跌倒检测.

License

Notifications You must be signed in to change notification settings

powerli2002/FallDetectionApp

Repository files navigation

FallDetectionApp

A desktop program based on pyside2 is implemented, which uses yolov5 and KNN algorithm to detect falls.

实现了一个基于pyside2的桌面程序, 使用yolov5以及KNN算法进行跌倒检测.

How To Use 使用

Installation environment:

安装环境:

pip install -r requirement.txt

Run the desktop program:

运行桌面程序:

python StartUp.py

Run the tester:

运行检测程序:

python predict.py

Training model (data set required)

训练模型(需要数据集)

python train.py

Obtain the results of the evaluation

获得评估:

python get_map.py

Pay attention to model path modification and pattern change.

注意模型路径修改和模式改变

KNN algorithm

使用mediapipe进行人体关键点提取,再使用knn算法进行分类。对视频每帧调用mp.solutions.pose进行人体关键点提取,分别存入对应csv文件。再对数据集进行划分。

数据集中包括人体关键点数据,共100列。第一列为标签,后面为33个关键点*3坐标数据。

训练过程:

调用sklearn的knn模型,设置k=3,读取训练集进行训练,保存权重到joblib文件中。

对数据检测一次的速度为1.24ms。

对图像检测一次的速度为1/6=166ms。

模型检验

调用sklearn.metrics 库,对模型在测试集上进行相关指标的评估。

image-20240131132325847

此数值建立在数据集较小情况下的理论情况,而理论性能好的模型不一定对实际情况做出较好应对。实际上,受限于数据集和knn本身限制,此模型不具有很好泛化性.

YOLOv5 Model

训练过程

数据集来源:飞桨公开数据集falldown

其中包括7782张图片,可用类别为:person和fall(后期修改),

对数据集进行重新划分,划分时去除无效标签。划分比例为(训练集+验证集):测试集 = 9:1,训练集:验证集 = 9:1。

yolov5s版本模型,sgd优化器,momentum = 0.937,

权值衰减weight_decay=5e-4。

学习率下降方式为cos。

最大学习率0.01,最小学习率为其0.01倍。

image-20240131132336627

模型检验:

nms_iou=0.5,门限值为0.5时

Class Scores Fall Person
AP 85.11% 69.49%
F1 0.68 0.52
Recall 53.60% 37.57%
Precision 92.79% 86.10%
Map 77.30%
Total Accuracy 97.51%
Score_threhold Accuracy 42.57%

An attempt to combine YOLOv5 and KNN

image-20240131132347993

设想使用medaipipe对其进行修正。即在置信度大于0.5的框内进行medaipipe的检测,进而提高模型的准确率。

但是需要注意的是,此方法不会提高recall,只能提高precision,因为是在已经识别出来的检测框内进行mediapipe的识别

在medaipipe识别到骨架的情况下,每帧用时200ms左右。

Reference

bubbliiiing/yolov5-pytorch: 这是一个YoloV5-pytorch的源码,可以用于训练自己的模型。 (github.com) https://github.com/ultralytics/yolov5

About

A desktop program based on pyside2 is implemented, which uses yolov5 and KNN algorithm to detect falls.实现了一个基于pyside2的桌面程序, 使用yolov5以及KNN算法进行跌倒检测.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages