Skip to content

Commit c204fc9

Browse files
committed
conf for network_based mode
1 parent 74d83e2 commit c204fc9

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,8 @@ Possible arguments of the ```auto_calculate_crop_values``` function:
266266
| image | np.ndarray | | The input image in BGR format. |
267267
| mode | str | "network_based" | The type of analysis to perform. Can be "resolution_based" for Resolution-Based Analysis or "network_based" for Neural Network-Based Analysis.|
268268
| model | ultralytics model | YOLO("yolov8m.pt") | Pre-initialized model object for "network_based" mode. If not provided, the default YOLOv8m model will be used.|
269-
| classes_list | list | None | A list of class indices to consider for object detection in "network_based" mode. If None, all classes will be considered. |
270-
271-
269+
| classes_list | list | None | A list of class indices to consider for object detection in "network_based" mode. If None, all classes will be considered. |
270+
| conf | float | 0.25 | The confidence threshold for detection in "network_based" mode. |
272271

273272
Example of using:
274273
```python

patched_yolo_infer/functions_extra.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def basic_crop_size_calculation(width, height):
503503
return crop_shape_x, crop_shape_y, crop_overlap_x, crop_overlap_y
504504

505505

506-
def auto_calculate_crop_values(image, mode="network_based", model=None, classes_list=None):
506+
def auto_calculate_crop_values(image, mode="network_based", model=None, classes_list=None, conf=0.25):
507507
"""
508508
Automatically calculate the optimal crop size and overlap for an image.
509509
@@ -519,6 +519,7 @@ def auto_calculate_crop_values(image, mode="network_based", model=None, classes_
519519
will be loaded. Default is None.
520520
classes_list (list): A list of class indices to consider for object detection. If None, all classes
521521
will be considered. Default is None.
522+
conf (float): The confidence threshold for detection in "network_based" mode. Default is 0.25.
522523
523524
Returns:
524525
tuple: A tuple containing the crop size in the x direction (crop_shape_x), crop size in the y direction
@@ -537,7 +538,7 @@ def auto_calculate_crop_values(image, mode="network_based", model=None, classes_
537538
model = YOLO("yolov8m.pt")
538539

539540
# Perform object detection on the image
540-
result = model.predict(image, conf=0.25, iou=0.75, classes=classes_list, verbose=False)
541+
result = model.predict(image, conf=conf, iou=0.75, classes=classes_list, verbose=False)
541542

542543
# If no objects are detected, calculate crop size based on image dimensions
543544
if len(result[0].boxes) == 0:

0 commit comments

Comments
 (0)