解锁小红书“成人”新玩法,发现属于你的精致生活

核心内容摘要

HDHDHD18:解锁无限可能,重塑未来之境
倾城之姿,岂容宵小觊觎?——刻晴的英勇抉择与无畏之心

2025年免费网站推广入口:抓住机遇,引爆流量的终极指南!

1基于深度学习的暴力行为检测系统 使用 PyQt5 YOLOv811以下是您提供的基于深度学习的暴力行为检测系统的完整代码实现该系统使用PyQt5 YOLOv8 OpenCV构建支持✅ 图片/视频/摄像头实时检测✅ 暴力行为打架、推搡与非暴力行为分类✅ 界面可视化置信度、框坐标、类别✅ 支持自定义阈值和模型切换✅

项目结构TomatoDetection/ ├── data/ │ ├── train/ │ ├── val/ │ └── test/ ├── models/ │ └── best.pt # 训练好的 YOLOv8 模型 ├── ui/ │ └── MainProgram.py # 主程序 UI ├── utils/ │ └── detect.py # 推理逻辑 ├── data.yaml # 数据集配置 ├── README.txt └── main.py # 启动文件✅

数据集说明data.yaml# data.yamlpath:./datatrain:images/trainval:images/valtest:images/testnc:2names:[Violence,NonViolence] 类别说明Violence打斗、推搡、踢人等暴力行为NonViolence正常行走、站立、传球等非暴力行为 数据集来源公开体育赛事、校园监控视频剪辑人工标注共约 3000 张图像。

YOLOv8 模型训练代码可选# train.pyfromultralyticsimportYOLO modelYOLO(yolov8s.pt)# 使用小模型适合推理resultsmodel.train(datadata.yaml,epochs100,imgsz640,batch16,nameviolence_detection,cacheTrue,device0,workers8,patience

建议使用yolov8s.pt或yolov8n.pt轻量级且速度快。

主界面代码MainProgram.py# MainProgram.pyimportsysimporttimefromPyQt

QtWidgetsimportQApplication,QMainWindow,QLabel,QPushButton,QFileDialog,QVBoxLayout,QWidget,QHBoxLayout,QComboBox,QSpinBox,QTextEditfromPyQt

QtGuiimportQPixmap,QImagefromPyQt

QtCoreimportQt,QTimerimportcv2importnumpyasnpfromultralyticsimportYOLOclassMainWindow(QMainWindow):def__init__(self):super().__init__()self.setWindowTitle(基于深度学习的暴力行为检测系统)self.setGeometry(100,100,1000,

# 初始化模型self.modelYOLO(models/best.pt)self.capNoneself.timerQTimer()self.timer.timeout.connect(self.update_frame)# 创建 UI 组件self.init_ui()definit_ui(self):# 中央窗口central_widgetQWidget()self.setCentralWidget(central_widget)layoutQVBoxLayout()# 图像显示区域self.image_labelQLabel(点击打开图片或摄像头)self.image_label.setAlignment(Qt.AlignCenter)self.image_label.setStyleSheet(border: 1px solid gray; background-color: white;)layout.addWidget(self.image_label)# 控制按钮区btn_layoutQHBoxLayout()self.btn_open_imageQPushButton(打开图片)self.btn_open_videoQPushButton(打开视频)self.btn_cameraQPushButton(打开摄像头)self.btn_stopQPushButton(停止)self.btn_stop.setEnabled(False)self.btn_open_image.clicked.connect(self.open_image)self.btn_open_video.clicked.connect(self.open_video)self.btn_camera.clicked.connect(self.open_camera)self.btn_stop.clicked.connect(self.stop_capture)btn_layout.addWidget(self.btn_open_image)btn_layout.addWidget(self.btn_open_video)btn_layout.addWidget(self.btn_camera)btn_layout.addWidget(self.btn_stop)layout.addLayout(btn_layout)# 参数设置区param_layoutQHBoxLayout()self.conf_thresholdQSpinBox()self.conf_threshold.setRange(0,

self.conf_threshold.setValue(

# 默认

25self.conf_threshold.setSuffix(%)self.iou_thresholdQSpinBox()self.iou_threshold.setRange(0,

self.iou_threshold.setValue(

# 默认

45self.iou_threshold.setSuffix(%)param_layout.addWidget(QLabel(置信度阈值:))param_layout.addWidget(self.conf_threshold)param_layout.addWidget(QLabel(交并比阈值:))param_layout.addWidget(self.iou_threshold)layout.addLayout(param_layout)# 结果显示区result_layoutQVBoxLayout()self.result_labelQLabel(检测结果)self.result_textQTextEdit()self.result_text.setReadOnly(True)result_layout.addWidget(self.result_label)result_layout.addWidget(self.result_text)layout.addLayout(result_layout)central_widget.setLayout(layout)defopen_image(self):file_path,_QFileDialog.getOpenFileName(self,选择图片,,Image Files (*.jpg *.jpeg *.png))iffile_path:self.process_image(file_path)defopen_video(self):file_path,_QFileDialog.getOpenFileName(self,选择视频,,Video Files (*.mp4 *.avi *.mov))iffile_path:self.capcv

VideoCapture(file_path)self.timer.start(

self.btn_stop.setEnabled(True)defopen_camera(self):self.capcv

VideoCapture(

self.timer.start(

self.btn_stop.setEnabled(True)defstop_capture(self):self.timer.stop()ifself.cap:self.cap.release()self.capNoneself.btn_stop.setEnabled(False)defprocess_image(self,image_path):imgcv

imread(image_path)resultsself.model(img,confself.conf_threshold.value()/100,iouself.iou_threshold.value()/

annotated_imgresults[0].plot()self.display_image(annotated_img)self.show_results(results)defupdate_frame(self):ret,frameself.cap.read()ifret:resultsself.model(frame,confself.conf_threshold.value()/100,iouself.iou_threshold.value()/

annotated_frameresults[0].plot()self.display_image(annotated_frame)self.show_results(results)else:self.timer.stop()self.cap.release()self.capNonedefdisplay_image(self,img):qimgQImage(img.data,img.shape[1],img.shape[0],img.strides[0],QImage.Format_BGR

pixmapQPixmap.fromImage(qimg)self.image_label.setPixmap(pixmap.scaled(640,480,Qt.KeepAspectRatio))defshow_results(self,results):result_strforboxinresults[0].boxes:cls_idint(box.cls.item())conffloat(box.conf.item())x1,y1,x2,y2map(int,box.xyxy[0])label暴力ifcls_id0else非暴力result_strf类别:{label}, 置信度:{conf:.2f}, 位置: ({x1},{y1})~({x2},{y2})\nself.result_text.setText(result_str)if__name____main__:appQApplication(sys.argv)windowMainWindow()window.show()sys.exit(app.exec_())✅

推理模块detect.py# detect.pyfromultralyticsimportYOLOimportcv2defdetect_violence(image_path,model_pathmodels/best.pt,conf

25,iou

0.

:modelYOLO(model_path)resultsmodel(image_path,confconf,iouiou)returnresults✅

启动脚本main.py# main.pyimportsysfromPyQt

QtWidgetsimportQApplicationfromMainProgramimportMainWindowif__name____main__:appQApplication(sys.argv)windowMainWindow()window.show()sys.exit(app.exec_())✅

部署与运行

安装依赖pipinstallPyQt5 opencv-python ultralytics

运行程序python main.py✅

功能亮点功能说明️ 图片检测打开本地图片进行暴力行为识别 视频检测支持 MP4/AVI 视频文件逐帧分析 摄像头实时检测调用电脑摄像头实时预警⚙️ 可调参数置信度、IoU 阈值可动态调整 AI 分类区分“暴力” vs “非暴力”行为 结果可视化显示类别、置信度、坐标信息✅

应用场景 校园安全监控自动识别学生打架事件️ 体育赛事监测球员冲突行为 商场/车站异常行为预警 视频内容审核自动过滤暴力片段

虫虫漫画页面免费漫画在线阅读窗-虫虫漫画页面免费漫画在线阅读窗应用

百度百家号客服电话人工服务

123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123 123