Skip to content

Register now for

# Reference for `ultralytics/models/fastsam/val.py`

Note

This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/val.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!

## `` ultralytics.models.fastsam.val.FastSAMValidator

    FastSAMValidator(dataloader=None, save_dir=None, args=None, _callbacks=None)

Bases: `SegmentationValidator`

Custom validation class for Fast SAM (Segment Anything Model) segmentation in Ultralytics YOLO framework.

Extends the SegmentationValidator class, customizing the validation process specifically for Fast SAM. This class sets the task to 'segment' and uses the SegmentMetrics for evaluation. Additionally, plotting features are disabled to avoid errors during validation.

Attributes:

Name | Type | Description
--- | --- | ---
`dataloader` | `DataLoader` | The data loader object used for validation.
`save_dir` | `Path` | The directory where validation results will be saved.
`args` | `SimpleNamespace` | Additional arguments for customization of the validation process.
`_callbacks` | `list` | List of callback functions to be invoked during validation.
`metrics` | `SegmentMetrics` | Segmentation metrics calculator for evaluation.

Methods:

Name | Description
--- | ---

Parameters:

Name | Type | Description | Default
--- | --- | --- | ---
`dataloader` | `DataLoader` | Dataloader to be used for validation. | `None`
`save_dir` | `Path` | Directory to save results. | `None`
`args` | `SimpleNamespace` | Configuration for the validator. | `None`
`_callbacks` | `list` | List of callback functions to be invoked during validation. | `None`

Notes

Plots for ConfusionMatrix and other related metrics are disabled in this class to avoid errors.

Source code in `ultralytics/models/fastsam/val.py`

    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    def __init__(self, dataloader=None, save_dir=None, args=None, _callbacks=None):
        """
        Initialize the FastSAMValidator class, setting the task to 'segment' and metrics to SegmentMetrics.

        Args:
            dataloader (torch.utils.data.DataLoader, optional): Dataloader to be used for validation.
            save_dir (Path, optional): Directory to save results.
            args (SimpleNamespace, optional): Configuration for the validator.
            _callbacks (list, optional): List of callback functions to be invoked during validation.

        Notes:
            Plots for ConfusionMatrix and other related metrics are disabled in this class to avoid errors.
        """
        super().__init__(dataloader, save_dir, args, _callbacks)
        self.args.task = "segment"
        self.args.plots = False  # disable ConfusionMatrix and other plots to avoid errors

📅 Created 1 year ago ✏️ Updated 1 year ago