File size: 715 Bytes
06c27e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from ultralytics import YOLO

# Load the YOLOv8 nano model
model = YOLO('yolov8n.pt')

# Train the model on the pothole dataset
model.train(
    data='pothole_dataset/data.yaml',  # Path to the dataset config file
    epochs=50,  # Number of training epochs
    imgsz=640,  # Image size
    batch=16,  # Batch size (adjust based on your hardware)
    device='cpu',  # Use CPU (Hugging Face Spaces may not have GPU)
    project='runs/train',  # Output directory for training results
    name='pothole_yolov8n',  # Experiment name
    patience=10  # Early stopping after 10 epochs of no improvement
)

# Export the trained model weights
model.export(format='pt')  # Saves to runs/train/pothole_yolov8n/weights/best.pt