鄂州网站建设推广报价,网站功能描述与分析,商城网站如何建设方案,网易企业邮箱登陆入口官网一、项目介绍 本项目旨在开发一个基于前沿目标检测模型YOLOv12的固体废物自动识别系统。系统专注于对两种最常见的可回收物——瓶类#xff08;Bottle#xff09; 和 罐类#xff08;Cans#xff09; 进行高精度、实时的检测与定位。通过对包含近8000张图像的数据集进行模…一、项目介绍本项目旨在开发一个基于前沿目标检测模型YOLOv12的固体废物自动识别系统。系统专注于对两种最常见的可回收物——瓶类Bottle和罐类Cans进行高精度、实时的检测与定位。通过对包含近8000张图像的数据集进行模型训练与优化该模型能够有效学习瓶罐类废物的视觉特征为后续的自动化垃圾分类、回收流程提供核心的视觉感知能力是推动智慧环保和城市垃圾智能化管理的关键技术实践。目录一、项目介绍二、项目功能展示2.1 用户登录系统2.2 检测功能2.3 检测结果显示2.4 参数配置2.5 其他功能3. 技术特点4. 系统流程三、数据集介绍数据集配置文件四、项目环境配置创建虚拟环境安装所需要库五、模型训练训练代码训练结果六、核心代码登录注册验证 多重检测模式️ 沉浸式可视化⚙️ 参数配置系统✨ UI美学设计 智能工作流七、项目源码(视频简介)基于深度学习YOLOv12的固体垃圾废物识别检测系统YOLOv12YOLO数据集UI界面登录注册界面Python项目源码模型_哔哩哔哩_bilibili基于深度学习YOLOv12的固体垃圾废物识别检测系统YOLOv12YOLO数据集UI界面登录注册界面Python项目源码模型二、项目功能展示✅ 用户登录注册支持密码检测和安全性验证。✅ 三种检测模式基于YOLOv12模型支持图片、视频和实时摄像头三种检测精准识别目标。✅ 双画面对比同屏显示原始画面与检测结果。✅ 数据可视化实时表格展示检测目标的类别、置信度及坐标。✅智能参数调节提供置信度滑块动态优化检测精度适应不同场景需求。✅科幻风交互界面深色主题搭配动态光效减少视觉疲劳提升操作体验。✅多线程高性能架构独立检测线程保障流畅运行实时状态提示响应迅速无卡顿。​​​​​2.1 用户登录系统提供用户登录和注册功能用户名和密码验证账户信息本地存储(accounts.json)密码长度至少6位的安全要求2.2 检测功能图片检测支持JPG/JPEG/PNG/BMP格式图片的火焰烟雾检测视频检测支持MP4/AVI/MOV格式视频的逐帧检测摄像头检测实时摄像头流检测(默认摄像头0)检测结果保存到results目录2.3 检测结果显示显示原始图像和检测结果图像检测结果表格展示包含检测到的类别置信度分数物体位置坐标(x,y)、2.4 参数配置模型选择置信度阈值调节(0-1.0)IoU(交并比)阈值调节(0-1.0)实时同步滑块和数值输入框2.5 其他功能检测结果保存功能视频检测时自动保存结果视频状态栏显示系统状态和最后更新时间无边框窗口设计可拖动和调整大小3. 技术特点采用多线程处理检测任务避免界面卡顿精美的UI设计具有科技感的视觉效果发光边框和按钮悬停和按下状态效果自定义滑块、表格和下拉框样式检测结果保存机制响应式布局适应不同窗口大小4. 系统流程用户登录/注册选择检测模式(图片/视频/摄像头)调整检测参数(可选)开始检测并查看结果可选择保存检测结果停止检测或切换其他模式三、数据集介绍本系统的性能基础是一个高质量、精心标注的专用数据集。该数据集针对瓶类和罐类废物进行了大规模收集和标注确保了模型的泛化能力和鲁棒性。1. 数据集概览类别定义nc: 2数据集中共包含2个目标类别。Bottle: 泛指各种材质的瓶形容器如塑料瓶、玻璃瓶等。Cans: 泛指金属材质的罐形容器如易拉罐、金属罐头盒等。数据总量数据集图像总数共计7,967 张。数据划分为遵循机器学习最佳实践确保模型评估的客观性数据集被划分为三个独立部分训练集Training Set5,553 张图像用于模型训练让模型学习识别瓶和罐的特征。验证集Validation Set1,474 张图像用于在训练过程中调整超参数和监控模型性能防止过拟合。测试集Test Set940 张图像用于在模型训练完成后进行最终、客观的性能评估以衡量其真实的泛化能力。数据集配置文件数据集采用标准化YOLO格式组织train: F:\固体废物识别检测数据集\train\images val: F:\固体废物识别检测数据集\valid\images test: F:\固体废物识别检测数据集\test\images nc:2names: [Bottle,Cans]​​​​​​​四、项目环境配置创建虚拟环境首先新建一个Anaconda环境每个项目用不同的环境这样项目中所用的依赖包互不干扰。终端输入conda create -n yolov12 python3.9​激活虚拟环境conda activate yolov12​安装cpu版本pytorchpip install torch torchvision torchaudio​安装所需要库pip install -r requirements.txtpycharm中配置anaconda​​五、模型训练训练代码fromultralyticsimportYOLO model_path yolo12s.ptdata_path data.yamlif__name__ __main__: model YOLO(model_path) results model.train(datadata_path, epochs100, batch8, device0, workers0, projectruns, nameexp, )根据实际情况更换模型 # yolov12n.yaml (nano)轻量化模型适合嵌入式设备速度快但精度略低。 # yolov12s.yaml (small)小模型适合实时任务。 # yolov12m.yaml (medium)中等大小模型兼顾速度和精度。 # yolov12b.yaml (base)基本版模型适合大部分应用场景。 # yolov12l.yaml (large)大型模型适合对精度要求高的任务。--batch 8每批次8张图像。--epochs 100训练100轮。--datasets/data.yaml数据集配置文件。--weights yolov12s.pt初始化模型权重yolov12s.pt是预训练的轻量级YOLO模型。训练结果​​​​​​​​​​​​六、核心代码​importsysimportcv2importnumpyasnpfromPyQt5.QtWidgetsimportQApplication, QMessageBox, QFileDialogfromPyQt5.QtCoreimportQThread, pyqtSignalfromultralyticsimportYOLOfromUiMainimportUiMainWindowimporttimeimportosfromPyQt5.QtWidgetsimportQDialogfromLoginWindowimportLoginWindowclassDetectionThread(QThread): frame_received pyqtSignal(np.ndarray, np.ndarray,list)# 原始帧, 检测帧, 检测结果finished_signal pyqtSignal()# 线程完成信号def__init__(self, model, source, conf, iou, parentNone):super().__init__(parent) self.model model self.source source self.conf conf self.iou iou self.running Truedefrun(self):try:ifisinstance(self.source,int)orself.source.endswith((.mp4,.avi,.mov)):# 视频或摄像头cap cv2.VideoCapture(self.source)whileself.runningandcap.isOpened(): ret, frame cap.read()ifnotret:break# 保存原始帧original_frame frame.copy()# 检测results self.model(frame, confself.conf, iouself.iou) annotated_frame results[0].plot()# 提取检测结果detections []forresultinresults:forboxinresult.boxes: class_id int(box.cls) class_name self.model.names[class_id] confidence float(box.conf) x, y, w, h box.xywh[0].tolist() detections.append((class_name, confidence, x, y))# 发送信号self.frame_received.emit( cv2.cvtColor(original_frame, cv2.COLOR_BGR2RGB), cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB), detections )# 控制帧率time.sleep(0.03)# 约30fpscap.release()else:# 图片frame cv2.imread(self.source)ifframeisnotNone: original_frame frame.copy() results self.model(frame, confself.conf, iouself.iou) annotated_frame results[0].plot()# 提取检测结果detections []forresultinresults:forboxinresult.boxes: class_id int(box.cls) class_name self.model.names[class_id] confidence float(box.conf) x, y, w, h box.xywh[0].tolist() detections.append((class_name, confidence, x, y)) self.frame_received.emit( cv2.cvtColor(original_frame, cv2.COLOR_BGR2RGB), cv2.cvtColor(annotated_frame, cv2.COLOR_BGR2RGB), detections )exceptExceptionase:print(fDetection error:{e})finally: self.finished_signal.emit()defstop(self): self.running FalseclassMainWindow(UiMainWindow):def__init__(self):super().__init__()# 初始化模型self.model Noneself.detection_thread Noneself.current_image Noneself.current_result Noneself.video_writer Noneself.is_camera_running Falseself.is_video_running Falseself.last_detection_result None# 新增保存最后一次检测结果# 连接按钮信号self.image_btn.clicked.connect(self.detect_image) self.video_btn.clicked.connect(self.detect_video) self.camera_btn.clicked.connect(self.detect_camera) self.stop_btn.clicked.connect(self.stop_detection) self.save_btn.clicked.connect(self.save_result)# 初始化模型self.load_model()defload_model(self):try: model_name self.model_combo.currentText() self.model YOLO(f{model_name}.pt)# 自动下载或加载本地模型self.update_status(f模型{model_name}加载成功)exceptExceptionase: QMessageBox.critical(self,错误,f模型加载失败:{str(e)}) self.update_status(模型加载失败)defdetect_image(self):ifself.detection_threadandself.detection_thread.isRunning(): QMessageBox.warning(self,警告,请先停止当前检测任务)returnfile_path, _ QFileDialog.getOpenFileName( self,选择图片,,图片文件 (*.jpg *.jpeg *.png *.bmp))iffile_path: self.clear_results() self.current_image cv2.imread(file_path) self.current_image cv2.cvtColor(self.current_image, cv2.COLOR_BGR2RGB) self.display_image(self.original_image_label, self.current_image)# 创建检测线程conf self.confidence_spinbox.value() iou self.iou_spinbox.value() self.detection_thread DetectionThread(self.model, file_path, conf, iou) self.detection_thread.frame_received.connect(self.on_frame_received) self.detection_thread.finished_signal.connect(self.on_detection_finished) self.detection_thread.start() self.update_status(f正在检测图片:{os.path.basename(file_path)})defdetect_video(self):ifself.detection_threadandself.detection_thread.isRunning(): QMessageBox.warning(self,警告,请先停止当前检测任务)returnfile_path, _ QFileDialog.getOpenFileName( self,选择视频,,视频文件 (*.mp4 *.avi *.mov))iffile_path: self.clear_results() self.is_video_running True# 初始化视频写入器cap cv2.VideoCapture(file_path) frame_width int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) frame_height int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) fps cap.get(cv2.CAP_PROP_FPS) cap.release()# 创建保存路径save_dir resultsos.makedirs(save_dir, exist_okTrue) timestamp time.strftime(%Y%m%d_%H%M%S) save_path os.path.join(save_dir,fresult_{timestamp}.mp4) fourcc cv2.VideoWriter_fourcc(*mp4v) self.video_writer cv2.VideoWriter(save_path, fourcc, fps, (frame_width, frame_height))# 创建检测线程conf self.confidence_spinbox.value() iou self.iou_spinbox.value() self.detection_thread DetectionThread(self.model, file_path, conf, iou) self.detection_thread.frame_received.connect(self.on_frame_received) self.detection_thread.finished_signal.connect(self.on_detection_finished) self.detection_thread.start() self.update_status(f正在检测视频:{os.path.basename(file_path)})defdetect_camera(self):ifself.detection_threadandself.detection_thread.isRunning(): QMessageBox.warning(self,警告,请先停止当前检测任务)returnself.clear_results() self.is_camera_running True# 创建检测线程 (默认使用摄像头0)conf self.confidence_spinbox.value() iou self.iou_spinbox.value() self.detection_thread DetectionThread(self.model,0, conf, iou) self.detection_thread.frame_received.connect(self.on_frame_received) self.detection_thread.finished_signal.connect(self.on_detection_finished) self.detection_thread.start() self.update_status(正在从摄像头检测...)登录注册验证对应文件LoginWindow.py# 账户验证核心逻辑defhandle_login(self): username self.username_input.text().strip() password self.password_input.text().strip()ifnotusernameornotpassword: QMessageBox.warning(self,警告,用户名和密码不能为空)returnifusernameinself.accountsandself.accounts[username] password: self.accept()# 验证通过else: QMessageBox.warning(self,错误,用户名或密码错误)# 密码强度检查注册时defhandle_register(self):iflen(password) 6:# 密码长度≥6位QMessageBox.warning(self,警告,密码长度至少为6位)多重检测模式对应文件main.py图片检测defdetect_image(self): file_path, _ QFileDialog.getOpenFileName( self,选择图片,,图片文件 (*.jpg *.jpeg *.png *.bmp))iffile_path: self.detection_thread DetectionThread(self.model, file_path, conf, iou) self.detection_thread.start()# 启动检测线程视频检测defdetect_video(self): file_path, _ QFileDialog.getOpenFileName( self,选择视频,,视频文件 (*.mp4 *.avi *.mov))iffile_path: self.video_writer cv2.VideoWriter()# 初始化视频写入器self.detection_thread DetectionThread(self.model, file_path, conf, iou)实时摄像头defdetect_camera(self): self.detection_thread DetectionThread(self.model,0, conf, iou)# 摄像头设备号0self.detection_thread.start()️沉浸式可视化对应文件UiMain.py双画面显示defdisplay_image(self, label, image): q_img QImage(image.data, w, h, bytes_per_line, QImage.Format_RGB888) pixmap QPixmap.fromImage(q_img) label.setPixmap(pixmap.scaled(label.size(), Qt.KeepAspectRatio))# 自适应缩放结果表格defadd_detection_result(self, class_name, confidence, x, y): self.results_table.insertRow(row) items [ QTableWidgetItem(class_name),# 类别列QTableWidgetItem(f{confidence:.2f}),# 置信度QTableWidgetItem(f{x:.1f}),# X坐标QTableWidgetItem(f{y:.1f})# Y坐标]⚙️参数配置系统对应文件UiMain.py双阈值联动控制# 置信度阈值同步defupdate_confidence(self, value): confidence value /100.0self.confidence_spinbox.setValue(confidence)# 滑块→数值框self.confidence_label.setText(f置信度阈值:{confidence:.2f})# IoU阈值同步defupdate_iou(self, value): iou value /100.0self.iou_spinbox.setValue(iou)✨UI美学设计对应文件UiMain.py科幻风格按钮defcreate_button(self, text, color):returnf QPushButton {{ border: 1px solid{color}; color:{color}; border-radius: 6px; }} QPushButton:hover {{ background-color:{self.lighten_color(color,10)}; box-shadow: 0 0 10px{color}; # 悬停发光效果 }} 动态状态栏defupdate_status(self, message): self.status_bar.showMessage(f状态:{message}| 最后更新:{time.strftime(%H:%M:%S)}# 实时时间戳)智能工作流对应文件main.py线程管理classDetectionThread(QThread): frame_received pyqtSignal(np.ndarray, np.ndarray,list)# 信号量通信defrun(self):whileself.running:# 多线程检测循环results self.model(frame, confself.conf, iouself.iou) self.frame_received.emit(original_frame, result_frame, detections)七、项目源码(视频简介)​​演示与介绍视频基于深度学习YOLOv12的固体垃圾废物识别检测系统YOLOv12YOLO数据集UI界面登录注册界面Python项目源码模型_哔哩哔哩_bilibili基于深度学习YOLOv12的固体垃圾废物识别检测系统YOLOv12YOLO数据集UI界面登录注册界面Python项目源码模型