增加obb
This commit is contained in:
16
ultralytics_yolo11-main/obb_data.yaml
Normal file
16
ultralytics_yolo11-main/obb_data.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
# 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, ..]
|
||||
train: /home/hx/桌面/image/images/train
|
||||
val: /home/hx/桌面/image/images/val
|
||||
|
||||
nc: 1
|
||||
names: ['clamp']
|
||||
|
||||
18
ultralytics_yolo11-main/train_obb_main.py
Normal file
18
ultralytics_yolo11-main/train_obb_main.py
Normal file
@ -0,0 +1,18 @@
|
||||
from ultralytics import YOLO
|
||||
|
||||
if __name__ == '__main__':
|
||||
model = YOLO(r'/home/hx/yolo/ultralytics_yolo11-main/ultralytics/cfg/models/11/yolo11-obb.yaml')
|
||||
results = model.train(
|
||||
data='obb_data.yaml',
|
||||
epochs=1000,
|
||||
imgsz=1280,
|
||||
batch=4,
|
||||
workers=10,
|
||||
device='0',
|
||||
project='runs/train',
|
||||
name='exp_obb',
|
||||
exist_ok=False,
|
||||
optimizer='AdamW',
|
||||
lr0=0.001,
|
||||
patience=20,
|
||||
)
|
||||
@ -2,7 +2,7 @@
|
||||
# YOLO11 Oriented Bounding Boxes (OBB) model with P3-P5 outputs. For Usage examples see https://docs.ultralytics.com/tasks/obb
|
||||
|
||||
# Parameters
|
||||
nc: 80 # number of classes
|
||||
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
|
||||
|
||||
@ -455,24 +455,7 @@ def convert_dota_to_yolo_obb(dota_root_path: str):
|
||||
|
||||
# Class names to indices mapping
|
||||
class_mapping = {
|
||||
"plane": 0,
|
||||
"ship": 1,
|
||||
"storage-tank": 2,
|
||||
"baseball-diamond": 3,
|
||||
"tennis-court": 4,
|
||||
"basketball-court": 5,
|
||||
"ground-track-field": 6,
|
||||
"harbor": 7,
|
||||
"bridge": 8,
|
||||
"large-vehicle": 9,
|
||||
"small-vehicle": 10,
|
||||
"helicopter": 11,
|
||||
"roundabout": 12,
|
||||
"soccer-ball-field": 13,
|
||||
"swimming-pool": 14,
|
||||
"container-crane": 15,
|
||||
"airport": 16,
|
||||
"helipad": 17,
|
||||
"clamp": 0,
|
||||
}
|
||||
|
||||
def convert_label(image_name, image_width, image_height, orig_label_dir, save_dir):
|
||||
@ -504,7 +487,7 @@ def convert_dota_to_yolo_obb(dota_root_path: str):
|
||||
|
||||
image_paths = list(image_dir.iterdir())
|
||||
for image_path in TQDM(image_paths, desc=f"Processing {phase} images"):
|
||||
if image_path.suffix != ".png":
|
||||
if image_path.suffix not in [".png" ,".jpg" , ".jpeg"]:
|
||||
continue
|
||||
image_name_without_ext = image_path.stem
|
||||
img = cv2.imread(str(image_path))
|
||||
|
||||
Reference in New Issue
Block a user