Trainers¶
- class flat_bug.trainers.FlatBugSegmentationTrainer(cfg: IterableSimpleNamespace = IterableSimpleNamespace(task='detect', mode='train', model=None, data=None, epochs=100, time=None, patience=100, batch=16, imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=None, exist_ok=False, pretrained=True, optimizer='auto', verbose=True, seed=0, deterministic=True, single_cls=False, rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, freeze=None, multi_scale=False, overlap_mask=True, mask_ratio=4, dropout=0.0, val=True, split='val', save_json=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, vid_stride=1, stream_buffer=False, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, embed=None, show=False, save_frames=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, show_boxes=True, line_width=None, format='torchscript', keras=False, optimize=False, int8=False, dynamic=False, simplify=True, opset=None, workspace=None, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, bgr=0.0, mosaic=1.0, mixup=0.0, cutmix=0.0, copy_paste=0.0, copy_paste_mode='flip', auto_augment='randaugment', erasing=0.4, cfg=None, tracker='botsort.yaml'), overrides: Dict = None, _callbacks: Any = None, *args, **kwargs)¶
- build_dataset(img_path: str, mode: str = 'train', batch: int | None = None) FlatBugYOLODataset | FlatBugYOLOValidationDataset ¶
Build YOLO Dataset for training or validation.
- Parameters:
img_path (str) – Path to the folder containing images.
mode (str) – train mode or val mode, users are able to customize different augmentations for each mode.
batch (int, optional) – Size of batches, this is for rect.
- Returns:
YOLO dataset object configured for the specified mode.
- Return type:
(Dataset)
- get_dataloader(dataset_path: str, batch_size: int | None = 16, rank: int = 0, mode: str = 'train') InfiniteDataLoader ¶
Construct and return dataloader.
- get_validator() SegmentationValidator ¶
Return an instance of SegmentationValidator for validation of YOLO model.
- setup_model() Dict | None ¶
Load, create, or download model for any task.
- Returns:
Optional checkpoint to resume training from.
- Return type:
(dict)
- validate() Tuple[Dict, float] ¶
Runs validation on test set using self.validator. The returned dict is expected to contain “fitness” key.