-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented IOU for
BaseBx
and added unittests (#1)
# Main commits * implemented intersection-over-union (IOU) for `BaseBx` * added unittests for all modules * Implemented classmethod and `bbx()` for `BaseBx` class to convert all types to `BaseBx` * `ops` now handles all type conversions (json-array, list-array) * bug fixes, best caught: * `BaseBx` method `xywh()` flipped `w` and `h` * read keys in order of `voc_keys` for json annotations) * updated README.md and nbs/ ## Squashed commit messages: * move voc_keys to anchor.py * add new corrected annots_rand.json, annots_iou.json * Implemented iou and fixed bbx.xywh() bug, inserted classmethod for bbx * function to make json, list -> array function to calculate the intersecting box dimension. * adding testing scripts * adding testing scripts * comment fixed * add tests for all modules * update README.md
- Loading branch information
1 parent
ccb18ca
commit bf37cb7
Showing
12 changed files
with
371 additions
and
158 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[ | ||
{ | ||
"x_min": 20.0, | ||
"y_min": 10.0, | ||
"x_max": 70.0, | ||
"y_max": 80.0, | ||
"label": "b1" | ||
}, | ||
{ | ||
"x_min": 50.0, | ||
"y_min": 60.0, | ||
"x_max": 120.0, | ||
"y_max": 150.0, | ||
"label": "b2" | ||
}, | ||
{ | ||
"x_min": 50.0, | ||
"y_min": 60.0, | ||
"x_max": 70.0, | ||
"y_max": 80.0, | ||
"label": "int" | ||
} | ||
] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
import unittest | ||
|
||
import numpy as np | ||
|
||
from pybx import anchor | ||
|
||
np.random.seed(1) | ||
|
||
params = { | ||
"feature_szs": [(2, 2), (3, 3), (4, 4)], | ||
"asp_ratios": [1 / 2., 1., 2.], | ||
"feature_sz": (2, 2), | ||
"asp_ratio": 1 / 2., | ||
"image_sz": (10, 10, 3), | ||
"data_dir": '../data', | ||
} | ||
|
||
results = { | ||
"bx_b": 236.8933982822018, | ||
"bx_l": 'a_2x2_0.5_8', | ||
"bxs_b": 3703.086279536432, | ||
"bxs_l": 'a_4x4_2.0_24', | ||
"scaled_ans": (9.0, 6.0), | ||
} | ||
|
||
|
||
class AnchorTestCase(unittest.TestCase): | ||
def test_bx(self): | ||
b, l_ = anchor.bx(params["image_sz"], params["feature_sz"], params["asp_ratio"]) | ||
self.assertIn(results["bx_l"], l_, 'label not matching') | ||
self.assertEqual(len(b), len(l_)) | ||
self.assertEqual(b.sum(), results["bx_b"], 'sum not matching') # add assertion here | ||
|
||
def test_bxs(self): | ||
b, l_ = anchor.bxs(params["image_sz"], params["feature_szs"], params["asp_ratios"]) | ||
self.assertIn(results["bxs_l"], l_, 'label not matching') | ||
self.assertEqual(len(b), len(l_)) | ||
self.assertEqual(b.sum(), results["bxs_b"], 'sum not matching') # add assertion here | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.