Skip to content

Commit f8d3714

Browse files
authored
Fix the documented examples and defaults that do not match the code (#1427)
Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
1 parent 6597c67 commit f8d3714

6 files changed

Lines changed: 22 additions & 29 deletions

File tree

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ source .venv/bin/activate # On Windows: .venv\Scripts\activate
2626

2727
```bash
2828
# Install core + dev dependencies
29-
uv sync --extra dev
29+
uv sync --group dev
3030

3131
# For testing specific models, install their dependencies.
3232
```
@@ -92,7 +92,7 @@ If the CI build fails due to formatting:
9292
3. Install dev dependencies:
9393

9494
```bash
95-
uv sync --extra dev
95+
uv sync --group dev
9696
```
9797

9898
4. Fix formatting:

docs/cli.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ sahi predict --slice_width 512 --slice_height 512 \
8989

9090
**Match Metrics:**
9191

92-
- `--postprocess_match_metric IOS` - Intersection over smaller area
93-
- `--postprocess_match_metric IOU` - Intersection over union (default)
92+
- `--postprocess_match_metric IOS` - Intersection over smaller area (default)
93+
- `--postprocess_match_metric IOU` - Intersection over union
9494

9595
**Additional Options:**
9696

@@ -127,8 +127,7 @@ sahi predict --dataset_json_path dataset.json \
127127
--model_path path/to/model
128128
```
129129

130-
Predictions will be exported as a COCO JSON file to
131-
`runs/predict/exp/results.json`. You can then use:
130+
Adding `--dataset_json_path` also exports predictions as a COCO JSON file to `runs/predict/exp/result.json`. You can then use:
132131

133132
- `sahi coco evaluate` - Calculate COCO evaluation metrics
134133
- `sahi coco analyse` - Generate detailed error analysis plots
@@ -367,7 +366,6 @@ Display your currently installed SAHI version.
367366

368367
```bash
369368
sahi version
370-
0.11.22
371369
```
372370

373371
---

docs/guides/models.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ All models accept these parameters in `AutoDetectionModel.from_pretrained()`:
447447
| `model_type` | str | Framework name (see sections above) |
448448
| `model_path` | str | Path to weights file or model name |
449449
| `config_path` | str | Config file path (MMDetection, Detectron2) |
450-
| `confidence_threshold` | float | Minimum score to keep a detection (default: 0.25) |
450+
| `confidence_threshold` | float | Minimum score to keep a detection (default: 0.3) |
451451
| `device` | str | `"cpu"`, `"cuda:0"`, `"mps"`, etc. |
452-
| `category_mapping` | dict | Map category IDs to names: `{0: "car", 1: "person"}` |
452+
| `category_mapping` | dict | Map category IDs to names, keys are strings: `{"0": "car", "1": "person"}` |
453453
| `category_remapping` | dict | Remap category names after inference |
454454
| `image_size` | int | Override model input resolution |
455455
| `load_at_init` | bool | Load weights immediately (default: True) |

docs/notebooks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ Clone the repository and run notebooks with Jupyter:
4040
```bash
4141
git clone https://github.com/obss/sahi.git
4242
cd sahi
43-
pip install -e ".[dev]"
43+
uv sync --group dev
4444
jupyter notebook demo/
4545
```

docs/postprocess/backends.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ right backend depends on your hardware and installed packages.
2424

2525
By default SAHI automatically picks the best available backend at runtime:
2626

27-
1. **torchvision** if `torchvision` is installed _and_ a GPU is present
27+
1. **torchvision**: if `torchvision` is installed _and_ a GPU is present
2828
(CUDA, or Apple MPS on Apple Silicon).
29-
2. **numba** if the `numba` package is installed.
30-
3. **numpy** always available as the final fallback.
29+
2. **numba**: if the `numba` package is installed.
30+
3. **numpy**: always available as the final fallback.
3131

3232
```python
3333
from sahi.postprocess.backends import get_postprocess_backend
@@ -103,11 +103,11 @@ predictions = np.array([
103103
[300, 300, 400, 400, 0.90, 1],
104104
])
105105

106-
# Global NMS all categories compete together
106+
# Global NMS, all categories compete together
107107
keep = nms(predictions, match_metric="IOU", match_threshold=0.5)
108108
print(predictions[keep])
109109

110-
# Per-category NMS class 0 and class 1 are treated independently
110+
# Per-category NMS, class 0 and class 1 are treated independently
111111
keep = batched_nms(predictions, match_metric="IOU", match_threshold=0.5)
112112
print(predictions[keep])
113113
```
@@ -147,19 +147,19 @@ by `get_sliced_prediction` via the `postprocess_type` argument:
147147
```python
148148
from sahi.postprocess.combine import NMSPostprocess, NMMPostprocess, GreedyNMMPostprocess
149149

150-
# NMS keep the best box, discard the rest
150+
# NMS, keep the best box, discard the rest
151151
postprocessor = NMSPostprocess(
152152
match_threshold=0.5,
153153
match_metric="IOU",
154154
class_agnostic=True, # False → per-category
155155
)
156156
filtered = postprocessor(object_prediction_list)
157157

158-
# Greedy NMM merge overlapping boxes (fast)
158+
# Greedy NMM, merge overlapping boxes (fast)
159159
postprocessor = GreedyNMMPostprocess(match_threshold=0.5)
160160
merged = postprocessor(object_prediction_list)
161161

162-
# Full NMM transitive merging
162+
# Full NMM, transitive merging
163163
postprocessor = NMMPostprocess(match_threshold=0.5)
164164
merged = postprocessor(object_prediction_list)
165165
```

docs/predict.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,9 @@ for i, preds in enumerate(detection_model.object_prediction_list_per_image):
131131
print(pred.category.name, pred.score.value, pred.bbox.to_xyxy())
132132
```
133133

134-
!!! note "Single-image compatibility" The existing `object_prediction_list`
134+
!!! note "Single-image compatibility"
135135

136-
property is unchanged and returns predictions for the first image, so code that
137-
uses `perform_inference` + `convert_original_predictions` +
138-
`object_prediction_list` continues to work without modification.
136+
The existing `object_prediction_list` property is unchanged and returns predictions for the first image, so code that uses `perform_inference` + `convert_original_predictions` + `object_prediction_list` continues to work without modification.
139137

140138
## Progress-Bar
141139

@@ -175,11 +173,11 @@ result = get_sliced_prediction(
175173
)
176174
```
177175

178-
!!! tip "Notes" - `progress_bar` and `progress_callback` can be used together.
176+
!!! tip "Notes"
179177

180-
When both are provided, the tqdm bar will display and the callback will be
181-
called after each slice group is processed. - The `progress_callback` is called
182-
with 1-based indices (i.e. first call will be `(1, total)`).
178+
`progress_bar` and `progress_callback` can be used together. When both are provided, the tqdm bar will display and the callback will be called after each slice group is processed.
179+
180+
The `progress_callback` is called with 1-based indices, so the first call will be `(1, total)`.
183181

184182
## Exclude custom classes on inference
185183

@@ -230,12 +228,9 @@ result.export_visuals(
230228
export_dir="outputs/",
231229
text_size=1.0, # Size of the class label text
232230
rect_th=2, # Thickness of bounding box lines
233-
text_th=2, # Thickness of the text
234231
hide_labels=False, # Set True to hide class labels
235232
hide_conf=False, # Set True to hide confidence scores
236-
color=(255, 0, 0), # Custom color in RGB format (red in this example)
237233
file_name="custom_visualization",
238-
export_format="jpg" # Supports 'jpg' and 'png'
239234
)
240235

241236
# Export as COCO format annotations

0 commit comments

Comments
 (0)