You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
948 B
34 lines
948 B
# Ultralytics YOLO 🚀, AGPL-3.0 license
|
|
|
|
from pathlib import Path
|
|
|
|
from ultralytics.engine.model import Model
|
|
|
|
from .predict import FastSAMPredictor
|
|
from .val import FastSAMValidator
|
|
|
|
|
|
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):
|
|
return {'segment': {'predictor': FastSAMPredictor, 'validator': FastSAMValidator}}
|