I don't get segmentation instance masks with yolov8 using SAHI #1000
-
Hi everyone, I followed the examples available on the SAHI github and tried to help myself with other examples from the internet but I still can't get the segment masks when I use yolov8. from sahi.utils.yolov8 import download_yolov8s_model
from sahi import AutoDetectionModel
from sahi.utils.cv import read_image
from sahi.utils.file import download_from_url
from sahi.predict import get_prediction, get_sliced_prediction, predict
from pathlib import Path
from IPython.display import Image
# Download YOLOv8 model
yolov8_model_path = "models/yolov8s-seg.pt"
download_yolov8s_model(yolov8_model_path)
# Download test images
download_from_url('https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/small-vehicles1.jpeg', 'demo_data/small-vehicles1.jpeg')
download_from_url('https://raw.githubusercontent.com/obss/sahi/main/demo/demo_data/terrain2.png', 'demo_data/terrain2.png')
detection_model = AutoDetectionModel.from_pretrained(
model_type='yolov8',
model_path=yolov8_model_path,
confidence_threshold=0.3,
device="cpu", # or 'cuda:0'
)
result = get_sliced_prediction(
"demo_data/small-vehicles1.jpeg",
detection_model,
slice_height=256,
slice_width=256,
overlap_height_ratio=0.2,
overlap_width_ratio=0.2
)
print(result.object_prediction_list)
result.export_visuals(export_dir="demo_data/")
Image("demo_data/prediction_visual.png") And here's a part of the result but there is always
Can anyone tell me what's wrong with my code? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
I'm having the same issue and would love to know if there is a solution for this! |
Beta Was this translation helpful? Give feedback.
-
Hi @ThibautMrl and @kyra-smith, as you can see, Which means that this model does not return masks. If you dig a little bit into the code: Lines 87 to 91 in d91e1e6 I am afraid that yolov8 models in sahi do not return masks. |
Beta Was this translation helpful? Give feedback.
-
I am also looking to get the masks from the results. Any way to get it? |
Beta Was this translation helpful? Give feedback.
-
Segmentation mask support for yolov8 and mmdet models is live with the latest release! https://github.com/obss/sahi/discussions/1051 Check the demo notebook on how it works: https://github.com/obss/sahi/blob/main/demo/inference_for_yolov8.ipynb |
Beta Was this translation helpful? Give feedback.
-
I figured it out: I need an updated SAHI version to run the code. |
Beta Was this translation helpful? Give feedback.
Segmentation mask support for yolov8 and mmdet models is live with the latest release! https://github.com/obss/sahi/discussions/1051
Check the demo notebook on how it works: https://github.com/obss/sahi/blob/main/demo/inference_for_yolov8.ipynb