-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrain.py
More file actions
31 lines (26 loc) · 754 Bytes
/
Copy pathtrain.py
File metadata and controls
31 lines (26 loc) · 754 Bytes
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
from ultralytics import YOLO
EPOCHS=5
BATCH_SIZE=16
INPUT_SIZE=640
def train_step_yolo(yaml_path,model_weights,input_size=640,epochs=5,batch_size=16):
model=YOLO(model_weights)
results=model.train(
data=yaml_path,
imgsz=input_size,
epochs=epochs,
batch=batch_size,
workers=1,
device='cpu' # Use '0' for GPU if available
)
print("Training is completed with pretrained weights")
return results
if __name__=="__main__":
yaml_path='data.yaml'
model_weights='yolov8n.pt'
train_step_yolo(
yaml_path=yaml_path,
model_weights=model_weights,
input_size=INPUT_SIZE,
epochs=EPOCHS,
batch_size=BATCH_SIZE
)