service__projact / train_yolov8.py
lokesh341's picture
Create train_yolov8.py
06c27e5 verified
raw
history blame contribute delete
715 Bytes
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