File size: 1,201 Bytes
c6abe34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
34
35
36
37
38
39
from ultralytics import YOLO
import os

def train_player_referee_model():
    print("--- Training Player/Referee Model (YOLOv11) - CPU MODE ---")
    model = YOLO("yolo11n.pt") 
    
    model.train(
        data="datasets/nbl_dataset/data.yaml",
        epochs=30,           # Reduced epochs for CPU
        imgsz=320,          # Smaller image size is MUCH faster on CPU
        batch=4,            # Smaller batch avoids memory overload
        device='cpu',       # Force CPU
        workers=2,          # Limit background threads
        name="nbl_player_referee"
    )
    print("Player/Referee Training Complete!")

def train_ball_model():
    print("--- Training Ball Model (YOLOv10) - CPU MODE ---")
    model = YOLO("yolov10n.pt")
    
    model.train(
        data="datasets/nbl_dataset/data.yaml",
        epochs=30,
        imgsz=320,
        batch=4,
        device='cpu',
        workers=2,
        name="nbl_ball_model"
    )
    print("Ball Training Complete!")

if __name__ == "__main__":
    # You can choose which one to run, or run both
    # For now, let's run both and then we can update the config to use the best weights
    train_player_referee_model()
    train_ball_model()