張家港外貿網站制作網站建設師薪資
鶴壁市浩天電氣有限公司
2026/01/24 09:11:46
張家港外貿網站制作,網站建設師薪資,wordpress數(shù)據(jù)改網址,做網站年入多少一、項目介紹
本項目基于YOLOv8目標檢測算法開發(fā)了一套騎手佩戴頭盔檢測系統(tǒng)#xff0c;專注于識別摩托車騎乘場景中的三類關鍵目標#xff1a;頭盔#xff08;helmet#xff09;、車牌#xff08;license_plate#xff09;和騎手#xff08;motorcyclist#xff09;?!弧㈨椖拷榻B本項目基于YOLOv8目標檢測算法開發(fā)了一套騎手佩戴頭盔檢測系統(tǒng)專注于識別摩托車騎乘場景中的三類關鍵目標頭盔helmet、車牌license_plate和騎手motorcyclist。該系統(tǒng)可廣泛應用于交通執(zhí)法與安全監(jiān)管場景輔助提升道路安全管理的智能化水平。YOLOv8的高精度與高效率架構確保了在復雜環(huán)境下仍能保持可靠的檢測性能為違規(guī)行為識別和證據(jù)采集提供技術支持。數(shù)據(jù)集共包含1,803張圖像按功能劃分為訓練集1,563張、驗證集140張和測試集100張。數(shù)據(jù)內容覆蓋多種光照條件、角度及遮擋場景標注包含上述三個類別注重頭盔與騎手的關聯(lián)性以及車牌的清晰度。數(shù)據(jù)規(guī)模雖有限但通過增強和優(yōu)化標注策略仍可有效支撐模型學習局部特征與上下文關系為實際應用提供基礎數(shù)據(jù)保障。目錄一、項目介紹二、項目功能展示系統(tǒng)功能圖片檢測視頻檢測攝像頭實時檢測三、數(shù)據(jù)集介紹數(shù)據(jù)集概述數(shù)據(jù)集特點數(shù)據(jù)集配置文件數(shù)據(jù)集制作流程四、項目環(huán)境配置創(chuàng)建虛擬環(huán)境pycharm中配置anaconda安裝所需要庫五、模型訓練訓練代碼訓練結果六、核心代碼?編輯七、項目源碼(視頻簡介內)基于深度學習YOLOv8的騎手佩戴頭盔檢測系統(tǒng)YOLOv8YOLO數(shù)據(jù)集UI界面Python項目源碼模型_嗶哩嗶哩_bilibili基于深度學習YOLOv8的騎手佩戴頭盔檢測系統(tǒng)YOLOv8YOLO數(shù)據(jù)集UI界面Python項目源碼模型二、項目功能展示系統(tǒng)功能?圖片檢測可對圖片進行檢測返回檢測框及類別信息。?視頻檢測支持視頻文件輸入檢測視頻中每一幀的情況。?攝像頭實時檢測連接USB 攝像頭實現(xiàn)實時監(jiān)測。?參數(shù)實時調節(jié)置信度和IoU閾值圖片檢測該功能允許用戶通過單張圖片進行目標檢測。輸入一張圖片后YOLO模型會實時分析圖像識別出其中的目標并在圖像中框出檢測到的目標輸出帶有目標框的圖像。視頻檢測視頻檢測功能允許用戶將視頻文件作為輸入。YOLO模型將逐幀分析視頻并在每一幀中標記出檢測到的目標。最終結果可以是帶有目標框的視頻文件或實時展示適用于視頻監(jiān)控和分析等場景。攝像頭實時檢測該功能支持通過連接攝像頭進行實時目標檢測。YOLO模型能夠在攝像頭拍攝的實時視頻流中進行目標檢測實時識別并顯示檢測結果。此功能非常適用于安防監(jiān)控、無人駕駛、智能交通等應用提供即時反饋。核心特點高精度基于YOLO模型提供精確的目標檢測能力適用于不同類型的圖像和視頻。實時性特別優(yōu)化的算法使得實時目標檢測成為可能無論是在視頻還是攝像頭實時檢測中響應速度都非常快。批量處理支持高效的批量圖像和視頻處理適合大規(guī)模數(shù)據(jù)分析。三、數(shù)據(jù)集介紹數(shù)據(jù)集概述數(shù)據(jù)集共包含1,803張圖像按功能劃分為訓練集1,563張、驗證集140張和測試集100張。數(shù)據(jù)內容覆蓋多種光照條件、角度及遮擋場景標注包含上述三個類別注重頭盔與騎手的關聯(lián)性以及車牌的清晰度。數(shù)據(jù)規(guī)模雖有限但通過增強和優(yōu)化標注策略仍可有效支撐模型學習局部特征與上下文關系為實際應用提供基礎數(shù)據(jù)保障。數(shù)據(jù)集配置文件數(shù)據(jù)集采用YOLO格式的配置文件主要包含以下內容train: 騎手佩戴頭盔檢測數(shù)據(jù)集 rainimages val:騎手佩戴頭盔檢測數(shù)據(jù)集validimages test: 騎手佩戴頭盔檢測數(shù)據(jù)集 estimages nc: 3 names: [helmet, license_plate, motorcyclist]四、項目環(huán)境配置創(chuàng)建虛擬環(huán)境首先新建一個Anaconda環(huán)境每個項目用不同的環(huán)境這樣項目中所用的依賴包互不干擾。終端輸入conda create -n yolov8 python3.9激活虛擬環(huán)境conda activate yolov8安裝cpu版本pytorchpip install torch torchvision torchaudiopycharm中配置anaconda安裝所需要庫pip install -r requirements.txt五、模型訓練訓練代碼from ultralytics import YOLO model_path yolov8s.pt data_path datasets/data.yaml if __name__ __main__: model YOLO(model_path) results model.train(datadata_path, epochs500, batch64, device0, workers0, projectruns/detect, nameexp, )根據(jù)實際情況更換模型 yolov8n.yaml (nano)輕量化模型適合嵌入式設備速度快但精度略低。 yolov8s.yaml (small)小模型適合實時任務。 yolov8m.yaml (medium)中等大小模型兼顧速度和精度。 yolov8b.yaml (base)基本版模型適合大部分應用場景。 yolov8l.yaml (large)大型模型適合對精度要求高的任務。--batch 64每批次64張圖像。--epochs 500訓練500輪。--datasets/data.yaml數(shù)據(jù)集配置文件。--weights yolov8s.pt初始化模型權重yolov8s.pt是預訓練的輕量級YOLO模型。訓練結果六、核心代碼from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import Qt, QTimer from PyQt5.QtGui import QImage, QPixmap, QIcon from PyQt5.QtWidgets import (QFileDialog, QMessageBox, QTableWidgetItem, QStyledItemDelegate, QHeaderView) import cv2 import numpy as np from ultralytics import YOLO import os import datetime import sys class CenteredDelegate(QStyledItemDelegate): def initStyleOption(self, option, index): super().initStyleOption(option, index) option.displayAlignment Qt.AlignCenter class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName(MainWindow) MainWindow.resize(1400, 900) MainWindow.setWindowTitle(YOLOv8 目標檢測系統(tǒng)) # 設置窗口圖標 if hasattr(sys, _MEIPASS): icon_path os.path.join(sys._MEIPASS, icon.ico) else: icon_path icon.ico if os.path.exists(icon_path): MainWindow.setWindowIcon(QIcon(icon_path)) self.centralwidget QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName(centralwidget) # 主布局 self.main_layout QtWidgets.QHBoxLayout(self.centralwidget) self.main_layout.setContentsMargins(10, 10, 10, 10) self.main_layout.setSpacing(15) # 左側布局 (圖像顯示) self.left_layout QtWidgets.QVBoxLayout() self.left_layout.setSpacing(15) # 原始圖像組 self.original_group QtWidgets.QGroupBox(原始圖像) self.original_group.setMinimumHeight(400) self.original_img_label QtWidgets.QLabel() self.original_img_label.setAlignment(QtCore.Qt.AlignCenter) self.original_img_label.setText(等待加載圖像...) self.original_img_label.setStyleSheet(background-color: #F0F0F0; border: 1px solid #CCCCCC;) original_layout QtWidgets.QVBoxLayout() original_layout.addWidget(self.original_img_label) self.original_group.setLayout(original_layout) self.left_layout.addWidget(self.original_group) # 檢測結果圖像組 self.result_group QtWidgets.QGroupBox(檢測結果) self.result_group.setMinimumHeight(400) self.result_img_label QtWidgets.QLabel() self.result_img_label.setAlignment(QtCore.Qt.AlignCenter) self.result_img_label.setText(檢測結果將顯示在這里) self.result_img_label.setStyleSheet(background-color: #F0F0F0; border: 1px solid #CCCCCC;) result_layout QtWidgets.QVBoxLayout() result_layout.addWidget(self.result_img_label) self.result_group.setLayout(result_layout) self.left_layout.addWidget(self.result_group) self.main_layout.addLayout(self.left_layout, stretch3) # 右側布局 (控制面板) self.right_layout QtWidgets.QVBoxLayout() self.right_layout.setSpacing(15) # 模型選擇組 self.model_group QtWidgets.QGroupBox(模型設置) self.model_group.setStyleSheet(QGroupBox { font-weight: bold; }) self.model_layout QtWidgets.QVBoxLayout() # 模型選擇 self.model_combo QtWidgets.QComboBox() self.model_combo.addItems([best.pt]) self.model_combo.setCurrentIndex(0) # 加載模型按鈕 self.load_model_btn QtWidgets.QPushButton( 加載模型) self.load_model_btn.setIcon(QIcon.fromTheme(document-open)) self.load_model_btn.setStyleSheet( QPushButton { padding: 8px; background-color: #4CAF50; color: white; border-radius: 4px; } QPushButton:hover { background-color: #45a049; } ) self.model_layout.addWidget(self.model_combo) self.model_layout.addWidget(self.load_model_btn) self.model_group.setLayout(self.model_layout) self.right_layout.addWidget(self.model_group) # 參數(shù)設置組 self.param_group QtWidgets.QGroupBox(檢測參數(shù)) self.param_group.setStyleSheet(QGroupBox { font-weight: bold; }) self.param_layout QtWidgets.QFormLayout() self.param_layout.setLabelAlignment(Qt.AlignLeft) self.param_layout.setFormAlignment(Qt.AlignLeft) self.param_layout.setVerticalSpacing(15) # 置信度滑塊 self.conf_slider QtWidgets.QSlider(Qt.Horizontal) self.conf_slider.setRange(1, 99) self.conf_slider.setValue(25) self.conf_value QtWidgets.QLabel(0.25) self.conf_value.setAlignment(Qt.AlignCenter) self.conf_value.setStyleSheet(font-weight: bold; color: #2196F3;) # IoU滑塊 self.iou_slider QtWidgets.QSlider(Qt.Horizontal) self.iou_slider.setRange(1, 99) self.iou_slider.setValue(45) self.iou_value QtWidgets.QLabel(0.45) self.iou_value.setAlignment(Qt.AlignCenter) self.iou_value.setStyleSheet(font-weight: bold; color: #2196F3;) self.param_layout.addRow(置信度閾值:, self.conf_slider) self.param_layout.addRow(當前值:, self.conf_value) self.param_layout.addRow(QtWidgets.QLabel()) # 空行 self.param_layout.addRow(IoU閾值:, self.iou_slider) self.param_layout.addRow(當前值:, self.iou_value) self.param_group.setLayout(self.param_layout) self.right_layout.addWidget(self.param_group) # 功能按鈕組 self.func_group QtWidgets.QGroupBox(檢測功能) self.func_group.setStyleSheet(QGroupBox { font-weight: bold; }) self.func_layout QtWidgets.QVBoxLayout() self.func_layout.setSpacing(10) # 圖片檢測按鈕 self.image_btn QtWidgets.QPushButton( 圖片檢測) self.image_btn.setIcon(QIcon.fromTheme(image-x-generic)) # 視頻檢測按鈕 self.video_btn QtWidgets.QPushButton( 視頻檢測) self.video_btn.setIcon(QIcon.fromTheme(video-x-generic)) # 攝像頭檢測按鈕 self.camera_btn QtWidgets.QPushButton( 攝像頭檢測) self.camera_btn.setIcon(QIcon.fromTheme(camera-web)) # 停止檢測按鈕 self.stop_btn QtWidgets.QPushButton( 停止檢測) self.stop_btn.setIcon(QIcon.fromTheme(process-stop)) self.stop_btn.setEnabled(False) # 保存結果按鈕 self.save_btn QtWidgets.QPushButton( 保存結果) self.save_btn.setIcon(QIcon.fromTheme(document-save)) self.save_btn.setEnabled(False) # 設置按鈕樣式 button_style QPushButton { padding: 10px; background-color: #2196F3; color: white; border: none; border-radius: 4px; text-align: left; } QPushButton:hover { background-color: #0b7dda; } QPushButton:disabled { background-color: #cccccc; } for btn in [self.image_btn, self.video_btn, self.camera_btn, self.stop_btn, self.save_btn]: btn.setStyleSheet(button_style) self.func_layout.addWidget(btn) self.func_group.setLayout(self.func_layout) self.right_layout.addWidget(self.func_group) # 檢測結果表格組 self.table_group QtWidgets.QGroupBox(檢測結果詳情) self.table_group.setStyleSheet(QGroupBox { font-weight: bold; }) self.table_layout QtWidgets.QVBoxLayout() self.result_table QtWidgets.QTableWidget() self.result_table.setColumnCount(4) self.result_table.setHorizontalHeaderLabels([類別, 置信度, 左上坐標, 右下坐標]) self.result_table.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.result_table.verticalHeader().setVisible(False) self.result_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) self.result_table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) # 設置表格樣式 self.result_table.setStyleSheet( QTableWidget { border: 1px solid #e0e0e0; alternate-background-color: #f5f5f5; } QHeaderView::section { background-color: #2196F3; color: white; padding: 5px; border: none; } QTableWidget::item { padding: 5px; } ) # 設置居中代理 delegate CenteredDelegate(self.result_table) self.result_table.setItemDelegate(delegate) self.table_layout.addWidget(self.result_table) self.table_group.setLayout(self.table_layout) self.right_layout.addWidget(self.table_group, stretch1) self.main_layout.addLayout(self.right_layout, stretch1) MainWindow.setCentralWidget(self.centralwidget) # 狀態(tài)欄 self.statusbar QtWidgets.QStatusBar(MainWindow) self.statusbar.setStyleSheet(QStatusBar { border-top: 1px solid #c0c0c0; }) MainWindow.setStatusBar(self.statusbar) # 初始化變量 self.model None self.cap None self.timer QTimer() self.is_camera_running False self.current_image None self.current_result None self.video_writer None self.output_path output # 創(chuàng)建輸出目錄 if not os.path.exists(self.output_path): os.makedirs(self.output_path) # 連接信號槽 self.load_model_btn.clicked.connect(self.load_model) 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.conf_slider.valueChanged.connect(self.update_conf_value) self.iou_slider.valueChanged.connect(self.update_iou_value) self.timer.timeout.connect(self.update_camera_frame) # 設置全局樣式 self.set_style() def set_style(self): style QMainWindow { background-color: #f5f5f5; } QGroupBox { border: 1px solid #e0e0e0; border-radius: 5px; margin-top: 10px; padding-top: 15px; } QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px; } QLabel { color: #333333; } QComboBox { padding: 5px; border: 1px solid #cccccc; border-radius: 3px; } QSlider::groove:horizontal { height: 6px; background: #e0e0e0; border-radius: 3px; } QSlider::handle:horizontal { width: 16px; height: 16px; margin: -5px 0; background: #2196F3; border-radius: 8px; } QSlider::sub-page:horizontal { background: #2196F3; border-radius: 3px; } self.centralwidget.setStyleSheet(style) def load_model(self): model_name self.model_combo.currentText().split( )[0] try: self.model YOLO(model_name) self.statusbar.showMessage(f模型 {model_name} 加載成功, 3000) self.image_btn.setEnabled(True) self.video_btn.setEnabled(True) self.camera_btn.setEnabled(True) except Exception as e: QMessageBox.critical(None, 錯誤, f模型加載失敗: {str(e)}) def update_conf_value(self): conf self.conf_slider.value() / 100 self.conf_value.setText(f{conf:.2f}) def update_iou_value(self): iou self.iou_slider.value() / 100 self.iou_value.setText(f{iou:.2f}) def detect_image(self): if self.model is None: QMessageBox.warning(None, 警告, 請先加載模型) return file_path, _ QFileDialog.getOpenFileName( None, 選擇圖片, , 圖片文件 (*.jpg *.jpeg *.png *.bmp);;所有文件 (*) ) if file_path: try: # 讀取圖片 img cv2.imread(file_path) img cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # 顯示原始圖片 self.display_image(img, self.original_img_label) self.current_image img.copy() # 檢測圖片 conf self.conf_slider.value() / 100 iou self.iou_slider.value() / 100 self.statusbar.showMessage(正在檢測圖片...) QtWidgets.QApplication.processEvents() # 更新UI results self.model.predict(img, confconf, iouiou) result_img results[0].plot() # 顯示檢測結果 self.display_image(result_img, self.result_img_label) self.current_result result_img.copy() # 更新結果表格 self.update_result_table(results[0]) self.save_btn.setEnabled(True) self.statusbar.showMessage(f圖片檢測完成: {os.path.basename(file_path)}, 3000) except Exception as e: QMessageBox.critical(None, 錯誤, f圖片檢測失敗: {str(e)}) self.statusbar.showMessage(圖片檢測失敗, 3000) def detect_video(self): if self.model is None: QMessageBox.warning(None, 警告, 請先加載模型) return file_path, _ QFileDialog.getOpenFileName( None, 選擇視頻, , 視頻文件 (*.mp4 *.avi *.mov *.mkv);;所有文件 (*) ) if file_path: try: self.cap cv2.VideoCapture(file_path) if not self.cap.isOpened(): raise Exception(無法打開視頻文件) # 獲取視頻信息 fps self.cap.get(cv2.CAP_PROP_FPS) width int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH)) height int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) # 創(chuàng)建視頻寫入器 timestamp datetime.datetime.now().strftime(%Y%m%d_%H%M%S) output_file os.path.join(self.output_path, foutput_{timestamp}.mp4) fourcc cv2.VideoWriter_fourcc(*mp4v) self.video_writer cv2.VideoWriter(output_file, fourcc, fps, (width, height)) # 啟用停止按鈕禁用其他按鈕 self.stop_btn.setEnabled(True) self.save_btn.setEnabled(True) self.image_btn.setEnabled(False) self.video_btn.setEnabled(False) self.camera_btn.setEnabled(False) # 開始處理視頻 self.timer.start(30) # 30ms間隔 self.statusbar.showMessage(f正在處理視頻: {os.path.basename(file_path)}...) except Exception as e: QMessageBox.critical(None, 錯誤, f視頻檢測失敗: {str(e)}) self.statusbar.showMessage(視頻檢測失敗, 3000)七、項目源碼(視頻簡介內)演示與介紹視頻基于深度學習YOLOv8的騎手佩戴頭盔檢測系統(tǒng)YOLOv8YOLO數(shù)據(jù)集UI界面Python項目源碼模型_嗶哩嗶哩_bilibili基于深度學習YOLOv8的騎手佩戴頭盔檢測系統(tǒng)YOLOv8YOLO數(shù)據(jù)集UI界面Python項目源碼模型