ultralytics 8.3.13 SAM prompt-inference refactor (#16894)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
5a9ce863e4
commit
15e6133534
4 changed files with 85 additions and 54 deletions
|
|
@ -142,11 +142,20 @@ SAM 2 can be utilized across a broad spectrum of tasks, including real-time vide
|
|||
# Display model information (optional)
|
||||
model.info()
|
||||
|
||||
# Segment with bounding box prompt
|
||||
# Run inference with bboxes prompt
|
||||
results = model("path/to/image.jpg", bboxes=[100, 100, 200, 200])
|
||||
|
||||
# Segment with point prompt
|
||||
results = model("path/to/image.jpg", points=[150, 150], labels=[1])
|
||||
# Run inference with single point
|
||||
results = model(points=[900, 370], labels=[1])
|
||||
|
||||
# Run inference with multiple points
|
||||
results = model(points=[[400, 370], [900, 370]], labels=[1, 1])
|
||||
|
||||
# Run inference with multiple points prompt per object
|
||||
results = model(points=[[[400, 370], [900, 370]]], labels=[[1, 1]])
|
||||
|
||||
# Run inference with negative points prompt
|
||||
results = model(points=[[[400, 370], [900, 370]]], labels=[[1, 0]])
|
||||
```
|
||||
|
||||
#### Segment Everything
|
||||
|
|
|
|||
|
|
@ -59,16 +59,16 @@ The Segment Anything Model can be employed for a multitude of downstream tasks t
|
|||
results = model("ultralytics/assets/zidane.jpg", bboxes=[439, 437, 524, 709])
|
||||
|
||||
# Run inference with single point
|
||||
results = predictor(points=[900, 370], labels=[1])
|
||||
results = model(points=[900, 370], labels=[1])
|
||||
|
||||
# Run inference with multiple points
|
||||
results = predictor(points=[[400, 370], [900, 370]], labels=[1, 1])
|
||||
results = model(points=[[400, 370], [900, 370]], labels=[1, 1])
|
||||
|
||||
# Run inference with multiple points prompt per object
|
||||
results = predictor(points=[[[400, 370], [900, 370]]], labels=[[1, 1]])
|
||||
results = model(points=[[[400, 370], [900, 370]]], labels=[[1, 1]])
|
||||
|
||||
# Run inference with negative points prompt
|
||||
results = predictor(points=[[[400, 370], [900, 370]]], labels=[[1, 0]])
|
||||
results = model(points=[[[400, 370], [900, 370]]], labels=[[1, 0]])
|
||||
```
|
||||
|
||||
!!! example "Segment everything"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue