Skip to content

Commit f720fd6

Browse files
adityaarun1ruotianluo
authored andcommitted
cleanup and code formatting
1 parent 8041ca8 commit f720fd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3265
-4622
lines changed

lib/datasets/coco.py

Lines changed: 250 additions & 243 deletions
Large diffs are not rendered by default.

lib/datasets/ds_utils.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,39 @@
1111

1212

1313
def unique_boxes(boxes, scale=1.0):
14-
"""Return indices of unique boxes."""
15-
v = np.array([1, 1e3, 1e6, 1e9])
16-
hashes = np.round(boxes * scale).dot(v)
17-
_, index = np.unique(hashes, return_index=True)
18-
return np.sort(index)
14+
"""Return indices of unique boxes."""
15+
v = np.array([1, 1e3, 1e6, 1e9])
16+
hashes = np.round(boxes * scale).dot(v)
17+
_, index = np.unique(hashes, return_index=True)
18+
return np.sort(index)
1919

2020

2121
def xywh_to_xyxy(boxes):
22-
"""Convert [x y w h] box format to [x1 y1 x2 y2] format."""
23-
return np.hstack((boxes[:, 0:2], boxes[:, 0:2] + boxes[:, 2:4] - 1))
22+
"""Convert [x y w h] box format to [x1 y1 x2 y2] format."""
23+
return np.hstack((boxes[:, 0:2], boxes[:, 0:2] + boxes[:, 2:4] - 1))
2424

2525

2626
def xyxy_to_xywh(boxes):
27-
"""Convert [x1 y1 x2 y2] box format to [x y w h] format."""
28-
return np.hstack((boxes[:, 0:2], boxes[:, 2:4] - boxes[:, 0:2] + 1))
27+
"""Convert [x1 y1 x2 y2] box format to [x y w h] format."""
28+
return np.hstack((boxes[:, 0:2], boxes[:, 2:4] - boxes[:, 0:2] + 1))
2929

3030

3131
def validate_boxes(boxes, width=0, height=0):
32-
"""Check that a set of boxes are valid."""
33-
x1 = boxes[:, 0]
34-
y1 = boxes[:, 1]
35-
x2 = boxes[:, 2]
36-
y2 = boxes[:, 3]
37-
assert (x1 >= 0).all()
38-
assert (y1 >= 0).all()
39-
assert (x2 >= x1).all()
40-
assert (y2 >= y1).all()
41-
assert (x2 < width).all()
42-
assert (y2 < height).all()
32+
"""Check that a set of boxes are valid."""
33+
x1 = boxes[:, 0]
34+
y1 = boxes[:, 1]
35+
x2 = boxes[:, 2]
36+
y2 = boxes[:, 3]
37+
assert (x1 >= 0).all()
38+
assert (y1 >= 0).all()
39+
assert (x2 >= x1).all()
40+
assert (y2 >= y1).all()
41+
assert (x2 < width).all()
42+
assert (y2 < height).all()
4343

4444

4545
def filter_small_boxes(boxes, min_size):
46-
w = boxes[:, 2] - boxes[:, 0]
47-
h = boxes[:, 3] - boxes[:, 1]
48-
keep = np.where((w >= min_size) & (h > min_size))[0]
49-
return keep
46+
w = boxes[:, 2] - boxes[:, 0]
47+
h = boxes[:, 3] - boxes[:, 1]
48+
keep = np.where((w >= min_size) & (h > min_size))[0]
49+
return keep

lib/datasets/factory.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
# Licensed under The MIT License [see LICENSE for details]
55
# Written by Ross Girshick
66
# --------------------------------------------------------
7-
87
"""Factory method for easily getting imdbs by name."""
98
from __future__ import absolute_import
109
from __future__ import division
@@ -16,37 +15,37 @@
1615

1716
import numpy as np
1817

19-
# Set up voc_<year>_<split>
18+
# Set up voc_<year>_<split>
2019
for year in ['2007', '2012']:
21-
for split in ['train', 'val', 'trainval', 'test']:
22-
name = 'voc_{}_{}'.format(year, split)
23-
__sets[name] = (lambda split=split, year=year: pascal_voc(split, year))
20+
for split in ['train', 'val', 'trainval', 'test']:
21+
name = 'voc_{}_{}'.format(year, split)
22+
__sets[name] = (lambda split=split, year=year: pascal_voc(split, year))
2423

2524
for year in ['2007', '2012']:
26-
for split in ['train', 'val', 'trainval', 'test']:
27-
name = 'voc_{}_{}_diff'.format(year, split)
28-
__sets[name] = (lambda split=split, year=year: pascal_voc(split, year, use_diff=True))
25+
for split in ['train', 'val', 'trainval', 'test']:
26+
name = 'voc_{}_{}_diff'.format(year, split)
27+
__sets[name] = (lambda split=split, year=year: pascal_voc(split, year, use_diff=True))
2928

3029
# Set up coco_2014_<split>
3130
for year in ['2014']:
32-
for split in ['train', 'val', 'minival', 'valminusminival', 'trainval']:
33-
name = 'coco_{}_{}'.format(year, split)
34-
__sets[name] = (lambda split=split, year=year: coco(split, year))
31+
for split in ['train', 'val', 'minival', 'valminusminival', 'trainval']:
32+
name = 'coco_{}_{}'.format(year, split)
33+
__sets[name] = (lambda split=split, year=year: coco(split, year))
3534

3635
# Set up coco_2015_<split>
3736
for year in ['2015']:
38-
for split in ['test', 'test-dev']:
39-
name = 'coco_{}_{}'.format(year, split)
40-
__sets[name] = (lambda split=split, year=year: coco(split, year))
37+
for split in ['test', 'test-dev']:
38+
name = 'coco_{}_{}'.format(year, split)
39+
__sets[name] = (lambda split=split, year=year: coco(split, year))
4140

4241

4342
def get_imdb(name):
44-
"""Get an imdb (image database) by name."""
45-
if name not in __sets:
46-
raise KeyError('Unknown dataset: {}'.format(name))
47-
return __sets[name]()
43+
"""Get an imdb (image database) by name."""
44+
if name not in __sets:
45+
raise KeyError('Unknown dataset: {}'.format(name))
46+
return __sets[name]()
4847

4948

5049
def list_imdbs():
51-
"""List all registered imdbs."""
52-
return list(__sets.keys())
50+
"""List all registered imdbs."""
51+
return list(__sets.keys())

0 commit comments

Comments
 (0)