Skip to content

Commit

Permalink
Add documentation for heatmap class
Browse files Browse the repository at this point in the history
  • Loading branch information
vniclas committed Jun 23, 2021
1 parent d96f938 commit 87a7bc4
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 210 deletions.
14 changes: 14 additions & 0 deletions docs/reference/engine-target.md
Expand Up @@ -277,3 +277,17 @@ The [SpeechCommand](#class_engine.target.SpeechCommand) class has the following
#### SpeechCommand(prediction, confidence=None)
Construct a new [SpeechCommand](#class_engine.target.SpeechCommand) object based from *prediction*.
*prediction* is expected to be an integer designating the class and optional *confidence* a float between 0 and 1.

### class engine.target.Heatmap
Bases: *ToDo: Inherit from engine.target.Target (issue #90)*

This target is used for multi-class segmentation problems or multi-class problems that require heatmap annotations/outputs.

The [Heatmap](#class_engine.target.Heatmap) class has the following public methods:
#### Heatmap(data, description=None, class_names=None)
Construct a new [Heatmap](#class_engine.target.Heatmap) object based from *data*.
- *data* is expected to be a numpy array
- *description* is expected to be a string [optional]
- *class_names* is expected to be a dictionary and can be used for mapping class IDs (integer) to names (string) [optional]
#### shape()
Returns the shape of the underlying *data* object.
79 changes: 39 additions & 40 deletions src/opendr/engine/target.py
Expand Up @@ -149,15 +149,14 @@ class BoundingBox(Target):
This target is used for 2D Object Detection.
A bounding box is described by the left-top corner and its width and height.
"""

def __init__(
self,
name,
left,
top,
width,
height,
score=0,
self,
name,
left,
top,
width,
height,
score=0,
):
super().__init__()
self.name = name
Expand Down Expand Up @@ -203,14 +202,15 @@ class BoundingBoxList(Target):
"""

def __init__(
self,
boxes,
self,
boxes,
):
super().__init__()
self.data = boxes
self.confidence = np.mean([box.confidence for box in self.data])

def mot(self, with_confidence=True):

result = np.array([
box.mot(with_confidence) for box in self.data
])
Expand Down Expand Up @@ -239,17 +239,16 @@ class TrackingAnnotation(Target):
This target is used for 2D Object Tracking.
A tracking bounding box is described by id, the left-top corner and its width and height.
"""

def __init__(
self,
name,
left,
top,
width,
height,
id,
score=0,
frame=-1,
self,
name,
left,
top,
width,
height,
id,
score=0,
frame=-1,
):
super().__init__()
self.name = name
Expand Down Expand Up @@ -312,10 +311,9 @@ class TrackingAnnotationList(Target):
This target is used for 2D Object Tracking.
A bounding box is described by the left and top corners and its width and height.
"""

def __init__(
self,
boxes,
self,
boxes,
):
super().__init__()
self.data = boxes
Expand All @@ -330,6 +328,7 @@ def from_mot(data):
return TrackingAnnotationList(boxes)

def mot(self, with_confidence=True):

result = np.array([
box.mot(with_confidence) for box in self.data
])
Expand Down Expand Up @@ -554,20 +553,19 @@ class TrackingAnnotation3D(BoundingBox3D):
truncation (truncated) and occlusion (occluded) levels, the name of an object (name) and
observation angle of an object (alpha).
"""

def __init__(
self,
name,
truncated,
occluded,
alpha,
bbox2d,
dimensions,
location,
rotation_y,
id,
score=0,
frame=-1,
self,
name,
truncated,
occluded,
alpha,
bbox2d,
dimensions,
location,
rotation_y,
id,
score=0,
frame=-1,
):
self.data = {
"name": name,
Expand All @@ -584,6 +582,7 @@ def __init__(
self.confidence = score

def kitti(self, with_tracking_info=True):

result = {}

result["name"] = np.array([self.data["name"]])
Expand Down Expand Up @@ -633,10 +632,9 @@ class TrackingAnnotation3DList(Target):
truncation (truncated) and occlusion (occluded) levels, the name of an object (name) and
observation angle of an object (alpha).
"""

def __init__(
self,
tracking_bounding_boxes_3d
self,
tracking_bounding_boxes_3d
):
super().__init__()
self.data = tracking_bounding_boxes_3d
Expand Down Expand Up @@ -764,7 +762,8 @@ def __str__(self):
return f"Class {self.data} speech command"


#ToDo: Inherit from Target class
#ToDo: Inherit from Target class:
# The problem is that the variables in Target are not masked private (leading underscore) preventing proper getter/setters
class Heatmap():
"""
This target is used for multi-class segmentation problems or multi-class problems that require heatmap annotations.
Expand Down
Expand Up @@ -146,7 +146,6 @@ def gen_packages_items():
name='mmdet',
version=get_version(),
description='Open MMLab Detection Toolbox and Benchmark',
# long_description=readme(),
author='OpenMMLab',
author_email='chenkaidev@gmail.com',
keywords='computer vision, object detection',
Expand All @@ -166,12 +165,6 @@ def gen_packages_items():
setup_requires=parse_requirements('requirements/build.txt'),
tests_require=parse_requirements('requirements/tests.txt'),
install_requires=parse_requirements('requirements/runtime.txt'),
# extras_require={
# 'all': parse_requirements('requirements.txt'),
# 'tests': parse_requirements('requirements/tests.txt'),
# 'build': parse_requirements('requirements/build.txt'),
# 'optional': parse_requirements('requirements/optional.txt'),
# },
ext_modules=[
make_cuda_ext(name='compiling_info', module='mmdet.ops.utils', sources=['src/compiling_info.cpp']),
make_cuda_ext(name='nms_cpu', module='mmdet.ops.nms', sources=['src/nms_cpu.cpp']),
Expand Down

This file was deleted.

@@ -1,3 +1,16 @@
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from pathlib import Path
from typing import List, Tuple

Expand Down Expand Up @@ -35,7 +48,7 @@ def train():
config_file=str(Path(__file__).parent / 'configs' / 'singlegpu_sample.py')
)
learner.fit(train_dataset, val_dataset=val_dataset, logging_path=str(Path(__file__).parent / 'work_dir'))
learner.save(path=f'{DATA_ROOT}/checkpoints/efficientPS/sample/model.path')
learner.save(path=f'{DATA_ROOT}/checkpoints/efficientPS/sample/model.pth')


def evaluate():
Expand Down
Expand Up @@ -9,5 +9,5 @@ cityscapesscripts==2.2.0
git+git://github.com/waspinator/pycococreator.git@0.2.0
git+https://github.com/mapillary/inplace_abn.git

./algorithm/efficientNet
./algorithm/mmdetection
-e ./algorithm/efficientNet
-e ./algorithm/mmdetection

0 comments on commit 87a7bc4

Please sign in to comment.