航拍电网连接端识别检测数据集 yolo数据集 1200张标注名称以及数量:5330261287航拍电网连接端识别检测航拍电网连接端识别检测基于航拍电网连接端识别检测数据集进行目标检测任务。数据集包含1200张图片并且已经标注为YOLO格式。具体类别及其数量如下类别5: 3302个实例类别6: 1287个实例备注文章代码仅供参考环境准备确保您已经安装了以下软件和库Python 3.8 或更高版本PyTorch 1.9 或更高版本torchvision 0.10 或更高版本OpenCVnumpypandasmatplotlibalbumentations用于数据增强您可以使用以下命令安装所需的Python库pipinstalltorch torchvision opencv-python numpy pandas matplotlib albumentations数据集准备假设您的数据集已经按照YOLO格式组织好并且包含训练集、验证集和测试集。以下是数据集的预期结构datasets/ └── grid_connection_points/ ├── images/ │ ├── train/ │ ├── val/ │ └── test/ └── labels/ ├── train/ ├── val/ └── test/同时有一个classes.txt文件包含类别名称每行一个类别名称。类别文件 (classes.txt)connection_point_5 connection_point_6模型训练我们将使用YOLOv5进行训练。首先克隆YOLOv5仓库并设置环境。gitclone https://github.com/ultralytics/yolov5.gitcdyolov5 pipinstall-rrequirements.txt准备配置文件创建一个hyp.scratch.yaml文件来定义超参数# Hyperparameters for YOLOv5 training from scratchlr0:0.01# initial learning rate (SGD1E-2, Adam1E-3)lrf:0.1# final OneCycleLR learning rate (lr0 * lrf)momentum:0.937# SGD momentum/Adam beta1weight_decay:0.0005# optimizer weight decay 5e-4warmup_epochs:3.0# warmup epochs (fractions ok)warmup_momentum:0.8# warmup initial momentumwarmup_bias_lr:0.1# warmup initial bias lrbox:0.05# box loss gaincls:0.5# cls loss gaincls_pw:1.0# cls BCELoss positive_weightobj:1.0# obj loss gain (scale with pixels)obj_pw:1.0# obj BCELoss positive_weightiou_t:0.20# IoU training thresholdanchor_t:4.0# anchor-multiple thresholdfl_gamma:0.0# focal loss gamma (efficientDet default gamma1.5)hsv_h:0.015# image HSV-Hue augmentation (fraction)hsv_s:0.7# image HSV-Saturation augmentation (fraction)hsv_v:0.4# image HSV-Value augmentation (fraction)degrees:0.0# image rotation (/- deg)translate:0.1# image translation (/- fraction)scale:0.5# image scale (/- gain)shear:0.0# image shear (/- deg)perspective:0.0# image perspective (/- fraction), range 0-0.001flipud:0.0# image flip up-down (probability)fliplr:0.5# image flip left-right (probability)mosaic:1.0# image mosaic (probability)mixup:0.0# image mixup (probability)copy_paste:0.0# segment copy-paste (probability)paste_in:0.0# segment paste-in (probability)rect:0# rectangular trainingresume:false# resume training from last checkpointnosave:false# only save final checkpointnoval:false# only validate final epochnoautoanchor:true# disable AutoAnchorevolve:false# evolve hyperparametersbucket:# gsutil bucketcache_images:false# cache images for faster trainingimage_weights:false# use weighted image selection for trainingsingle_cls:false# train multi-class data as single-classoptimizer:SGD# optimizer: SGD or AdamWsync_bn:false# use SyncBatchNorm, only available in DDP modeworkers:8# dataloader workers (max is number of CPU cores)freeze:0# freeze first n layersv5_metric:true# assume maximum recall as 1.0 in AP calculationmulti_scale:true# vary input size between 320 and 640 pixelsrect_training:false# rectangular trainingcos_lr:false# cosine LR schedulerclose_mosaic:1000# close mosaic borderscales:[0.5,1.5]# image size scalesaugment:true# augment dataverbose:false# verbose printseed:0# random seed for reproducibilitylocal_rank:-1# ddp device id (-1 for single gpu train)entity:null# WB entityupload_dataset:False# upload dataset as WB artifact tablebbox_interval:-1# WB bounding box logging intervalartifact_alias:latest# version of dataset artifact to useproject:runs/train# save results to project/nameexist_ok:false# existing project/name ok, do not incrementquad:false# quadrilateral anchorslinear_assignment:false# use linear assignment for NMS创建一个data.yaml文件来定义数据集路径和类别train:../datasets/grid_connection_points/images/train/val:../datasets/grid_connection_points/images/val/nc:2# number of classesnames:[connection_point_5,connection_point_6]# list of class names训练模型使用以下命令开始训练python train.py--img640--batch16--epochs50--datadata.yaml--cfgyolov5s.yaml--weightsyolov5s.pt--hyphyp.scratch.yaml结果评估训练完成后可以使用以下命令评估模型性能python val.py--datadata.yaml--weightsruns/train/exp/weights/best.pt--tasktest使用说明配置路径确保datasets/grid_connection_points/目录结构正确。确保data.yaml中的路径和类别名称正确。运行脚本在终端中依次运行训练脚本和评估脚本。注意事项根据需要调整超参数和训练设置。可以通过修改data.yaml中的cfg参数来选择不同的YOLOv5模型架构如yolov5m.yaml,yolov5l.yaml,yolov5x.yaml。示例假设您的数据集文件夹结构如下datasets/ └── grid_connection_points/ ├── images/ │ ├── train/ │ ├── val/ │ └── test/ └── labels/ ├── train/ ├── val/ └── test/并且images/和labels/目录分别包含对应的图片和标注文件。运行上述脚本后您可以查看训练日志和最终的模型权重文件。总结