text
stringlengths
1
93.6k
import json
CONFIG = json.load(open("config.json"))
DIR_NAME = "%s/%s" % (CONFIG["BASE_DATA_DIR"], CONFIG["DATA_DIR"])
CV_filenames = [glob.glob("%s/%s/*.xml" % (DIR_NAME, i)) for i in range(1,6)]
filenames = reduce(lambda x, y: x + y, CV_filenames[0:])
WordToken.set_vocab() # Initialize an empty vocab
index_word, word_dict, index_char, char_dict = gen_vocab(filenames, n_words = 50000, min_freq=3)
save_vocab(word_dict, save_file="index_word.txt")
logger.info("Saved %s index for vocab words in file %s." % (len(index_word), "index_word.txt"))
save_vocab(char_dict, save_file="index_char.txt")
logger.info("Saved %s index for vocab chars in file %s." % (len(index_char), "index_char.txt"))
# <FILESEP>
#!/usr/bin/env python3
# This file is covered by the LICENSE file in the root of this project.
import os
import sys
import yaml
import argparse
import numpy as np
from tqdm import tqdm
from utils.np_ioueval import iouEval
DISTANCES = [(1e-8, 300.0),
(1e-8, 10.0),
(10.0, 20.0),
(20.0, 30.0),
(30.0, 40.0),
(40.0, 50.0),
(50.0, 60.0),
(60.0, 70.0),
(70.0, 80.0),
(80.0, 300.0),]
def get_args():
parser = argparse.ArgumentParser("./evaluate_semantics.py")
parser.add_argument(
'--eval_type', '-e',
default='all',
type=str, choices=['all', 'sub'],
help='Eval ALL or just eval Subsample')
parser.add_argument(
'--dataset', '-d',
type=str,
default='/home/chx/Work/SemanticPOSS_dataset/sequences',
help='Dataset dir. No Default',
)
parser.add_argument(
'--predictions', '-p',
type=str,
default='/home/chx/Work/PT-RandLA-Net/poss_result/test-baaf-random',
help='Prediction dir. Same organization as dataset, but predictions in'
'each sequences "prediction" directory. No Default. If no option is set'
' we look for the labels in the same directory as dataset'
)
parser.add_argument(
'--sequences', '-s',
nargs="+",
default=["03"],
help='evaluated sequences',
)
parser.add_argument(
'--datacfg', '-dc',
type=str,
required=False,
default="utils/semantic-poss.yaml",
help='Dataset config file. Defaults to %(default)s',
)
parser.add_argument(
'--limit', '-l',
type=int,
required=False,
default=None,
help='Limit to the first "--limit" points of each scan. Useful for'
' evaluating single scan from aggregated pointcloud.'
' Defaults to %(default)s',
)
FLAGS = parser.parse_args()
# fill in real predictions dir
if FLAGS.predictions is None:
FLAGS.predictions = FLAGS.dataset
return FLAGS
def load_label(data_root, sequences, sub_dir_name, ext):
label_names = []
for sequence in sequences:
sequence = '{0:02d}'.format(int(sequence))
label_paths = os.path.join(data_root, str(sequence), sub_dir_name)
# populate the label names
seq_label_names = [os.path.join(dp, f) for dp, dn, fn in os.walk(
os.path.expanduser(label_paths)) for f in fn if f".{ext}" in f]
seq_label_names.sort()
label_names.extend(seq_label_names)
return label_names