Reference for ultralytics/models/fastsam/predict.py
Note
This file is available at https://github.com/ultralytics/ultralytics/blob/main/ultralytics/models/fastsam/predict.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
ultralytics.models.fastsam.predict.FastSAMPredictor
Bases: SegmentationPredictor
FastSAMPredictor is specialized for fast SAM (Segment Anything Model) segmentation prediction tasks in Ultralytics YOLO framework.
This class extends the SegmentationPredictor, customizing the prediction pipeline specifically for fast SAM. It adjusts post-processing steps to incorporate mask prediction and non-max suppression while optimizing for single- class segmentation.
Source code in ultralytics/models/fastsam/predict.py
postprocess
Applies box postprocess for FastSAM predictions.
Source code in ultralytics/models/fastsam/predict.py
prompt
Internal function for image segmentation inference based on cues like bounding boxes, points, and masks. Leverages SAM's specialized architecture for prompt-based, real-time segmentation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
results | Results | List[Results] | The original inference results from FastSAM models without any prompts. | required |
bboxes | ndarray | List | Bounding boxes with shape (N, 4), in XYXY format. | None |
points | ndarray | List | Points indicating object locations with shape (N, 2), in pixels. | None |
labels | ndarray | List | Labels for point prompts, shape (N, ). 1 = foreground, 0 = background. | None |
texts | str | List[str] | Textual prompts, a list contains string objects. | None |
Returns:
Type | Description |
---|---|
List[Results] | The output results determined by prompts. |