From d694866e1e98e6129f37eaf4c1950b962fed437f Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Fri, 4 Feb 2022 17:33:07 +0100 Subject: [PATCH] applied black --- fb_detr/utils/box_merging.py | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/fb_detr/utils/box_merging.py b/fb_detr/utils/box_merging.py index 29f6327..1b94d11 100644 --- a/fb_detr/utils/box_merging.py +++ b/fb_detr/utils/box_merging.py @@ -4,7 +4,7 @@ from operator import attrgetter, itemgetter from frozendict import frozendict -Rectangle = namedtuple('Rectangle', 'xmin ymin xmax ymax') +Rectangle = namedtuple("Rectangle", "xmin ymin xmax ymax") def make_box(x1, y1, x2, y2): @@ -20,7 +20,7 @@ def compute_intersection(a, b): # returns None if rectangles don't intersect dx = min(a.xmax, b.xmax) - max(a.xmin, b.xmin) dy = min(a.ymax, b.ymax) - max(a.ymin, b.ymin) - return dx*dy if (dx>=0) and (dy>=0) else 0 + return dx * dy if (dx >= 0) and (dy >= 0) else 0 def compute_union(a, b): @@ -35,7 +35,7 @@ def compute_iou(a, b): return compute_intersection(a, b) / compute_union(a, b) -LPBox = namedtuple('LPBox', 'label proba box') +LPBox = namedtuple("LPBox", "label proba box") def less_likely(a, b): @@ -47,8 +47,7 @@ def overlap_too_much(a, b, iou_thresh): return iou > iou_thresh -def filter_contained(lpboxes, iou_thresh=.1): - +def filter_contained(lpboxes, iou_thresh=0.1): def remove_less_likely(a, b): try: ll = less_likely(a, b) @@ -80,11 +79,7 @@ def lpboxes_to_dict(lpboxes): boxes, classes, probas = map(list, [boxes, classes, probas]) - return { - "bboxes": boxes, - "classes": classes, - "probas": probas - } + return {"bboxes": boxes, "classes": classes, "probas": probas} def page_predictions_to_lpboxes(predictions): @@ -100,22 +95,3 @@ def page_predictions_to_lpboxes(predictions): def predictions_to_lpboxes(predictions_per_page): return map(page_predictions_to_lpboxes, predictions_per_page) - - - - - - - - - - - - - - - - - - -