Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficientdet #256

Merged
merged 8 commits into from
Feb 8, 2023
Next Next commit
BoxesTo* processor is now selected via 'method' argument in the const…
…ructor of ToBoxes2D class.
  • Loading branch information
Manojkumarmuru committed Feb 7, 2023
commit a143bb6d3b6d322337ec8ac108abac7b4818eea7
2 changes: 1 addition & 1 deletion examples/efficientdet/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def call(self, image):
ScaleBox(image_scales),
NonMaximumSuppressionPerClass(self.nms_thresh),
FilterBoxes(self.class_names, self.score_thresh),
ToBoxes2D(self.class_names, box_type='BoxesWithOneHotVectors'),
ToBoxes2D(self.class_names, method=0),
RemoveClass(self.class_names, class_arg=None)])
outputs = process_outputs(outputs)
boxes2D = postprocessing(outputs)
Expand Down
23 changes: 9 additions & 14 deletions examples/efficientdet/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,28 +160,23 @@ class ToBoxes2D(Processor):
"""
def __init__(
self, class_names=None, one_hot_encoded=False,
default_score=1.0, default_class=None,
box_type='BoxesWithOneHotVectors'):
default_score=1.0, default_class=None, method=0):
if class_names is not None:
self.arg_to_class = dict(zip(range(len(class_names)), class_names))
self.one_hot_encoded = one_hot_encoded
self.default_score = default_score
self.default_class = default_class
self.box_type = box_type
method_to_processor = {0: BoxesWithOneHotVectorsToBoxes2D(
self.arg_to_class),
1: BoxesToBoxes2D(
self.default_score, self.default_class),
2: BoxesWithClassArgToBoxes2D(
self.arg_to_class, self.default_score)}
self.box_processor = method_to_processor[method]
super(ToBoxes2D, self).__init__()

def call(self, boxes):
if self.box_type == 'Boxes':
box_processor = BoxesToBoxes2D(
self.default_score, self.default_class)
elif self.box_type == 'BoxesWithOneHotVectors':
box_processor = BoxesWithOneHotVectorsToBoxes2D(self.arg_to_class)
elif self.box_type == "BoxesWithClassArg":
box_processor = BoxesWithClassArgToBoxes2D(
self.arg_to_class, self.default_score)
else:
raise ValueError('Invalid box type: ', self.box_type)
return box_processor(boxes)
return self.box_processor(boxes)


class BoxesToBoxes2D(Processor):
Expand Down