Bỏ để qua phần nội dung

Tài liệu tham khảo cho ultralytics/models/fastsam/model.py

Ghi

Tệp này có sẵn tại https://github.com/ultralytics/ultralytics/blob/main/ultralytics/Mô hình/fastsam/model.py. Nếu bạn phát hiện ra một vấn đề, vui lòng giúp khắc phục nó bằng cách đóng góp Yêu cầu 🛠️ kéo. Cảm ơn bạn 🙏 !



ultralytics.models.fastsam.model.FastSAM

Căn cứ: Model

FastSAM giao diện mô hình.

Ví dụ
from ultralytics import FastSAM

model = FastSAM('last.pt')
results = model.predict('ultralytics/assets/bus.jpg')
Mã nguồn trong ultralytics/models/fastsam/model.py
class FastSAM(Model):
    """
    FastSAM model interface.

    Example:
        ```python
        from ultralytics import FastSAM

        model = FastSAM('last.pt')
        results = model.predict('ultralytics/assets/bus.jpg')
        ```
    """

    def __init__(self, model="FastSAM-x.pt"):
        """Call the __init__ method of the parent class (YOLO) with the updated default model."""
        if str(model) == "FastSAM.pt":
            model = "FastSAM-x.pt"
        assert Path(model).suffix not in {".yaml", ".yml"}, "FastSAM models only support pre-trained models."
        super().__init__(model=model, task="segment")

    @property
    def task_map(self):
        """Returns a dictionary mapping segment task to corresponding predictor and validator classes."""
        return {"segment": {"predictor": FastSAMPredictor, "validator": FastSAMValidator}}

task_map property

Trả về tác vụ phân đoạn ánh xạ từ điển cho các lớp dự đoán và trình xác thực tương ứng.

__init__(model='FastSAM-x.pt')

Gọi phương thức init của lớp cha (YOLO) với mô hình mặc định được cập nhật.

Mã nguồn trong ultralytics/models/fastsam/model.py
def __init__(self, model="FastSAM-x.pt"):
    """Call the __init__ method of the parent class (YOLO) with the updated default model."""
    if str(model) == "FastSAM.pt":
        model = "FastSAM-x.pt"
    assert Path(model).suffix not in {".yaml", ".yml"}, "FastSAM models only support pre-trained models."
    super().__init__(model=model, task="segment")





Đã tạo 2023-11-12, Cập nhật 2024-05-08
Tác giả: Burhan-Q (1), glenn-jocher (3)