Spaces:
Sleeping
Sleeping
File size: 614 Bytes
908e980 |
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 |
import os
from ultralytics import YOLO
PROJECT_DIR = os.path.dirname(os.path.dirname(__file__))
# load a pretrained model (recommended for training)
model = YOLO('yolov8n.pt')
os.environ['KMP_DUPLICATE_LIB_OK'] = 'True'
out_path = os.path.join(PROJECT_DIR, 'output')
data_path = os.path.join(PROJECT_DIR, 'data', 'custom_data.yaml')
# train on the pretrained model
results = model.train(
data=data_path,
imgsz=640,
epochs=2,
batch=32,
project=out_path,
name='yolov8n_custom',
save_period=2
)
# evaluate model performance on the validation set
results = model.val(project=out_path) |