-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrain.py
51 lines (44 loc) · 995 Bytes
/
train.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright (C) 2025 Anthony Casagrande
# AGPL-3.0 license
from ultralytics import YOLO, checks, hub
checks()
hub.login()
# Batch sizes by imgsz
batch_sizes = {
1920: {
'yolo11x.pt': 1,
'yolo11l.pt': 1,
'yolo11m.pt': 2,
'yolo11s.pt': 3, # 4,
'yolo11n.pt': 6,
},
1280: {
'yolo11s.pt': 9, # 10 = 11.3 GB, 11 = 11.4 - 12 GB
'yolo11m.pt': 5, # 5 = 10.7 - 11.1 GB
'yolo11l.pt': 4, # 4 = 11.3 GB, 3 = 8.7 GB
},
1088: {
'yolo11l.pt': 5,
'yolo11s.pt': 15,
},
960: {
'yolo11l.pt': 8,
},
640: {
"yolo11x.pt": 11,
}
}
imgsz = 1280
# # For fresh learning
model_file = 'yolo11s.pt'
model = YOLO(model_file)
batch_size = -1
if imgsz in batch_sizes and model_file in batch_sizes[imgsz]:
batch_size = batch_sizes[imgsz][model_file]
results = model.train(
data="dataset.v3.yaml",
imgsz=imgsz,
epochs=500,
patience=100,
batch=batch_size,
)