-
Notifications
You must be signed in to change notification settings - Fork 652
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
Bikerack filtering #83
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
3555d7e
spellcheck
sourabh-nutonomy 853f509
add points_in_box() method to check whether points are inside the box
sourabh-nutonomy f8a2c24
test points_in_box() method
sourabh-nutonomy afa6699
perform bike rack filtering
sourabh-nutonomy b835f29
docstring for filter_eval_boxes
sourabh-nutonomy b19a103
Merge remote-tracking branch 'origin/release_v0.2' into bikerack_filt…
sourabh-nutonomy b7adb4d
added unittests for filter_eval_boxes()
sourabh-nutonomy 3fa82f5
update comment
sourabh-nutonomy aa843c6
Merge remote-tracking branch 'origin/release_v0.2' into bikerack_filt…
sourabh-nutonomy fd469ab
fix docstring
sourabh-nutonomy 6f7e790
can't use Box type because of a circular import. So switched to 'Box'
sourabh-nutonomy b80d3fd
can't use Box type because of a circular import. So switched to 'Box'
sourabh-nutonomy 9f0a8ad
Merge remote-tracking branch 'origin/release_v0.2' into bikerack_filt…
Alex-nutonomy 11a7e30
change threshold after bikerack filtering
sourabh-nutonomy ec27a6a
get max_dist from eval_detection_configs
sourabh-nutonomy d0b467a
Merge branch 'bikerack_filtering' of github.com:/nutonomy/nuscenes-de…
sourabh-nutonomy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
python-sdk/nuscenes/eval/detection/tests/test_loader.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# nuScenes dev-kit. | ||
# Code written by Sourabh Vora, 2019. | ||
# Licensed under the Creative Commons [see licence.txt] | ||
|
||
import os | ||
import unittest | ||
|
||
from nuscenes import NuScenes | ||
from nuscenes.eval.detection.config import eval_detection_configs | ||
from nuscenes.eval.detection.loaders import filter_eval_boxes | ||
from nuscenes.eval.detection.data_classes import EvalBox, EvalBoxes | ||
|
||
|
||
class TestLoader(unittest.TestCase): | ||
def test_filter_eval_boxes(self): | ||
""" | ||
This tests runs the evaluation for an arbitrary random set of predictions. | ||
This score is then captured in this very test such that if we change the eval code, | ||
this test will trigger if the results changed. | ||
""" | ||
assert 'NUSCENES' in os.environ, 'Set NUSCENES env. variable to enable tests.' | ||
|
||
nusc = NuScenes(version='v1.0-mini', dataroot=os.environ['NUSCENES'], verbose=False) | ||
|
||
sample_token = '0af0feb5b1394b928dd13d648de898f5' | ||
# This sample has a bike rack instance 'bfe685042aa34ab7b2b2f24ee0f1645f' with these parameters | ||
# 'translation': [683.681, 1592.002, 0.809], | ||
# 'size': [1.641, 14.465, 1.4], | ||
# 'rotation': [0.3473693995546558, 0.0, 0.0, 0.9377283723195315] | ||
|
||
max_dist = eval_detection_configs['cvpr_2019']['class_range'] | ||
|
||
# Test bicycle filtering by creating a box at the same position as the bike rack. | ||
box1 = EvalBox(sample_token=sample_token, | ||
translation=(683.681, 1592.002, 0.809), | ||
size=(1, 1, 1), | ||
detection_name='bicycle') | ||
|
||
eval_boxes = EvalBoxes() | ||
eval_boxes.add_boxes('0af0feb5b1394b928dd13d648de898f5', [box1]) | ||
|
||
filtered_boxes = filter_eval_boxes(nusc, eval_boxes, max_dist) | ||
|
||
self.assertEqual(len(filtered_boxes.boxes[sample_token]), 0) # box1 should be filtered. | ||
|
||
# Test motorcycle filtering by creating a box at the same position as the bike rack. | ||
box2 = EvalBox(sample_token=sample_token, | ||
translation=(683.681, 1592.002, 0.809), | ||
size=(1, 1, 1), | ||
detection_name='motorcycle') | ||
|
||
eval_boxes = EvalBoxes() | ||
eval_boxes.add_boxes('0af0feb5b1394b928dd13d648de898f5', [box1, box2]) | ||
|
||
filtered_boxes = filter_eval_boxes(nusc, eval_boxes, max_dist) | ||
|
||
self.assertEqual(len(filtered_boxes.boxes[sample_token]), 0) # both box1 and box2 should be filtered. | ||
|
||
# Now create a car at the same position as the bike rack. | ||
box3 = EvalBox(sample_token=sample_token, | ||
translation=(683.681, 1592.002, 0.809), | ||
size=(1, 1, 1), | ||
detection_name='car') | ||
|
||
eval_boxes = EvalBoxes() | ||
eval_boxes.add_boxes('0af0feb5b1394b928dd13d648de898f5', [box1, box2, box3]) | ||
|
||
filtered_boxes = filter_eval_boxes(nusc, eval_boxes, max_dist) | ||
|
||
self.assertEqual(len(filtered_boxes.boxes[sample_token]), 1) # box1 and box2 to be filtered. box3 to stay. | ||
self.assertEqual(filtered_boxes.boxes[sample_token][0].detection_name, 'car') | ||
|
||
# Now add a bike outside the bike rack. | ||
|
||
box4 = EvalBox(sample_token=sample_token, | ||
translation=(68.681, 1592.002, 0.809), | ||
size=(1, 1, 1), | ||
detection_name='bicycle') | ||
|
||
eval_boxes = EvalBoxes() | ||
eval_boxes.add_boxes('0af0feb5b1394b928dd13d648de898f5', [box1, box2, box3, box4]) | ||
|
||
filtered_boxes = filter_eval_boxes(nusc, eval_boxes, max_dist) | ||
|
||
self.assertEqual(len(filtered_boxes.boxes[sample_token]), 2) # box1, box2 to be filtered. box3, box4 to stay. | ||
self.assertEqual(filtered_boxes.boxes[sample_token][0].detection_name, 'car') | ||
self.assertEqual(filtered_boxes.boxes[sample_token][1].detection_name, 'bicycle') | ||
self.assertEqual(filtered_boxes.boxes[sample_token][1].translation[0], 68.681) | ||
|
||
# Add another bike on the bike rack center but set the ego_dist higher than what's defined in max_dist | ||
box5 = EvalBox(sample_token=sample_token, | ||
translation=(683.681, 1592.002, 0.809), | ||
size=(1, 1, 1), | ||
detection_name='bicycle', | ||
ego_dist=100.0) | ||
|
||
eval_boxes = EvalBoxes() | ||
eval_boxes.add_boxes('0af0feb5b1394b928dd13d648de898f5', [box1, box2, box3, box4, box5]) | ||
|
||
filtered_boxes = filter_eval_boxes(nusc, eval_boxes, max_dist) | ||
self.assertEqual(len(filtered_boxes.boxes[sample_token]), 2) # box1, box2, box5 filtered. box3, box4 to stay. | ||
self.assertEqual(filtered_boxes.boxes[sample_token][0].detection_name, 'car') | ||
self.assertEqual(filtered_boxes.boxes[sample_token][1].detection_name, 'bicycle') | ||
self.assertEqual(filtered_boxes.boxes[sample_token][1].translation[0], 68.681) | ||
|
||
# Add another bike on the bike rack center but set the num_pts to be zero so that it gets filtered. | ||
box6 = EvalBox(sample_token=sample_token, | ||
translation=(683.681, 1592.002, 0.809), | ||
size=(1, 1, 1), | ||
detection_name='bicycle', | ||
num_pts=0) | ||
|
||
eval_boxes = EvalBoxes() | ||
eval_boxes.add_boxes('0af0feb5b1394b928dd13d648de898f5', [box1, box2, box3, box4, box5, box6]) | ||
|
||
filtered_boxes = filter_eval_boxes(nusc, eval_boxes, max_dist) | ||
self.assertEqual(len(filtered_boxes.boxes[sample_token]), 2) # box1, box2, box5, box6 filtered. box3, box4 stay | ||
self.assertEqual(filtered_boxes.boxes[sample_token][0].detection_name, 'car') | ||
self.assertEqual(filtered_boxes.boxes[sample_token][1].detection_name, 'bicycle') | ||
self.assertEqual(filtered_boxes.boxes[sample_token][1].translation[0], 68.681) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include motorcycle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the instructions https://github.com/nutonomy/nuscenes-devkit/blob/master/instructions.md#bicycle-rack, a bike rack only mentions bicycles. But I know from our review that sometimes motorcycles are parked inside bike racks.