首页 / 资讯中心 / 文章详情

太阳能电池板航拍红外数据集 缺陷故障目标检测数据集 识别‘热点‘, ‘PID效应‘, ‘阴影‘, ‘串联故障‘并构建基于深度学习的太阳能电池板红外缺陷检测系统

太阳能电池板航拍红外数据集 缺陷故障目标检测数据集 识别‘热点‘, ‘PID效应‘, ‘阴影‘, ‘串联故障‘并构建基于深度学习的太阳能电池板红外缺陷检测系统 ★ FEATURED ARTICLE
使用深度学习目标检测框架yolov8训练使用太阳能电池板航拍红外缺陷故障目标检测数据集来识别’热点’, ‘PID效应’, ‘阴影’, 串联故障’并构建基于深度学习的太阳能电池板红外缺陷检测系统如何训练光伏巡检太阳能电池板航拍红外缺陷故障目标检测数据集如何训练光伏巡检太阳能电池板航拍红外缺陷故障目标检测数据集2274 张 4类names: [‘Hotspot’, ‘PID’, ‘Shadow’, ‘String’]名称[‘热点’, ‘PID效应’, ‘阴影’, ‘串联故障’]8:1:1比例划分train1819张val227张test228张标注文件为YOLO适用的txt格式。可以直接用于yolo模型训练。如何训练光伏巡检太阳能电池板航拍红外缺陷故障目标检测数据集如何使用Yolov8训练训练光伏巡检太阳能电池板航拍红外缺陷故障目标检测数据集以下代码仅供参考光伏巡检太阳能电池板航拍红外缺陷故障目标检测数据集并且标注文件已经转换为YOLO适用的TXT格式我们可以直接进行模型训练、评估以及可视化。以下是详细的步骤环境准备安装必要的库。数据集组织确认数据集的结构和路径。模型定义与训练使用YOLOv8进行目标检测。评估与可视化评估模型性能。可视化结果。环境准备首先我们需要安装必要的库。您可以使用以下命令来设置环境pipinstallultralytics opencv-python-headless pandas scikit-learn数据集组织假设您的数据集已经按照YOLO格式组织好并且包含以下文件夹结构datasets/solar_panel_inspection/ ├── images/ │ ├── train/ │ │ ├── image0.jpg │ │ ├── image1.jpg │ │ └── ... │ ├── val/ │ │ ├── image0.jpg │ │ ├── image1.jpg │ │ └── ... │ └── test/ │ ├── image0.jpg │ ├── image1.jpg │ └── ... └── labels/ ├── train/ │ ├── image0.txt │ ├── image1.txt │ └── ... ├── val/ │ ├── image0.txt │ ├── image1.txt │ └── ... └── test/ ├── image0.txt ├── image1.txt └── ...并且每个图像都有一个对应的TXT标签文件。创建YAML配置文件确保您有一个正确的YAML配置文件solar_panel_inspection.yaml来描述数据集。以下是示例配置文件[titleYOLOv8 Configuration File for Solar Panel Inspection Object Detection]train:../datasets/solar_panel_inspection/images/trainval:../datasets/solar_panel_inspection/images/valtest:../datasets/solar_panel_inspection/images/testnc:4names:[Hotspot,PID,Shadow,String]将上述内容保存为datasets/solar_panel_inspection/solar_panel_inspection.yaml。模型定义与训练我们将使用YOLOv8进行目标检测。以下是训练脚本train_detection.py:[titleTraining Script for Solar Panel Inspection Object Detection using YOLOv8]fromultralyticsimportYOLO# Load a modelmodelYOLO(yolov8n.pt)# load a pretrained model (recommended for training)# Train the modelresultsmodel.train(data../datasets/solar_panel_inspection/solar_panel_inspection.yaml,epochs50,imgsz640,batch16,project../runs/train,namesolar_panel_inspection_detection)# Evaluate the modelmetricsmodel.val()resultsmodel.export(formatonnx)# export the trained model to ONNX format评估与可视化使用YOLOv8自带的评估脚本来评估目标检测模型。[titleEvaluation Script for Solar Panel Inspection Object Detection using YOLOv8]fromultralyticsimportYOLO# Load the best modelbest_modelYOLO(../runs/train/solar_panel_inspection_detection/weights/best.pt)# Evaluate the model on the validation datasetmetricsbest_model.val(data../datasets/solar_panel_inspection/solar_panel_inspection.yaml,conf0.5,iou0.45)print(metrics)用户界面我们将使用 PyQt5 创建一个简单的 GUI 来加载和运行模型进行实时预测。以下是用户界面脚本ui.py:[titlePyQt5 Main Window for Solar Panel Inspection Object Detection]importsysimportcv2importnumpyasnpfromPyQt5.QtWidgetsimportQApplication,QMainWindow,QLabel,QPushButton,QVBoxLayout,QWidget,QFileDialogfromPyQt5.QtGuiimportQImage,QPixmapfromPyQt5.QtCoreimportQt,QTimerfromultralyticsimportYOLO# Load modeldetection_modelYOLO(../runs/train/solar_panel_inspection_detection/weights/best.pt)classMainWindow(QMainWindow):def__init__(self):super().__init__()self.setWindowTitle(光伏巡检图像缺陷检测系统)self.setGeometry(100,100,800,600)self.initUI()definitUI(self):self.central_widgetQWidget()self.setCentralWidget(self.central_widget)self.layoutQVBoxLayout()self.image_labelQLabel(self)self.image_label.setAlignment(Qt.AlignCenter)self.layout.addWidget(self.image_label)self.load_image_buttonQPushButton(加载图像,self)self.load_image_button.clicked.connect(self.load_image)self.layout.addWidget(self.load_image_button)self.start_prediction_buttonQPushButton(开始预测,self)self.start_prediction_button.clicked.connect(self.start_prediction)self.layout.addWidget(self.start_prediction_button)self.stop_prediction_buttonQPushButton(停止预测,self)self.stop_prediction_button.clicked.connect(self.stop_prediction)self.layout.addWidget(self.stop_prediction_button)self.central_widget.setLayout(self.layout)self.image_pathNoneself.timerQTimer()self.timer.timeout.connect(self.update_frame)defload_image(self):optionsQFileDialog.Options()file_name,_QFileDialog.getOpenFileName(self,选择图像文件,,Images (*.png *.jpg *.jpeg);;All Files (*),optionsoptions)iffile_name:self.image_pathfile_name self.display_image(file_name)defdisplay_image(self,path):pixmapQPixmap(path)scaled_pixmappixmap.scaled(self.image_label.width(),self.image_label.height(),Qt.KeepAspectRatio)self.image_label.setPixmap(scaled_pixmap)defstart_prediction(self):ifself.image_pathisnotNoneandnotself.timer.isActive():self.timer.start(30)# Update frame every 30 msdefstop_prediction(self):ifself.timer.isActive():self.timer.stop()self.image_label.clear()defupdate_frame(self):original_imagecv2.imread(self.image_path)image_rgbcv2.cvtColor(original_image,cv2.COLOR_BGR2RGB)# Detectionresultsdetection_model.predict(image_rgb,size640,conf0.5,iou0.45)[0]forboxinresults.boxes.cpu().numpy():rbox.xyxy[0].astype(int)clsint(box.cls[0])confbox.conf[0]# Map class ID to nameclass_names[热点,PID效应,阴影,串联故障]class_nameclass_names[cls]# Draw bounding boxcv2.rectangle(image_rgb,(r[0],r[1]),(r[2],r[3]),(0,255,0),2)# Put textfontcv2.FONT_HERSHEY_SIMPLEX cv2.putText(image_rgb,f{class_name}({conf:.2f}),(r[0],r[1]-10),font,0.9,(0,255,0),2)h,w,chimage_rgb.shape bytes_per_linech*w qt_imageQImage(image_rgb.data,w,h,bytes_per_line,QImage.Format_RGB888)pixmapQPixmap.fromImage(qt_image)scaled_pixmappixmap.scaled(self.image_label.width(),self.image_label.height(),Qt.KeepAspectRatio)self.image_label.setPixmap(scaled_pixmap)if__name____main__:appQApplication(sys.argv)windowMainWindow()window.show()sys.exit(app.exec_())请确保将路径替换为您实际的路径。使用说明配置路径确保datasets/solar_panel_inspection目录结构正确并且包含images和labels子目录。确保runs/train/solar_panel_inspection_detection/weights/best.pt是训练好的 YOLOv8 模型权重路径。运行脚本在终端中运行train_detection.py脚本来训练目标检测模型。在终端中运行evaluate_detection.py来评估目标检测模型性能。在终端中运行ui.py来启动 GUI 应用程序。注意事项确保所有必要的工具箱已安装特别是ultralytics和PyQt5。根据需要调整参数如epochs和batch_size。示例假设您的数据文件夹结构如下datasets/ └── solar_panel_inspection/ ├── images/ │ ├── train/ │ │ ├── image0.jpg │ │ ├── image1.jpg │ │ └── ... │ ├── val/ │ │ ├── image0.jpg │ │ ├── image1.jpg │ │ └── ... │ └── test/ │ ├── image0.jpg │ ├── image1.jpg │ └── ... └── labels/ ├── train/ │ ├── image0.txt │ ├── image1.txt │ └── ... ├── val/ │ ├── image0.txt │ ├── image1.txt │ └── ... └── test/ ├── image0.txt ├── image1.txt └── ...并且每个图像都有一个对应的TXT标签文件。运行ui.py后您可以点击按钮来加载图像并进行光伏巡检图像缺陷检测。
阅读完成 · 觉得有帮助?
咨询建站