code stringlengths 17 6.64M |
|---|
class SHREC(InMemoryDataset):
'The shrec classification dataset.\n\n This is the remeshed version from MeshCNN.\n\n .. note::\n\n Data objects hold mesh faces instead of edge indices.\n To convert the mesh to a graph, use the\n :obj:`torch_geometric.transforms.FaceToEdge` as :obj:`pre_t... |
def read_obj(path):
mesh = openmesh.read_trimesh(path)
pos = torch.from_numpy(mesh.points()).to(torch.float)
face = torch.from_numpy(mesh.face_vertex_indices())
face = face.t().to(torch.long).contiguous()
return Data(pos=pos, face=face)
|
def test(args):
path = osp.join(osp.dirname(osp.realpath(__file__)), 'data/ShapeNet')
pre_transform = Compose((T.NormalizeScale(), T.GeodesicFPS(args.num_points)))
transform = Compose((T.RandomScale(((2 / 3), (3 / 2))), T.RandomTranslateGlobal(0.1)))
test_dataset = ShapeNet(path, categories=args.class... |
def evaluate(model, device, loader, args):
model.eval()
test_pred_seg_acc = None
test_pred_seg = []
test_true_seg = []
test_label_seg = []
for i in progressbar(range(args.num_votes)):
for data in loader:
data = data.to(device)
with torch.no_grad():
... |
def train(args, writer):
path = osp.join(osp.dirname(osp.realpath(__file__)), 'data/ModelNet{}'.format(args.num_classes))
pre_transform = Compose((T.NormalizeScale(), SamplePoints((args.num_points * args.sampling_margin), include_normals=True), T.GeodesicFPS(args.num_points)))
transform = Compose((T.Rando... |
def train_epoch(epoch, model, device, optimizer, loader, writer):
'Train the model for one iteration on each item in the loader.'
model.train()
total_loss = 0
running_loss = 0.0
train_pred = []
train_true = []
for (i, data) in enumerate(loader):
data = data.to(device)
optim... |
def evaluate(model, device, loader):
'Evaluate the model for on each item in the loader.'
model.eval()
correct = 0
eval_pred = []
eval_true = []
for data in loader:
data = data.to(device)
with torch.no_grad():
pred = model(data).max(dim=1)[1]
correct += pred... |
def train(args, writer):
path = osp.join(osp.dirname(osp.realpath(__file__)), 'data/ScanObjectNN')
pre_transform = T.GeodesicFPS(args.num_points)
transform = Compose((RandomRotate(360, 1), RandomTranslate(0.01), T.RandomScale(((4 / 5), (5 / 4))), T.RandomTranslateGlobal(0.1)))
train_dataset = ScanObje... |
def train_epoch(epoch, model, device, optimizer, loader, writer):
'Train the model for one iteration on each item in the loader.'
model.train()
total_loss = 0
running_loss = 0.0
train_pred = []
train_true = []
for (i, data) in enumerate(loader):
data = data.to(device)
optim... |
def evaluate(model, device, loader):
'Evaluate the model for on each item in the loader.'
model.eval()
correct = 0
eval_pred = []
eval_true = []
for data in loader:
data = data.to(device)
with torch.no_grad():
pred = model(data).max(dim=1)[1]
correct += pred... |
def train(args, writer):
path = osp.join(osp.dirname(osp.realpath(__file__)), 'data/ShapeNet')
pre_transform = Compose((T.NormalizeScale(), T.GeodesicFPS(args.num_points)))
transform = Compose((T.RandomScale(((2 / 3), (3 / 2))), T.RandomTranslateGlobal(0.2)))
train_dataset = ShapeNet(path, categories=... |
def shapenet_model(args, num_classes):
' Define ShapeNet model in a separate function, so it can be reused by the test script. '
return DeltaNetSegmentation(in_channels=3, num_classes=num_classes, conv_channels=[64, 128, 256], mlp_depth=2, embedding_size=1024, num_neighbors=args.k, grad_regularizer=args.grad_... |
def train_epoch(epoch, model, device, optimizer, loader, writer, args):
'Train the model for one iteration on each item in the loader.'
model.train()
total_loss = 0
running_loss = 0.0
train_pred_seg = []
train_true_seg = []
train_label_seg = []
for (i, data) in enumerate(loader):
... |
def evaluate(model, device, loader, args):
'Evaluate the model for on each item in the loader.'
model.eval()
correct = 0
eval_pred_seg = []
eval_true_seg = []
eval_label_seg = []
for data in loader:
data = data.to(device)
if (args.class_choice is not None):
labe... |
def train(args, writer):
path = osp.join(osp.dirname(osp.realpath(__file__)), 'data/ShapeSeg')
pre_transform = Compose((T.NormalizeArea(), T.NormalizeAxes(), GenerateMeshNormals(), T.SamplePoints((args.num_points * args.sampling_margin), include_normals=True, include_labels=True), T.GeodesicFPS(args.num_point... |
def train_epoch(epoch, model, device, optimizer, loader, writer):
'Train the model for one iteration on each item in the loader.'
model.train()
running_loss = 0.0
for (i, data) in enumerate(loader):
optimizer.zero_grad()
out = model(data.to(device))
loss = calc_loss(out, data.y... |
def evaluate(model, device, loader):
'Evaluate the model for on each item in the loader.'
model.eval()
correct = 0
total_num = 0
for data in loader:
pred = model(data.to(device)).max(1)[1]
correct += pred.eq(data.y).sum().item()
total_num += data.y.size(0)
eval_acc = (c... |
def train(args, writer):
path = osp.join(osp.dirname(osp.realpath(__file__)), 'data/shrec')
pre_transform = Compose((T.NormalizeScale(), SamplePoints((args.num_points * args.sampling_margin), include_normals=True), T.GeodesicFPS(args.num_points)))
transform = Compose((T.RandomRotate(360, 0), T.RandomRotat... |
def train_epoch(epoch, model, device, optimizer, loader, writer):
'Train the model for one iteration on each item in the loader.'
model.train()
total_loss = 0
running_loss = 0.0
train_pred = []
train_true = []
for (i, data) in enumerate(loader):
data = data.to(device)
optim... |
def evaluate(model, device, loader):
'Evaluate the model for on each item in the loader.'
model.eval()
correct = 0
eval_pred = []
eval_true = []
for data in loader:
data = data.to(device)
with torch.no_grad():
pred = model(data).max(dim=1)[1]
correct += pred... |
def calc_loss(pred, true, smoothing=True):
'Calculate cross entropy loss, apply label smoothing if needed.'
true = true.contiguous().view((- 1))
if smoothing:
eps = 0.2
n_class = pred.size(1)
one_hot = torch.zeros_like(pred).scatter(1, true.view((- 1), 1), 1)
one_hot = ((on... |
def calc_shape_IoU(pred_np, seg_np, label, class_choice):
'Calculate IoU for a shape in ShapeNet.'
seg_num = [4, 2, 2, 4, 4, 3, 3, 2, 4, 2, 6, 2, 3, 3, 3, 3]
index_start = [0, 4, 6, 8, 12, 16, 19, 22, 24, 28, 30, 36, 38, 41, 44, 47]
label = label.squeeze()
shape_ious = []
for shape_idx in rang... |
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=''):
Extension.__init__(self, name, sources=[])
self.sourcedir = os.path.abspath(sourcedir)
|
class CMakeBuild(build_ext):
def run(self):
try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
raise RuntimeError(('CMake must be installed to build the following extensions: ' + ', '.join((e.name for e in self.extensions))))
if (platform.sy... |
def test_geodesic_fps():
n = 1024
n_samples = 512
pos = np.random.randn(n, 3)
samples1 = geodesic_fps(pos, n)
assert (samples1.shape[0] == n)
assert (np.unique(samples1).shape[0] == n)
samples2 = geodesic_fps(pos, n_samples)
assert (samples2.shape[0] == n_samples)
assert (np.unique... |
def test_batch_dot():
a = torch.rand(1024, 10)
b = torch.rand(1024, 10)
a_dot_b = (a * b).sum(dim=1, keepdim=True)
out = batch_dot(a, b)
assert torch.allclose(out, a_dot_b)
|
def test_deltaconv():
N = 1000
C_in = 3
C_out = 32
torch.manual_seed(1)
conv = DeltaConv(C_in, C_out, depth=1, centralized=True, vector=True)
assert (conv.__repr__() == f'DeltaConv({C_in}, {C_out})')
x = torch.rand(N, C_in)
edge_index = knn_graph(x, 20, loop=True, flow='target_to_sourc... |
def test_mlp():
x = torch.rand(10, 16)
mlp1 = MLP((16, 32))
out = mlp1(x)
assert (out.size(1) == 32)
assert (out.isnan().sum() == 0)
mlp2 = MLP((16, 32, 32, 64))
out = mlp2(x)
assert (out.size(1) == 64)
assert (out.isnan().sum() == 0)
|
def test_vectormlp():
N = 1000
C_in = 16
C_out = 32
v = torch.rand(N, C_in)
v_mlp1 = VectorMLP((C_in, C_out))
out = v_mlp1(v)
assert (out.size(1) == C_out)
assert (out.isnan().sum() == 0)
v_mlp2 = VectorMLP((C_in, C_out, C_out, C_out))
out = v_mlp2(v)
assert (out.size(1) ==... |
def test_scalarvectormlp_identity():
N = 1000
C_in = 16
C_out = 32
x = torch.rand(N, C_in)
v = torch.rand((N * 2), C_in)
sv_mlp = ScalarVectorMLP((C_in, C_out), vector_stream=True)
sv_out_sv = sv_mlp((x, v))
assert (type(sv_out_sv) is tuple)
assert (sv_out_sv[0].size(1) == C_out)
... |
def test_batchnorm1d():
bn = BatchNorm1d(10)
bn.reset_parameters()
assert (bn.__repr__() == 'BatchNorm1d(10)')
x = torch.stack(([torch.rand(10)] * 4), dim=0)
out = bn(x)
assert isinstance(out, Tensor)
assert (out.size() == x.size())
assert torch.allclose(out, torch.zeros_like(x))
a... |
def test_vectornonlin():
vnl = VectorNonLin(4)
vnl.reset_parameters()
assert (vnl.__repr__() == 'VectorNonLin(batchnorm=None)')
v = torch.rand((10, 4))
out = vnl(v)
assert isinstance(out, Tensor)
assert torch.allclose(out, v)
assert (torch.isnan(out).sum() == 0)
vnl_bn = VectorNonL... |
def calculate_diff_w_significance(A_scores, B_scores, alpha=1e-05):
A_scores = np.array(A_scores)
B_scores = np.array(B_scores)
mu = (np.mean(A_scores) - np.mean(B_scores))
p_value = stats.ttest_ind(A_scores, B_scores, alternative='greater')[1]
mu_variance = ((np.var(A_scores) / len(A_scores)) + (... |
class D5():
def __init__(self, A_samples: List[str], B_samples: List[str], validator: Validator, proposer, top_fraction: List[float]=None, total_hypotheses_count: int=60, early_stop: bool=True, top_K_hypotheses: int=5):
(self.A_samples, self.B_samples) = (A_samples, B_samples)
(self.proposer, sel... |
def subsample(samples, n=1000):
selected_idxes = list(range(len(samples)))
random.shuffle(selected_idxes)
selected_idxes = selected_idxes[:n]
return [samples[i] for i in sorted(selected_idxes)]
|
def flip_problem(problem):
problem = deepcopy(problem)
(problem['A_desc'], problem['B_desc']) = (problem['B_desc'], problem['A_desc'])
problem['split'] = {k: {'A_samples': v['B_samples'], 'B_samples': v['A_samples']} for (k, v) in problem['split'].items()}
return problem
|
def classify_cmp(x: str) -> bool:
tokenized_x = nltk.word_tokenize(x)
pos_tags = nltk.pos_tag(tokenized_x)
all_tags = {t[1] for t in pos_tags}
return any(((tag in ('JJR', 'RBR')) for tag in all_tags))
|
def construct_blocks(A_samples: List[str], B_samples: List[str], num_incontext_samples: int=25):
A_subsampled_samples = np.random.choice(A_samples, min(num_incontext_samples, len(A_samples)), replace=False)
A_block = ''.join([(('Group A: ' + s) + '\n') for s in A_subsampled_samples])
B_subsampled_samples ... |
def prefix_subspan(x: str, prefix_token_max_len: int=SINGLE_SAMPLE_MAX_LENGTH, tok: AutoTokenizer=GPT3_TOK) -> str:
tokens = tok.tokenize(x)
total_length = len(tokens)
if (total_length <= prefix_token_max_len):
return x
subspan_toks = tokens[:prefix_token_max_len]
return (tok.convert_token... |
def convert_cmp_to_ind(s: str) -> str:
for _ in range(3):
if (not classify_cmp(s)):
break
prompt = rm_cmp_prompt.format(input=s)
response = gpt3wrapper(prompt=prompt, max_tokens=2048, temperature=0.0, top_p=1, frequency_penalty=0.0, presence_penalty=0.0, stop=['\n\n'], engine='... |
def gpt3wrapper(max_repeat=20, **arguments):
i = 0
while (i < max_repeat):
try:
response = openai.Completion.create(**arguments)
return response
except KeyboardInterrupt:
raise KeyboardInterrupt
except Exception as e:
print(e)
... |
class GPT3_Proposer():
def __init__(self, problem, use_default_hypotheses=False, single_max_length=SINGLE_SAMPLE_MAX_LENGTH, engine_name='text-davinci-003', temperature=0.7):
if use_default_hypotheses:
self.example_hypotheses = DEFAULT_HYPOTHESES
else:
self.example_hypothe... |
def flip_problem(problem):
problem = deepcopy(problem)
(problem['A_desc'], problem['B_desc']) = (problem['B_desc'], problem['A_desc'])
problem['split'] = {k: {'A_samples': v['B_samples'], 'B_samples': v['A_samples']} for (k, v) in problem['split'].items()}
return problem
|
def subsample(samples, n=1000):
selected_idxes = list(range(len(samples)))
random.shuffle(selected_idxes)
selected_idxes = selected_idxes[:n]
return [samples[i] for i in sorted(selected_idxes)]
|
def re_order(sorted_l: List[str], top_p: float) -> List[str]:
part1 = sorted_l[:(int((len(sorted_l) * top_p)) + 1)]
part2 = sorted_l[(int((len(sorted_l) * top_p)) + 1):]
np.random.shuffle(part1)
np.random.shuffle(part2)
return (part1 + part2)
|
def get_word_set_of_sample(sample: str) -> Set[str]:
sample_no_punc = sample.translate(str.maketrans('', '', string.punctuation))
word_set = {ps.stem(word) for word in word_tokenize(sample_no_punc) if (word not in stops)}
return word_set
|
def lexical_diversity(sorted_A: List[str], sorted_B: List[str], top_p: float=0.2, num_samples: int=4, max_gap=None):
(sorted_A, sorted_B) = (deepcopy(sorted_A), deepcopy(sorted_B))
a_candidates = []
b_candidates = []
if (max_gap is None):
max_gap = ((num_samples // 4) + 1)
reordered_A = re... |
class BaseDataLoader(DataLoader):
'\n Base class for all data loaders\n '
def __init__(self, dataset, batch_size, shuffle, validation_split, num_workers, collate_fn=default_collate):
self.validation_split = validation_split
self.shuffle = shuffle
self.batch_idx = 0
self.... |
class BaseModel(nn.Module):
'\n Base class for all models\n '
@abstractmethod
def forward(self, *inputs):
'\n Forward pass logic\n\n :return: Model output\n '
raise NotImplementedError
def __str__(self):
'\n Model prints with number of traina... |
class BaseTrainer():
'\n Base class for all trainers\n '
def __init__(self, model, loss, metrics, optimizer, config):
self.config = config
if ('trainer' in config.config):
self.logger = config.get_logger('trainer', config['trainer']['verbosity'])
cfg_trainer = co... |
def main(config):
logger = config.get_logger('test')
output_dir = Path(config.config.get('output_dir', 'saved'))
output_dir.mkdir(exist_ok=True, parents=True)
file_name = config.config.get('file_name', 'pc.ply')
use_mask = config.config.get('use_mask', True)
roi = config.config.get('roi', None... |
class KittiOdometryDataloader(BaseDataLoader):
def __init__(self, batch_size=1, shuffle=True, validation_split=0.0, num_workers=4, **kwargs):
self.dataset = KittiOdometryDataset(**kwargs)
super().__init__(self.dataset, batch_size, shuffle, validation_split, num_workers)
|
def main():
parser = argparse.ArgumentParser(description='\n This script creates depth images from annotated velodyne data.\n ')
parser.add_argument('--output', '-o', help='Path of KITTI odometry dataset', default='../../../data/dataset')
parser.add_argument('--input', '-i', help='Pa... |
def main(config: ConfigParser):
logger = config.get_logger('train')
data_loader = config.initialize('data_loader', module_data)
loss = getattr(module_loss, config['loss'])
metrics = [getattr(module_metric, met) for met in config['metrics']]
if ('arch' in config.config):
models = [config.in... |
class Evaluater(BaseTrainer):
'\n Trainer class\n\n Note:\n Inherited from BaseTrainer.trainer\n '
def __init__(self, model, loss, metrics, config, data_loader):
super().__init__(model, loss, metrics, None, config)
self.config = config
self.data_loader = data_loader
... |
def to(data, device):
if isinstance(data, dict):
return {k: to(data[k], device) for k in data.keys()}
elif isinstance(data, list):
return [to(v, device) for v in data]
else:
return data.to(device)
|
def setup_logging(save_dir, log_config='logger/logger_config.json', default_level=logging.INFO):
'\n Setup logging configuration\n '
log_config = Path(log_config)
if log_config.is_file():
config = read_json(log_config)
for (_, handler) in config['handlers'].items():
if ('... |
class TensorboardWriter():
def __init__(self, log_dir, logger, enabled):
self.writer = None
self.selected_module = ''
if enabled:
log_dir = str(log_dir)
succeeded = False
for module in ['torch.utils.tensorboard', 'tensorboardX']:
try:
... |
class CrossCueFusion(nn.Module):
def __init__(self, cv_hypo_num=32, mid_dim=32, input_size=(256, 512)):
super().__init__()
self.cv_hypo_num = cv_hypo_num
self.mid_dim = mid_dim
self.residual_connection = True
self.is_reduce = (True if (input_size[1] > 650) else False)
... |
class MultiGuideMono(nn.Module):
def __init__(self, cv_hypo_num=32, mid_dim=32, input_size=(256, 512)):
super().__init__()
self.cv_hypo_num = cv_hypo_num
self.mid_dim = mid_dim
self.residual_connection = True
self.is_reduce = (True if (input_size[1] > 650) else False)
... |
class MonoGuideMulti(nn.Module):
def __init__(self, cv_hypo_num=32, mid_dim=32, input_size=(256, 512)):
super().__init__()
self.cv_hypo_num = cv_hypo_num
self.mid_dim = mid_dim
self.residual_connection = True
self.is_reduce = (True if (input_size[1] > 650) else False)
... |
class DyMultiDepthModel(nn.Module):
def __init__(self, inv_depth_min_max=(0.33, 0.0025), cv_depth_steps=32, pretrain_mode=False, pretrain_dropout=0.0, pretrain_dropout_mode=0, augmentation=None, use_mono=True, use_stereo=False, use_ssim=True, sfcv_mult_mask=True, simple_mask=False, mask_use_cv=True, mask_use_fea... |
def completeness_metric(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, roi=None, max_distance=None):
return torch.mean((depth_prediction != 0).to(dtype=torch.float32))
|
def covered_gt_metric(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, roi=None, max_distance=None):
gt_mask = (depth_gt != 0)
return mask_mean((depth_prediction != 0).to(dtype=torch.float32), gt_mask)
|
def sc_inv_metric(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, roi=None, max_distance=None):
'\n Computes scale inveriant metric described in (14)\n :param depth_prediction: Depth prediction computed by the network\n :param depth_gt: GT Depth\n :param roi: Specify a region of interest on wh... |
def l1_rel_metric(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, roi=None, max_distance=None):
'\n Computes the L1-rel metric described in (15)\n :param depth_prediction: Depth prediction computed by the network\n :param depth_gt: GT Depth\n :param roi: Specify a region of interest on which t... |
def l1_inv_metric(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, roi=None, max_distance=None):
'\n Computes the L1-inv metric described in (16)\n :param depth_prediction: Depth prediction computed by the network\n :param depth_gt: GT Depth\n :param roi: Specify a region of interest on which t... |
def a1_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(depth_pre... |
def a2_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(depth_pre... |
def a3_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(depth_pre... |
def rmse_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(depth_p... |
def rmse_log_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(dep... |
def abs_rel_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(dept... |
def sq_rel_metric(data_dict: dict, roi=None, max_distance=None):
depth_prediction = data_dict['result']
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, depth_gt, roi)
(depth_prediction, depth_gt) = get_positive_depth(depth_prediction, depth_gt)
(depth... |
def find_mincost_depth(cost_volume, depth_hypos):
argmax = torch.argmax(cost_volume, dim=1, keepdim=True)
mincost_depth = torch.gather(input=depth_hypos, dim=1, index=argmax)
return mincost_depth
|
def a1_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, dep... |
def a2_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, dep... |
def a3_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, dep... |
def rmse_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction, d... |
def rmse_log_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_predictio... |
def abs_rel_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction... |
def sq_rel_sparse_metric(data_dict: dict, roi=None, max_distance=None, pred_all_valid=True, use_cvmask=False, eval_mono=False):
depth_prediction = (data_dict['result_mono'] if eval_mono else data_dict['result'])
depth_gt = data_dict['target']
(depth_prediction, depth_gt) = preprocess_roi(depth_prediction,... |
def save_results(path, name, img, gt_depth, pred_depth, validmask, cv_mask, costvolume):
savepath = os.path.join(path, name)
device = img.device
(bs, _, h, w) = img.shape
img = (img[(0, ...)].permute(1, 2, 0).detach().cpu().numpy() + 0.5)
gt_depth = gt_depth[(0, ...)].permute(1, 2, 0).detach().cpu... |
def a1_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return a1_sparse_metric(data_dict, roi, max_distance, False)
|
def a2_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return a2_sparse_metric(data_dict, roi, max_distance, False)
|
def a3_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return a3_sparse_metric(data_dict, roi, max_distance, False)
|
def rmse_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return rmse_sparse_metric(data_dict, roi, max_distance, False)
|
def rmse_log_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return rmse_log_sparse_metric(data_dict, roi, max_distance, False)
|
def abs_rel_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return abs_rel_sparse_metric(data_dict, roi, max_distance, False)
|
def sq_rel_sparse_onlyvalid_metric(data_dict: dict, roi=None, max_distance=None):
return sq_rel_sparse_metric(data_dict, roi, max_distance, False)
|
def a1_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return a1_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def a2_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return a2_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def a3_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return a3_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def rmse_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return rmse_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def rmse_log_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return rmse_log_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def abs_rel_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return abs_rel_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def sq_rel_sparse_onlydynamic_metric(data_dict: dict, roi=None, max_distance=None):
return sq_rel_sparse_metric(data_dict, roi, max_distance, use_cvmask=True)
|
def a1_base(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, mask):
thresh = torch.max((depth_gt / depth_prediction), (depth_prediction / depth_gt))
return mask_mean((thresh < 1.25).type(torch.float), mask)
|
def a2_base(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, mask):
depth_gt[mask] = 1
depth_prediction[mask] = 1
thresh = torch.max((depth_gt / depth_prediction), (depth_prediction / depth_gt)).type(torch.float)
return mask_mean((thresh < (1.25 ** 2)).type(torch.float), mask)
|
def a3_base(depth_prediction: torch.Tensor, depth_gt: torch.Tensor, mask):
depth_gt[mask] = 1
depth_prediction[mask] = 1
thresh = torch.max((depth_gt / depth_prediction), (depth_prediction / depth_gt)).type(torch.float)
return mask_mean((thresh < (1.25 ** 3)).type(torch.float), mask)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.