lokesh341 commited on
Commit
06c27e5
·
verified ·
1 Parent(s): 9e8e688

Create train_yolov8.py

Browse files
Files changed (1) hide show
  1. train_yolov8.py +19 -0
train_yolov8.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ultralytics import YOLO
2
+
3
+ # Load the YOLOv8 nano model
4
+ model = YOLO('yolov8n.pt')
5
+
6
+ # Train the model on the pothole dataset
7
+ model.train(
8
+ data='pothole_dataset/data.yaml', # Path to the dataset config file
9
+ epochs=50, # Number of training epochs
10
+ imgsz=640, # Image size
11
+ batch=16, # Batch size (adjust based on your hardware)
12
+ device='cpu', # Use CPU (Hugging Face Spaces may not have GPU)
13
+ project='runs/train', # Output directory for training results
14
+ name='pothole_yolov8n', # Experiment name
15
+ patience=10 # Early stopping after 10 epochs of no improvement
16
+ )
17
+
18
+ # Export the trained model weights
19
+ model.export(format='pt') # Saves to runs/train/pothole_yolov8n/weights/best.pt