Skip to content

Commit

Permalink
Inference/evaluation in BDD format; Tensorboard support (#3)
Browse files Browse the repository at this point in the history
* Inference/evaluation in BDD format

* Tensorboard support
  • Loading branch information
haofengac authored Dec 5, 2018
1 parent d51b6f1 commit 518e26a
Show file tree
Hide file tree
Showing 11 changed files with 429 additions and 394 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ maskrcnn_benchmark.egg-info/
build/
dist/

# pytorch/python/numpy formats
# pytorch/python/numpy/json formats
*.pth
*.pkl
*.npy
*.json

# ipython/jupyter notebooks
*.ipynb
Expand All @@ -28,6 +29,9 @@ dist/
# project dirs
/datasets
/models
logs
out
out_*

# log
log.txt
2 changes: 2 additions & 0 deletions maskrcnn_benchmark/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,5 @@
_C.OUTPUT_DIR = "."

_C.PATHS_CATALOG = os.path.join(os.path.dirname(__file__), "paths_catalog.py")

_C.TENSORBOARD_LOGDIR = 'logs'
15 changes: 13 additions & 2 deletions maskrcnn_benchmark/data/datasets/bdd100k.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}

TYPE_ID_CONVERSION = {
'person': 0,
'vehicle': 1
'person': 1,
'vehicle': 2
}

class Bdd100kDataset(Dataset):
Expand Down Expand Up @@ -82,3 +82,14 @@ def __getitem__(self, idx):
def get_img_info(self, idx):
img = Image.open(os.path.join(self.image_dir, self.image_paths[idx]))
return {'width': img.width, 'height': img.height}

# Get all gt labels. Used in evaluation.
def get_gt_labels(self):

return self.labels


def get_classes_ids(self):
return TYPE_ID_CONVERSION;


46 changes: 43 additions & 3 deletions maskrcnn_benchmark/data/datasets/kitti.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
}

TYPE_ID_CONVERSION = {
'person': 0,
'vehicle': 1
'person': 1,
'vehicle': 2
}

KITTI_MAX_WIDTH = 1242
Expand Down Expand Up @@ -55,7 +55,6 @@ def __len__(self):


def __getitem__(self, idx):

# load image
img = ToTensor()(Image.open(os.path.join(self.image_dir, self.image_paths[idx])))
# padding
Expand Down Expand Up @@ -89,3 +88,44 @@ def __getitem__(self, idx):

def get_img_info(self, idx):
return {'width': KITTI_MAX_WIDTH, 'height': KITTI_MAX_HEIGHT}

# Get all gt labels. Used in evaluation.
def get_gt_labels(self):

gt_labels = []

for i, label_path in enumerate(self.label_paths):
gt_label = {
'name': self.image_paths[i],
'labels': [],
}
with open(os.path.join(self.label_dir, label_path)) as f:
labels = f.read().splitlines()

for label in labels:
attributes = label.split(' ')
if attributes[0] in CLASS_TYPE_CONVERSION.keys():
# TODO: further filter annotations if needed

label_type = CLASS_TYPE_CONVERSION[attributes[0]]
category = TYPE_ID_CONVERSION[label_type]
box = [float(c) for c in attributes[4:8]]

gt_label['labels'] += [{
'category': category,
'box2d': {
'x1': box[0],
'y1': box[1],
'x2': box[2],
'y2': box[3]
}
}]

gt_labels += [gt_label]

return gt_labels


def get_classes_ids(self):
return TYPE_ID_CONVERSION;

Loading

0 comments on commit 518e26a

Please sign in to comment.