applied black
This commit is contained in:
parent
381fe2dbf5
commit
d694866e1e
@ -4,7 +4,7 @@ from operator import attrgetter, itemgetter
|
|||||||
|
|
||||||
from frozendict import frozendict
|
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):
|
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)
|
dx = min(a.xmax, b.xmax) - max(a.xmin, b.xmin)
|
||||||
dy = min(a.ymax, b.ymax) - max(a.ymin, b.ymin)
|
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):
|
def compute_union(a, b):
|
||||||
@ -35,7 +35,7 @@ def compute_iou(a, b):
|
|||||||
return compute_intersection(a, b) / compute_union(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):
|
def less_likely(a, b):
|
||||||
@ -47,8 +47,7 @@ def overlap_too_much(a, b, iou_thresh):
|
|||||||
return iou > 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):
|
def remove_less_likely(a, b):
|
||||||
try:
|
try:
|
||||||
ll = less_likely(a, b)
|
ll = less_likely(a, b)
|
||||||
@ -80,11 +79,7 @@ def lpboxes_to_dict(lpboxes):
|
|||||||
|
|
||||||
boxes, classes, probas = map(list, [boxes, classes, probas])
|
boxes, classes, probas = map(list, [boxes, classes, probas])
|
||||||
|
|
||||||
return {
|
return {"bboxes": boxes, "classes": classes, "probas": probas}
|
||||||
"bboxes": boxes,
|
|
||||||
"classes": classes,
|
|
||||||
"probas": probas
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def page_predictions_to_lpboxes(predictions):
|
def page_predictions_to_lpboxes(predictions):
|
||||||
@ -100,22 +95,3 @@ def page_predictions_to_lpboxes(predictions):
|
|||||||
|
|
||||||
def predictions_to_lpboxes(predictions_per_page):
|
def predictions_to_lpboxes(predictions_per_page):
|
||||||
return map(page_predictions_to_lpboxes, predictions_per_page)
|
return map(page_predictions_to_lpboxes, predictions_per_page)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user