Optimize LightGlue for accuracy or speed
mainMaximize Accuracy
To use all keypoints and disable adaptive mechanisms:
extractor = SuperPoint(max_num_keypoints=None)
matcher = LightGlue(features='superpoint', depth_confidence=-1, width_confidence=-1)Maximize Speed
To decrease keypoints and lower adaptive thresholds:
extractor = SuperPoint(max_num_keypoints=1024)
matcher = LightGlue(features='superpoint', depth_confidence=0.9, width_confidence=0.95)Use PyTorch Compilation
For maximum speed (requires torch >= 2.0):
matcher = matcher.eval().cuda()
matcher.compile(mode='reduce-overhead')Note: For inputs with < 1536 keypoints, compilation disables point pruning due to overhead. For larger inputs, it falls back to eager mode with point pruning.