Docs Solutions to Navigation Bar (#13249)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Richard Abrich <richard.abrich@gmail.com>
This commit is contained in:
parent
25e7054a9c
commit
cbcb494cfc
7 changed files with 128 additions and 82 deletions
|
|
@ -3,6 +3,7 @@
|
|||
import subprocess
|
||||
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
from tests import CUDA_DEVICE_COUNT, CUDA_IS_AVAILABLE
|
||||
from ultralytics.cfg import TASK2DATA, TASK2MODEL, TASKS
|
||||
|
|
@ -74,26 +75,27 @@ def test_fastsam(task="segment", model=WEIGHTS_DIR / "FastSAM-s.pt", data="coco8
|
|||
sam_model = FastSAM(model) # or FastSAM-x.pt
|
||||
|
||||
# Run inference on an image
|
||||
everything_results = sam_model(source, device="cpu", retina_masks=True, imgsz=1024, conf=0.4, iou=0.9)
|
||||
for s in (source, Image.open(source)):
|
||||
everything_results = sam_model(s, device="cpu", retina_masks=True, imgsz=320, conf=0.4, iou=0.9)
|
||||
|
||||
# Remove small regions
|
||||
new_masks, _ = Predictor.remove_small_regions(everything_results[0].masks.data, min_area=20)
|
||||
# Remove small regions
|
||||
new_masks, _ = Predictor.remove_small_regions(everything_results[0].masks.data, min_area=20)
|
||||
|
||||
# Everything prompt
|
||||
prompt_process = FastSAMPrompt(source, everything_results, device="cpu")
|
||||
ann = prompt_process.everything_prompt()
|
||||
# Everything prompt
|
||||
prompt_process = FastSAMPrompt(s, everything_results, device="cpu")
|
||||
ann = prompt_process.everything_prompt()
|
||||
|
||||
# Bbox default shape [0,0,0,0] -> [x1,y1,x2,y2]
|
||||
ann = prompt_process.box_prompt(bbox=[200, 200, 300, 300])
|
||||
# Bbox default shape [0,0,0,0] -> [x1,y1,x2,y2]
|
||||
ann = prompt_process.box_prompt(bbox=[200, 200, 300, 300])
|
||||
|
||||
# Text prompt
|
||||
ann = prompt_process.text_prompt(text="a photo of a dog")
|
||||
# Text prompt
|
||||
ann = prompt_process.text_prompt(text="a photo of a dog")
|
||||
|
||||
# Point prompt
|
||||
# Points default [[0,0]] [[x1,y1],[x2,y2]]
|
||||
# Point_label default [0] [1,0] 0:background, 1:foreground
|
||||
ann = prompt_process.point_prompt(points=[[200, 200]], pointlabel=[1])
|
||||
prompt_process.plot(annotations=ann, output="./")
|
||||
# Point prompt
|
||||
# Points default [[0,0]] [[x1,y1],[x2,y2]]
|
||||
# Point_label default [0] [1,0] 0:background, 1:foreground
|
||||
ann = prompt_process.point_prompt(points=[[200, 200]], pointlabel=[1])
|
||||
prompt_process.plot(annotations=ann, output="./")
|
||||
|
||||
|
||||
def test_mobilesam():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue