|
|
from ultralytics import YOLO
|
|
|
import os
|
|
|
|
|
|
|
|
|
DATA_YAML_PATH = 'data.yaml'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EPOCHS = 50
|
|
|
|
|
|
|
|
|
model = YOLO('yolov8n.pt')
|
|
|
|
|
|
|
|
|
print(f"Starting training with data from: {DATA_YAML_PATH}")
|
|
|
if not os.path.exists(DATA_YAML_PATH):
|
|
|
print(f"ERROR: data.yaml file not found at {DATA_YAML_PATH}")
|
|
|
print("Please make sure the path is correct and the file exists.")
|
|
|
else:
|
|
|
results = model.train(
|
|
|
data=DATA_YAML_PATH,
|
|
|
epochs=EPOCHS,
|
|
|
imgsz=640,
|
|
|
plots=True
|
|
|
)
|
|
|
print("Training completed! Check 'runs/detect/train/weights/best.pt' for your trained model.") |