最新推送
This commit is contained in:
18
zjsh_code/obb_main/train/obb_data.yaml
Normal file
18
zjsh_code/obb_main/train/obb_data.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
# DOTA8 dataset 8 images from split DOTAv1 dataset by Ultralytics
|
||||
# Documentation: https://docs.ultralytics.com/datasets/obb/dota8/
|
||||
# Example usage: yolo train model=yolov8n-obb.pt data=dota8.yaml
|
||||
# parent
|
||||
# ├── ultralytics
|
||||
# └── datasets
|
||||
# └── dota8 ← downloads here (1MB)
|
||||
|
||||
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
|
||||
path: ./dataset
|
||||
train: train # 数据集路径下的train.txt
|
||||
val: val # 数据集路径下的val.txt
|
||||
test: test # 数据集路径下的test.txt
|
||||
|
||||
nc: 1
|
||||
names: ['clamp']
|
||||
|
||||
42
zjsh_code/obb_main/train/train_obb_zengqiang.py
Normal file
42
zjsh_code/obb_main/train/train_obb_zengqiang.py
Normal file
@ -0,0 +1,42 @@
|
||||
from ultralytics import YOLO
|
||||
|
||||
if __name__ == '__main__':
|
||||
# ✅ 推荐:加载官方预训练模型 或 自己的 best.pt
|
||||
model = YOLO(r'yolo11-obb.yaml') #
|
||||
|
||||
results = model.train(
|
||||
data='obb_data.yaml',
|
||||
epochs=500, # 减少 epochs,配合早停
|
||||
patience=0, # 50 轮无提升则停止
|
||||
imgsz=640,
|
||||
batch=4,
|
||||
workers=10,
|
||||
device='0',
|
||||
project='runs/train',
|
||||
name='exp_obb5', # 建议递增实验编号
|
||||
exist_ok=False,
|
||||
|
||||
# 优化器
|
||||
optimizer='AdamW',
|
||||
lr0=0.0005, # 更稳定的学习率
|
||||
weight_decay=0.01,
|
||||
momentum=0.937,
|
||||
|
||||
# 数据增强(OBB 关键)
|
||||
degrees=5.0, # 随机旋转 ±10°
|
||||
translate=0.1, # 平移
|
||||
scale=0.5, # 缩放比例
|
||||
shear=1.0, # 剪切
|
||||
flipud=0.0, # 不推荐上下翻转(角度易错)
|
||||
fliplr=0.5, # ✅ 水平翻转,OBB 支持良好
|
||||
hsv_h=0.015, # 色调扰动
|
||||
hsv_s=0.7, # 饱和度
|
||||
hsv_v=0.4, # 明度
|
||||
|
||||
# 其他
|
||||
close_mosaic=50, # 最后10轮关闭 Mosaic 增强,提升稳定性
|
||||
val=True, # 每轮验证
|
||||
|
||||
#
|
||||
amp=False,
|
||||
)
|
||||
47
zjsh_code/obb_main/train/yolo11-obb.yaml
Normal file
47
zjsh_code/obb_main/train/yolo11-obb.yaml
Normal file
@ -0,0 +1,47 @@
|
||||
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
||||
# YOLO11 Oriented Bounding Boxes (OBB) model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/obb
|
||||
|
||||
# Parameters
|
||||
nc: 1 # number of classes
|
||||
scales: # model compound scaling constants, i.e. 'model=yolo11n-obb.yaml' will call yolo11-obb.yaml with scale 'n'
|
||||
# [depth, width, max_channels]
|
||||
n: [0.50, 0.25, 1024] # summary: 344 layers, 2695747 parameters, 2695731 gradients, 6.9 GFLOPs
|
||||
s: [0.50, 0.50, 1024] # summary: 344 layers, 9744931 parameters, 9744915 gradients, 22.7 GFLOPs
|
||||
m: [0.50, 1.00, 512] # summary: 434 layers, 20963523 parameters, 20963507 gradients, 72.2 GFLOPs
|
||||
l: [1.00, 1.00, 512] # summary: 656 layers, 26220995 parameters, 26220979 gradients, 91.3 GFLOPs
|
||||
x: [1.00, 1.50, 512] # summary: 656 layers, 58875331 parameters, 58875315 gradients, 204.3 GFLOPs
|
||||
|
||||
# YOLO11n backbone
|
||||
backbone:
|
||||
# [from, repeats, module, args]
|
||||
- [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
|
||||
- [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
|
||||
- [-1, 2, C3k2, [256, False, 0.25]]
|
||||
- [-1, 1, Conv, [256, 3, 2]] # 3-P3/8
|
||||
- [-1, 2, C3k2, [512, False, 0.25]]
|
||||
- [-1, 1, Conv, [512, 3, 2]] # 5-P4/16
|
||||
- [-1, 2, C3k2, [512, True]]
|
||||
- [-1, 1, Conv, [1024, 3, 2]] # 7-P5/32
|
||||
- [-1, 2, C3k2, [1024, True]]
|
||||
- [-1, 1, SPPF, [1024, 5]] # 9
|
||||
- [-1, 2, C2PSA, [1024]] # 10
|
||||
|
||||
# YOLO11n head
|
||||
head:
|
||||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
||||
- [[-1, 6], 1, Concat, [1]] # cat backbone P4
|
||||
- [-1, 2, C3k2, [512, False]] # 13
|
||||
|
||||
- [-1, 1, nn.Upsample, [None, 2, "nearest"]]
|
||||
- [[-1, 4], 1, Concat, [1]] # cat backbone P3
|
||||
- [-1, 2, C3k2, [256, False]] # 16 (P3/8-small)
|
||||
|
||||
- [-1, 1, Conv, [256, 3, 2]]
|
||||
- [[-1, 13], 1, Concat, [1]] # cat head P4
|
||||
- [-1, 2, C3k2, [512, False]] # 19 (P4/16-medium)
|
||||
|
||||
- [-1, 1, Conv, [512, 3, 2]]
|
||||
- [[-1, 10], 1, Concat, [1]] # cat head P5
|
||||
- [-1, 2, C3k2, [1024, True]] # 22 (P5/32-large)
|
||||
|
||||
- [[16, 19, 22], 1, OBB, [nc, 1]] # Detect(P3, P4, P5)
|
||||
Reference in New Issue
Block a user