File size: 689 Bytes
9457184
c5cff55
9457184
1b65107
2c6959d
 
c5cff55
 
9457184
c5cff55
 
41ba03c
3e7703e
 
 
 
 
 
 
 
 
 
 
 
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
from ultralytics import YOLO
import os

# Define the correct path to config.yaml (in the root directory)
config_path = './config.yaml'  # Adjust based on the actual path to your config.yaml

# Load YOLO model
model = YOLO("yolo11n.yaml")  # You can choose a different model type like yolo5n, yolo6n, etc.

# Train the model
results = model.train(data=config_path, epochs=1)

# Define the save directory
save_dir = './runs/detect/train/weights'

# Create directory if it doesn't exist
if not os.path.exists(save_dir):
    os.makedirs(save_dir)

# Save the model
model.save(os.path.join(save_dir, 'best.pt'))

# Print confirmation
print("Model saved to:", os.path.join(save_dir, 'best.pt'))