Vai al contenuto

Riferimento per ultralytics/models/fastsam/model.py

Nota

Questo file è disponibile su https://github.com/ultralytics/ ultralytics/blob/main/ ultralytics/models/ fastsam/model .py. Se noti un problema, contribuisci a risolverlo inviando una Pull Request 🛠️. Grazie 🙏!



ultralytics.models.fastsam.model.FastSAM

Basi: Model

FastSAM interfaccia del modello.

Esempio
from ultralytics import FastSAM

model = FastSAM('last.pt')
results = model.predict('ultralytics/assets/bus.jpg')
Codice sorgente in 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

Restituisce un dizionario che mappa il compito del segmento con le corrispondenti classi di predittore e validatore.

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

Chiama il metodo init della classe padre (YOLO) con il modello predefinito aggiornato.

Codice sorgente in 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")





Creato 2023-11-12, Aggiornato 2024-05-08
Autori: Burhan-Q (1), glenn-jocher (3)