Training
- src.pipeline.train.find_latest_model(model_dir: str, fallback_model: str) str [source]
Finds the YOLO model with the latest date in the filename. If none found, returns the fallback model.
- Parameters:
model_dir (str) – Directory containing YOLO model .pt files.
fallback_model (str) – Path to fallback model (used if none found).
- Returns:
Path to the latest-dated model or the fallback model.
- Return type:
str
- src.pipeline.train.load_train_config(config_path: str) dict [source]
Loads training configuration from JSON file. :param config_path: Path to the train_config.json file. :type config_path: str
- Returns:
configuration dictionary
- Return type:
dict
- src.pipeline.train.train_model(config: dict) str [source]
Trains a YOLOv8 model using the Ultralytics library and saves the trained model and metadata.
- Parameters:
config (dict) – Loaded config dictionary from train_config.json, containing: - data_yaml_path (str): Path to data.yaml - torch_device (str): ‘cpu’ or ‘cuda’ - training_config (dict): eg., epochs, lr0, imgsz, batch, workers, etc - model_path (str): (Optional) Path to a pre-trained model to fine-tune.
- Returns:
Path to the saved trained model (.pt)
- Return type:
str