From a9802831fa17fb3478ebfab5d903e37837e91ea3 Mon Sep 17 00:00:00 2001 From: Gianluca Guzzetta <37228546+gguzzy@users.noreply.github.com> Date: Wed, 5 Mar 2025 12:00:52 +0100 Subject: [PATCH] Update predict.md - Added examples on excluding classes by its label or id, using new optional parameter --- docs/predict.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/predict.md b/docs/predict.md index 8e27f0c3b..da8ee7a75 100644 --- a/docs/predict.md +++ b/docs/predict.md @@ -69,3 +69,31 @@ result = predict( ) ``` + +- Exclude custom classes on inference: + +```python +from sahi.predict import get_sliced_prediction +from sahi import AutoDetectionModel + +# init a model +detection_model = AutoDetectionModel.from_pretrained(...) + +# define the class names to exclude from custom model inference +exclude_classes_by_name = ["car"] + +# or exclude classes by its custom id +exclude_classes_by_id = [0] + +result = get_sliced_prediction( + image, + detection_model, + slice_height = 256, + slice_width = 256, + overlap_height_ratio = 0.2, + overlap_width_ratio = 0.2, + exclude_classes_by_name = exclude_classes_by_name + # exclude_classes_by_id = exclude_classes_by_id +) + +```