text
stringlengths
1
93.6k
if __name__ == '__main__':
FLAGS = get_args()
# print summary of what we will do
print("*" * 80)
print("INTERFACE:")
print("Eval What:", FLAGS.eval_type)
print("Data: ", FLAGS.dataset)
print("Predictions: ", FLAGS.predictions)
print("Sequences: ", FLAGS.sequences)
print("Config: ", FLAGS.datacfg)
print("Limit: ", FLAGS.limit)
print("*" * 80)
print("Opening data config file %s" % FLAGS.datacfg)
DATA = yaml.safe_load(open(FLAGS.datacfg, 'r'))
# get number of interest classes, and the label mappings
class_strings = DATA["labels"]
class_ignore = DATA["learning_ignore"]
class_inv_remap = DATA["learning_map_inv"]
nr_classes = len(class_inv_remap)
data_config = FLAGS.datacfg
DATA = yaml.safe_load(open(data_config, 'r'))
remap_dict = DATA["learning_map"]
max_key = max(remap_dict.keys())
remap_lut = np.zeros((max_key + 100), dtype=np.int32)
remap_lut[list(remap_dict.keys())] = list(remap_dict.values())
# create evaluator
ignore = []
for cl, ign in class_ignore.items():
if ign:
x_cl = int(cl)
ignore.append(x_cl)
print("Ignoring xentropy class ", x_cl, " in IoU evaluation")
# create evaluator
# create evaluator
evaluators = []
for i in range(len(DISTANCES)):
evaluators.append(iouEval(nr_classes, ignore))
evaluators[i].reset()
# get label paths
if FLAGS.eval_type == "sub":
label_names = load_label(FLAGS.dataset, FLAGS.sequences, "labels", "npy")
else:
label_names = load_label(FLAGS.dataset, FLAGS.sequences, "labels", "label")
py_names = load_label(FLAGS.dataset, FLAGS.sequences, "velodyne", "bin")
# py_names = py_names[0:len(py_names):4]
# get predictions paths
pred_names = load_label(FLAGS.predictions, FLAGS.sequences, "predictions", "label")
# label_names = label_names[0:len(label_names):4]
print(len(label_names), len(pred_names))
assert(len(label_names) == len(pred_names))
print("Evaluating sequences")
N = len(label_names)
# open each file, get the tensor, and make the iou comparison
for i in tqdm(range(N)):
label_file = label_names[i]
pred_file = pred_names[i]
points_file = py_names[i]
# open label
if FLAGS.eval_type == "sub":
label = np.load(label_file)
label = label.reshape((-1)) # reshape to vector
else:
label = np.fromfile(label_file, dtype=np.int32)
label = label.reshape((-1))
sem_label = label & 0xFFFF # semantic label in lower half
inst_label = label >> 16 # instance id in upper half
assert ((sem_label + (inst_label << 16) == label).all())
label = remap_lut[sem_label]
if FLAGS.limit is not None:
label = label[:FLAGS.limit] # limit to desired length
# open prediction
pred = np.fromfile(pred_file, dtype=np.int32)
pred = pred.reshape((-1)) # reshape to vector
pred = remap_lut[pred]
if FLAGS.limit is not None:
pred = pred[:FLAGS.limit] # limit to desired length
# add single scan to evaluation
xyzr = np.fromfile(points_file, dtype=np.float32)
xyzr = xyzr.reshape((-1, 4))
points = xyzr[:, 0:3]
if FLAGS.limit is not None: