engine package
Subpackages
Submodules
engine.eval_detection module
- engine.eval_detection.predict_and_save(opts, input_tensor: Tensor, model: Module, input_np: ndarray | None = None, device: Optional = device(type='cpu'), is_coco_evaluation: bool | None = False, file_name: str | None = None, output_stride: int | None = 32, orig_h: int | None = None, orig_w: int | None = None, *args, **kwargs)[source]
This function makes a prediction on the input tensor and optionally save the detection results :param opts: command-line arguments :param input_tensor: Input tensor of size \((1, C, H, W)\) :type input_tensor: Tensor :param model: detection model :type model: nn.Module :param input_np: Input numpy image of size \((H, W, C)\). Used only for visualization purposes. Defaults to None :type input_np: Optional[np.ndarray] :param device: Device. Defaults to cpu. :type device: Optional[str] :param is_coco_evaluation: Evaluating on MS-COCO object detection. Defaults to False. :type is_coco_evaluation: Optional[bool] :param file_name: File name for storing detection results. Only applicable when is_coco_evaluation is False. Defaults to None. :type file_name: Optional[bool] :param output_stride: Output stride. This is used to ensure that image size is divisible by this factor. Defaults to 32. :type output_stride: Optional[int] :param orig_h: Original height of the input image. Useful for visualizing detection results. Defaults to None. :type orig_h: Optional[int] :param orig_w: Original width of the input image. Useful for visualizing detection results. Defaults to None. :type orig_w: Optional[int]
engine.eval_segmentation module
- engine.eval_segmentation.predict_and_save(opts, input_tensor: Tensor, file_name: str, orig_h: int, orig_w: int, model: Module, target_mask: Tensor | None = None, device: Optional = device(type='cpu'), conf_mat: ConfusionMatrix | None = None, color_map: List | None = None, orig_image: Image | None = None, adjust_label: int | None = 0, is_cityscape: bool | None = False, *args, **kwargs) None [source]
Predict the segmentation mask and optionally save them
- engine.eval_segmentation.draw_binary_masks(opts, pred_mask: Tensor, file_name: str, results_location: str, is_cityscape: bool | None = False) None [source]
Save masks whose values ranges between 0 and number_of_classes - 1
engine.evaluation_engine module
engine.training_engine module
- class engine.training_engine.Trainer(opts, model, validation_loader, training_loader, criterion, optimizer, scheduler, gradient_scaler, start_epoch: int = 0, start_iteration: int = 0, best_metric: float = 0.0, model_ema=None, *args, **kwargs)[source]
Bases:
object
This class defines the training and validation code for training models with CVNets
- __init__(opts, model, validation_loader, training_loader, criterion, optimizer, scheduler, gradient_scaler, start_epoch: int = 0, start_iteration: int = 0, best_metric: float = 0.0, model_ema=None, *args, **kwargs) None [source]
- find_easy_samples(epoch, model, *args, **kwargs)[source]
This function identifies easy samples in the training set and removes them from training.
Note
Currently, this is implemented separately to avoid breaking the training and validation pipeline. In future, this will be combined with main training loop to reduce overhead.
engine.utils module
- engine.utils.log_metrics(lrs: List | float, log_writer, train_loss: float, val_loss: float, epoch: int, best_metric: float, val_ema_loss: float | None = None, ckpt_metric_name: str | None = None, train_ckpt_metric: float | None = None, val_ckpt_metric: float | None = None, val_ema_ckpt_metric: float | None = None) None [source]