MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / inference

Function inference

dust3r/inference.py:56–72  ·  view source on GitHub ↗
(pairs, model, device, batch_size=8, verbose=True)

Source from the content-addressed store, hash-verified

54
55@torch.no_grad()
56def inference(pairs, model, device, batch_size=8, verbose=True):
57 if verbose:
58 print(f'>> Inference with model on {len(pairs)} image pairs')
59 result = []
60
61 # first, check if all images have the same size
62 multiple_shapes = not (check_if_same_size(pairs))
63 if multiple_shapes: # force bs=1
64 batch_size = 1
65
66 for i in tqdm.trange(0, len(pairs), batch_size, disable=not verbose):
67 res = loss_of_one_batch(collate_with_cat(pairs[i:i + batch_size]), model, None, device)
68 result.append(to_cpu(res))
69
70 result = collate_with_cat(result, lists=multiple_shapes)
71
72 return result
73
74
75def check_if_same_size(pairs):

Callers 3

mainFunction · 0.90
mainFunction · 0.90
get_reconstructed_sceneFunction · 0.90

Calls 4

collate_with_catFunction · 0.90
to_cpuFunction · 0.90
check_if_same_sizeFunction · 0.85
loss_of_one_batchFunction · 0.85

Tested by 1

mainFunction · 0.72