Skip to content

Commit c4c44be

Browse files
committed
new sorting alg
1 parent 949aa34 commit c4c44be

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ Class implementing combining masks/boxes from multiple crops + NMS (Non-Maximum
130130
| **Argument** | **Type** | **Default** | **Description** |
131131
|----------------------|-------------------|-------------|-------------------------------------------------------------------------------------------------------------------------|
132132
| element_crops |MakeCropsDetectThem| | Object containing crop information. |
133-
| nms_threshold | float | 0.3 | IoU/IoS threshold for non-maximum suppression. |
133+
| nms_threshold | float | 0.3 | IoU/IoS threshold for non-maximum suppression. The lower the value, the fewer objects remain after suppression. |
134134
| match_metric | str | IOS | Matching metric, either 'IOU' or 'IOS'. |
135135
| intelligent_sorter | bool | True | Enable sorting by area and rounded confidence parameter. If False, sorting will be done only by confidence (usual nms). |
136+
| sorter_bins | int | 10 | Number of bins to use for intelligent_sorter. A smaller number of bins makes the NMS more reliant on object sizes rather than confidence scores. |
137+
136138

137139

138140
---
@@ -198,7 +200,7 @@ visualize_results(
198200

199201
4. **Enhancing Detection Within Patches**: To detect more objects within a single crop, increase the `imgsz` parameter and lower the confidence threshold (`conf`). All parameters available for configuring Ultralytics model inference are also accessible during the initialization of the `MakeCropsDetectThem` element.
200202

201-
5. **Handling Duplicate Suppression Issues**: If you encounter issues with duplicate suppression from overlapping patches, consider adjusting the `nms_threshold` parameter in `CombineDetections` or modifying the overlap and size parameters of the patches themselves.
203+
5. **Handling Duplicate Suppression Issues**: If you encounter issues with duplicate suppression from overlapping patches, consider adjusting the `nms_threshold` and `sorter_bins` parameters in `CombineDetections` or modifying the overlap and size parameters of the patches themselves. (PS: often lowering `sorter_bins` to 5 or 4 can help).
202204

203205
6. **High-Quality Instance Segmentation**: For tasks requiring high-quality results in instance segmentation, detailed guidance is provided in the next section of the README.
204206
---

patched_yolo_infer/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# YOLO-Patch-Based-Inference
22

3-
This library facilitates various visualizations of inference results from ultralytics segmentation/detection models, including cropping with overlays, as well as **a patch-based inference algorithm enabling the detection/instance segmentation of small objects in images**.
3+
This Python library simplifies SAHI-like inference for instance segmentation tasks, enabling the detection of small objects in images. It caters to both object detection and instance segmentation tasks, supporting a wide range of Ultralytics models.
44

5-
**Model Support**: The library offers support for multiple ultralytics deep learning models, such as YOLOv8, YOLOv9, SAM, and RTDETR. Users can select from pre-trained options or utilize custom-trained models to best meet their task requirements.
5+
The library also provides a sleek customization of the visualization of the inference results for all models, both in the standard approach (direct network run) and the unique patch-based variant.
6+
7+
**Model Support**: The library offers support for multiple ultralytics deep learning [models](https://docs.ultralytics.com/models/), such as YOLOv8, YOLOv8-seg, YOLOv9, YOLOv9-seg, YOLOv10, FastSAM, and RTDETR. Users can select from pre-trained options or utilize custom-trained models to best meet their task requirements.
68

79

810
## Installation
@@ -25,7 +27,7 @@ __Check this Colab examples:__
2527

2628
Patch-Based-Inference Example - [Open in Colab](https://colab.research.google.com/drive/1XCpIYLMFEmGSO0XCOkSD7CcD9SFHSJPA?usp=sharing)
2729

28-
Example of using various functions for visualizing basic YOLOv8/v9 inference results and handling overlapping crops - [Open in Colab](https://colab.research.google.com/drive/1eM4o1e0AUQrS1mLDpcgK9HKInWEvnaMn?usp=sharing)
30+
Example of using various functions for visualizing basic YOLOv8/v9 inference results - [Open in Colab](https://colab.research.google.com/drive/1eM4o1e0AUQrS1mLDpcgK9HKInWEvnaMn?usp=sharing)
2931

3032

3133
## Usage
@@ -67,7 +69,7 @@ element_crops = MakeCropsDetectThem(
6769
iou=0.7,
6870
resize_initial_size=True,
6971
)
70-
result = CombineDetections(element_crops, nms_threshold=0.25, match_metric='IOS')
72+
result = CombineDetections(element_crops, nms_threshold=0.25)
7173

7274
# Final Results:
7375
img=result.image
@@ -108,7 +110,7 @@ Class implementing combining masks/boxes from multiple crops + NMS (Non-Maximum
108110
- **nms_threshold** (*float*): IoU/IoS threshold for non-maximum suppression.
109111
- **match_metric** (*str*): Matching metric, either 'IOU' or 'IOS'.
110112
- **intelligent_sorter** (*bool*): Enable sorting by area and rounded confidence parameter. If False, sorting will be done only by confidence (usual nms). (Dafault is True)
111-
113+
- **sorter_bins** (*int*): Number of bins to use for intelligent_sorter. A smaller number of bins makes the NMS more reliant on object sizes rather than confidence scores. (Defaults to 10)
112114

113115

114116
---

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
long_description = "\n" + fh.read()
99

1010

11-
VERSION = '1.2.7'
11+
VERSION = '1.2.8'
1212
DESCRIPTION = '''Patch-Based-Inference for detection/segmentation of small objects in images.'''
1313

1414
setup(

0 commit comments

Comments
 (0)