Skip to content

Commit

Permalink
Merge pull request #72 from albu/fix_bbox_example
Browse files Browse the repository at this point in the history
fix bbox example and bug with filtering
  • Loading branch information
albu committed Sep 20, 2018
2 parents 9e027f5 + 6635fda commit 9717919
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 131 deletions.
2 changes: 1 addition & 1 deletion albumentations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import absolute_import

__version__ = '0.0.15'
__version__ = '0.0.16'

from .core.composition import *
from .core.transforms_interface import *
Expand Down
13 changes: 6 additions & 7 deletions albumentations/augmentations/bbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,15 +204,14 @@ def filter_bboxes(bboxes, rows, cols, min_area=0., min_visibility=0.):
"""
resulting_boxes = []
for bbox in bboxes:
if min_visibility:
transformed_box_area = calculate_bbox_area(bbox, rows, cols)
bbox[:4] = np.clip(bbox[:4], 0, 1.)
clipped_box_area = calculate_bbox_area(bbox, rows, cols)
if not transformed_box_area or clipped_box_area / transformed_box_area < min_visibility:
continue
transformed_box_area = calculate_bbox_area(bbox, rows, cols)
bbox[:4] = np.clip(bbox[:4], 0, 1.)
clipped_box_area = calculate_bbox_area(bbox, rows, cols)
if not transformed_box_area or clipped_box_area / transformed_box_area <= min_visibility:
continue
else:
bbox[:4] = np.clip(bbox[:4], 0, 1.)
if min_area and calculate_bbox_area(bbox, rows, cols) < min_area:
if calculate_bbox_area(bbox, rows, cols) <= min_area:
continue
resulting_boxes.append(bbox)
return resulting_boxes
217 changes: 94 additions & 123 deletions notebooks/example_bboxes.ipynb

Large diffs are not rendered by default.

0 comments on commit 9717919

Please sign in to comment.