Manuscript Offprint
arXiv:2609.07373TRAIL: Trajectory-Aware Visual Place Recognition against Unordered Databases
Dominik A. Kloepfer¹★ and Patrick Wenzel²
¹ Visual Geometry Group (VGG), University of Oxford ² Helsing

Fig. 1: Incorporating information from previous images in a sequence boosts Visual Place Recognition (VPR) performance in challenging settings. We compare the top-1 Recall of the state-of-the-art VPR algorithm MegaLoc [6] with our system, which makes use of previous images in the sequence (see Sec. 4 for full results).
Abstract. Modern Visual Place Recognition (VPR) methods excel on standard benchmarks yet remain brittle in feature-poor environments. By treating each query image in isolation, they discard the sequential context in any real trajectory. We formalize a task that exploits this context: given a query sequence, localize the final image against an unordered reference database—which, unlike sequence-to-sequence methods, requires no sequential structure in the database. We propose TRAIL (TRajectory-Aware Image Localization), a principled framework based on Conditional Random Fields (CRF) that combines learned functions for visual similarity and for camera-motion consistency, refining a distribution over candidate references as each query arrives. A lightweight post-processing layer atop any pre-trained VPR backbone, TRAIL improves a state-of-the-art baseline by up to 8.3 percentage points on our primary benchmark, transfers to unseen datasets without retraining, and delivers its largest gains where visual cues are scarce.
- Work partially done during an internship at Helsing.
1 Introduction
Visual Place Recognition (VPR), the task of matching query images against a reference database to determine camera location, has seen remarkable progress in recent years. Leveraging large-scale datasets and powerful pre-trained visual encoders such as DINOv2 [33], modern methods achieve impressive performance on established benchmarks [2, 6, 21, 23].
Yet, this progress masks a fundamental brittleness. In visually challenging scenarios such as rural landscapes, forests, or uniform highway environments, performance degrades sharply due to a lack of distinctive visual cues. Recent work has further exposed fragility in seemingly robust systems, revealing sensitivity to minor variations in evaluation parameters like retrieval distance thresholds [20].
This brittleness is particularly troubling given VPR's role in many important applications: camera relocalization, loop closure detection in SLAM, and hierarchical localization systems where VPR provides the initial coarse estimate.
We observe that standard VPR formulations exacerbate this brittleness through an artificial constraint: treating each query image in isolation. This single-image paradigm, while convenient for benchmarking, discards critical information available in any real navigation scenario. Cameras follow continuous trajectories through space, and each new observation arrives with strong geometric priors from preceding frames. Such information dramatically constrains the search space, but the standard VPR formulation is unable to leverage it.
Prior sequence-based VPR methods [7, 11, 25, 31, 47] operate in a sequence-to-sequence paradigm requiring the reference database to be organized as ordered sequences covering the same routes as potential queries. This imposes a significant structural constraint: it demands exhaustive coverage of all possible trajectories through the environment. In practice, however, reference imagery is typically collected opportunistically, from mapping vehicles, crowd-sourced platforms, or satellite data, yielding unordered sets of geo-tagged images rather than structured sequences.
In this paper, we formalize a task that addresses these limitations: given a sequence of query images, the goal is to localize the final query image against an unordered reference database. This setting captures the practical scenario of an agent that needs to determine its current position, exploiting the context from its recent trajectory without imposing any structural requirements on the database. We develop TRAIL (TRjectory-Aware Image Localization), a principled probabilistic framework for this task, leveraging Bayesian filtering to maintain and update a probability distribution over reference locations as new query images arrive. Crucially, this framework operates as a post-processing step over existing VPR methods, requiring no architectural modifications and minimal computational overhead.
Specifically, our contributions are as follows:
(a) We formalize a Sequential Visual Place Recognition task that operates on unordered reference databases and targets localization of the final query image, clearly distinguishing it from the sequence-to-sequence paradigm adopted by prior work (Sec. 3.1).
(b) We introduce TRAIL, a probabilistic framework for incorporating sequential context into place recognition, designed to maximize retrieval accuracy while imposing minimal computational overhead (Sec. 3.2, Sec. 3.3, Sec. 3.4).
(c) We empirically validate our proposed framework and demonstrate its effectiveness on challenging datasets (Sec. 4).
By exploiting the temporal structure of navigation sequences, our method achieves notable improvements in both robustness and accuracy. Its simplicity and compatibility with existing systems make it well-suited for integration into real-world localization pipelines.
These advances have led to the saturation of several previously challenging benchmarks. However, challenges persist; for example, Izquierdo and Civera [20] have illustrated the heavy reliance of recall performance on the distance threshold that determines correct retrievals.
Sequential Visual Place Recognition. Sequence-based localization originates from loop closure detection, where SeqSLAM [32] and its variants [5, 36] match query sequences against previously visited locations. This sequence-to-sequence paradigm has since been extended to general VPR; SeqNet [11] learns descriptors for sequence-based hierarchical retrieval, Mereu et al. [31] aggregate single-image descriptors into sequence-level representations, JIST [7] jointly trains image and sequence descriptors, Zhao et al. [47] apply spatio-temporal attention to construct sequence descriptors, and CaseVPR [25] performs correlation-aware alignment between query and database sequences. Closely related, Lynen et al. [28] match continuous query image streams against previously recorded trajectories, and SeqMatchNet [12] learns single-image descriptors that are explicitly shaped by a sequence-matching metric, collapsing to standard single-image retrieval when no ordered references are available. Despite CaseVPR framing its task as sequence-to-frame, its retrieval stage, too, operates over database sequences. All of these methods thus require the reference database to be organized as ordered sequences, which demands exhaustive route coverage of the environment.
The setting most closely related to ours is the seq2im task described by Warburg et al. [41], which pairs query sequences with an unordered reference database. However, their formulation considers a retrieval correct if it is near any image in the query sequence, rather than targeting a specific one. We formalize a stricter variant that reflects the practical localization objective: determining the position of the final query image, and develop TRAIL, a CRF-based framework, to address it.
Probabilistic Models for Sequence Localization. Some methods employ Hidden Markov Models (HMM) for sequence localization, such as the work by Rudić et al. [35] in indoor environments, and Gui et al. [14] who used LiDAR scans for unmanned ground vehicle localization in enclosed spaces. These approaches typically use discretized camera locations as hidden states, creating large state spaces that pose challenges in expansive environments. In contrast, we estimate directly the probability that database images are close to the true camera location, offering a novel approach to efficiently managing large environments.
Other approaches such as Cadena et al. [8] use a formulation based on Conditional Random Fields (CRF), which we, too, use in our theoretical treatment (see Sec. 3.2 and Appendix Sec. A). However, existing works do not address the problem of visual place recognition with a very large database but instead focus on loop closure in SLAM pipelines, which have a significantly smaller set of reference images. Most directly related, Xu et al. [45] perform probabilistic topometric localization with a discrete Bayes filter whose forward recurrence coincides with the one we derive (Appendix Sec. A). Their setting differs substantially, however, assuming an ordered reference map with per-edge odometry; transferring it to our unordered databases is non-trivial and forces simplifications that strip away much of its odometry-driven motion model, so that the resulting baseline fails to consistently improve over plain single-image retrieval (Appendix Sec. F).
More broadly, sequence and trajectory priors are widely used in the robotics-localization literature for loop-closure detection and verification in SLAM, with recent examples such as ROVER [46] exploiting trajectory priors to reject false loop closures in repetitive environments. These methods, however, operate under far milder appearance variation than VPR (generally no day-night or season shifts) and assume the existence of loops that revisit previously mapped locations; they therefore do not transfer straightforwardly to our setting, in which queries follow open trajectories with no guaranteed revisits and visual appearance can change drastically between query and reference.
3 TRAIL: Sequential VPR with Conditional Random Fields
3.1 Task Definition
Similarly to the standard Visual Place Recognition task, our goal is to localize an image with respect to a database set of unordered reference images with associated locations, , where is an RGB-image of dimensions and is a position coordinate.
In contrast to Visual Place Recognition, each query is not just a single query image, but a query sequence of length , so that with images typically taken in order by an agent traversing the environment and the set of all query sequences of length . Each image in the query sequence also has an associated location , the agent's location when collecting this query image.
Given such a query sequence, a Sequential-VPR algorithm retrieves a single reference image, so we can formally write . A retrieval is defined to be a correct retrieval if with . In other words, the algorithm attempts to localize the final query image in the query sequence by retrieving a reference image that was collected from a location within a certain threshold distance from the location of the query image.
This reflects the practical goal of localizing an agent now, i.e., at the end of its trajectory. We assume that reference images carry known positions (GPS or geotags), which is standard in VPR [6,41]. At inference time, reference positions are used for the distance cutoff (Eq. (8)) and the aggregation function (Eq. (4)).
We measure performance using a Recall@T metric: the fraction of query sequences of length for which the retrieved image is correct. The standard VPR Recall@1 metric corresponds to the special case . Note that denotes the sequence length, not the number of retrieved candidates as in the standard Recall@K metric; the two coincide only for .
We now introduce TRAIL, which leverages a pre-trained VPR algorithm to compute the probability that each database image is a correct retrieval for the final query image in a sequence, returning the location of the highest-probability reference image.
3.2 Inference
Our goal is to localize the final query image in the sequence, , as reliably as possible, maximizing the Recall@T. In other words, we want to return the reference image that has the highest probability of having been taken from a position within the threshold of the query image's position.
We proceed in two stages: First, we model where is a random variable with if the reference image is the retrieval image closest to query image and otherwise. Second, we use these probabilities to estimate , where is a random variable with if the reference image is within the distance threshold of the query image and otherwise.
In the appendix Sec. A, we show that under some light locality assumptions we can model this process using a Conditional Random Field (CRF) [24] and derive the following recurrence relation for the first stage:

Fig. 2: Diagram illustrating TRAIL, our approach for Sequential Visual Place Recognition. For each query image in the sequence (top row), a pre-trained VPR model retrieves the top- database images, shown below in order of decreasing emission potential (green border = correct retrieval, red = incorrect). The emission potential measures visual similarity between a query and a candidate reference image, while the transition potential (arrows, left) measures whether the spatial displacement between two candidate reference images is consistent with the observed camera motion between consecutive queries; thicker arrows indicate higher transition potentials. Right: Compared to using only emission potentials (top bars, not filled), fusing emission and transition potentials via the CRF recurrence (Eq. (2)) yields substantial accuracy gains (bottom bars, filled; see Sec. 4.4).
where
(2)
and are two probability potentials. Intuitively, measures the probability that the state where would ‘emit’ query image , effectively measuring the similarity of the query image and a given retrieved image. in turn measures the probability that the state where transitions to the state where , conditioned on the query images at and .
Both of these probability potentials can be parameterized using neural networks and .
In the second stage, we use the computed to compute , the probability of reference image being within the distance threshold of the query image . We approximate
This approximation allows us to model using some appropriate function .
The complete forward algorithm is given in Algorithm 1. To obtain the predicted query image location at time step , we return the location of the highest-probability reference image: where .
Algorithm 1 Forward Algorithm for Sequential VPR
Require: Require: Require:
1:
2: for do
3:
4: end for
5: for do
6:
7:
8: end for
9: return ,
3.3 Network Architecture and Modeling Choices
In principle, we need to compute for all images in the retrieval database. The large size of the database, however, makes this intractable, so we set and only compute for the top- reference images retrieved by a pre-trained VPR algorithm .
Unless is very large, there is a non-negligible probability that none of the top- retrievals are actually within the distance threshold of a given query image. To account for this case, we add a dustbin state with iff . We found improved performance by setting , which corresponds to the case where the algorithm “lost track” of the query location.
Choice of . We require and for , with smooth interpolation between these points. Intuitively, models the distribution of the minimum localization error when , i.e., reference image is the best possible reference image; if this error was always zero and the location of the best possible reference image always coincided with the query image location, the optimal would be with as the indicator function.
We choose a scaled sigmoid:
(4) with the offset fixed and the bandwidth learnable. The scaling factor ensures that , while the indicator function ensures that . This function consists of an initial flat section followed by a quick decay towards zero. The boundary condition for directly mirrors the evaluation criterion (a retrieval is correct iff it lies within ). Just as any retrieval method must define what counts as correct, encodes the same notion into the probability model. Our ablation (Sec. D) shows that replacing the scaled sigmoid with a supergaussian yields similar performance, confirming that the framework is robust to the particular functional form of .
Network Architectures. Finally, we also need to make some modeling choices for the network architectures of and . Since we already use a pre-trained visual place recognition algorithm to constrain the candidate reference images at each time step, it would be efficient to use intermediate results computed by that algorithm. In our experiments, we use the standard form of visual place recognition algorithms that compute global image descriptors by first extracting local image features that are then aggregated into a single vector. We make the following choices:
First, we notice that the task performed by is similar to pure Visual Place Recognition without sequential information, and so to the task that the global image descriptors are trained to do. We therefore set
with * corresponding to element-wise multiplication and MLP denoting a small multi-layer perceptron, as a sort of 'generalized cosine-similarity'.
To compute the probability potentials , we first want to compute descriptors for the movement between the reference images and and between the query images and , and then assign a high probability potential if these transitions are similar. For the latter step, we again use a generalized cosine-similarity
We compute the transition descriptors by computing the cosine-similarity between each pair of local image features and arranging them into a tensor of shape , which we pass through a convolutional neural network:
Finally, we notice that the probability potential should be zero for pairs of retrieval images that are very far apart, as a transition between those would be physically impossible. We therefore set when the positions of the retrieval images are too far apart. This leaves us with
Intuition. Intuitively, the recurrence Eq. (2) suppresses candidate reference images whose locations are inconsistent with earlier observations: if an earlier query image was confidently matched to database image , for the current query image the transition potentials will down-weight candidate images at locations relative to 's location that do not match the query images' trajectory.
Even when no single image is easy to match (e.g., along a feature-poor highway), the transition potentials implicitly compare the relative camera motion inferred from reference image pairs with the motion observed in the query sequence, progressively constraining the set of plausible locations.
3.4 Training
End-to-End Training. The entire algorithm Algorithm 1 is differentiable, so given a pre-trained algorithm we train the entire system end-to-end by applying a binary cross-entropy loss on the computed :
(9)
To improve training dynamics, we apply this loss at every timestep, not just :
In our implementation, we perform all calculations in log-space for improved numerical stability. The relevant derivations and equations can be found in the appendix in Sec. B.
Pre-Training. End-to-end training is sped up and stabilized by first pre-training and individually with cross-entropy losses.
For , given query images with candidate retrievals from , we train using:
where is the closest candidate to the query position.
For , we sample consecutive query pairs and, for efficiency, train transitions from the correct retrieval to candidates . That is, for each pair of query images we also select , the candidate retrieval with the position closest to , and candidate retrievals . We then compute and again apply a cross-entropy loss:
4 Experiments
4.1 Datasets
Mapillary Street-Level Sequences To train and evaluate TRAIL, we need datasets containing images with associated camera locations, organized into individual image sequences. A large and diverse dataset that fits these requirements is the Mapillary Street-Level Sequences (MSLS) [41] dataset, and accordingly we use it as our main training dataset. This dataset contains 1.6 million images collected from short sequences of dashcam footage in 30 cities around the globe, providing a large and diverse set of images for training and evaluation.
Since individual sequences are split across the original 'query' and 'database' sets for each city, we merge them and construct a new database set for each sequence, against which localization is performed. For each sequence, the database set consists of all images from the same city that do not appear in the query sequence, and all results for MSLS cited in this paper refer to this setting.
To avoid degenerate sequences with little camera movement, we skip frames in a sequence that have a distance of less than 25.0 meters from the previous frame.
Evaluation Protocol. Prior work [21, 23] holds out the images collected in San Francisco and Copenhagen for validation. However, we notice that these two cities are among the easiest in the entire dataset, with some of the highest Recall@1 performance for state-of-the-art Visual Place Recognition algorithms such as MegaLoc [6]. We therefore instead hold out the images collected in Amsterdam and Boston for validation, which are more challenging. Whereas MegaLoc has a Recall@1 performance of 89% for images from Copenhagen and 84.5% for images from San Francisco, the Recall@1 performance for images from Amsterdam is 54.0% and 71.5% for images from Boston.
We continue to use the distance threshold of meters used in the literature [6, 21, 23].
Two main factors account for the slightly worse Recall@1 performance on the Mapillary-SLS dataset in our setting compared to the performance reported on the validation split of the dataset elsewhere in the literature even for images from Copenhagen and San Francisco (e.g., Berton et al. [6] reach 91.0% Recall@1). Firstly, we ensure that no images from the same sequence as a query image are included in the database. Secondly, we use all other sequences to create the database instead of a more curated sub-set of images. While this leads to a higher theoretically possible localization performance due to a denser coverage of a given environment, it also increases the number of distractor images among which a VPR-algorithm must discriminate.
Nordland Another dataset containing image sequences that can be used as query sequences in our setting is the Nordland dataset [37]. This dataset comprises videos of a train traversing a 728-kilometer route in Norway across four seasons.
TRAIL 11
The largely rural landscape, with few distinctive features that remain consistent across seasons, makes this a challenging setting. While its lack of visual diversity makes it unsuitable for training, we evaluate our model on Nordland without fine-tuning, using weights trained on MSLS.
Evaluation Protocol. The standard test split of the Nordland dataset discards the sequential nature of the source data. We therefore define the query sequences by uniformly sub-sampling 256 sequences of 10 frames each from the winter-video.
As the database, we choose all the images of the summer-video, which is the season with the largest domain shift to the query season.
We filter out degenerate cases with little camera movement by skipping frames if they were not collected at least 10 meters from the previously sampled frame. Like for the MSLS dataset, we define meters as the threshold for correct localization.
4Seasons As a third dataset, we evaluate on the 4Seasons [43,44] dataset, which consists of gray-scale videos recorded using a sensor suite on a car following a number of different routes throughout different seasons. Most of these routes lead through urban environments with a large number of visual features, which causes non-sequential VPR algorithms to saturate them. We therefore use the “countryside” loop, which is the most challenging route that also supplies ground-truth camera poses for each frame for evaluation. Like Nordland, this dataset is used for evaluation only, again using weights trained on MSLS.
Evaluation Protocol. We follow a similar protocol as for the Nordland dataset, extracting 252 query sequences from the “winter” recording, which we localize against the “summer” recording that serves as the database. As before, we ensure that subsequent query frames are separated by at least 25.0 meters and that database images are separated by at least 10.0 meters, and use meters as the threshold for correct localization. The comparatively small loop leaves a total of 672 reference images.
Other Datasets Few other datasets meet the requirement of sequential queries covering sufficiently large areas. Standard VPR benchmarks such as Pittsburgh-30k [3, 13], Tokyo 24/7 [39], and St. Lucia [42] do not preserve the sequential structure of their source data in the standard evaluation splits, making them unsuitable for our task without non-trivial re-processing. The Oxford Robot-Car dataset [30] contains sequential information but covers a small, feature-rich loop where im2im methods are near-saturated. Other domains such as off-road or aerial data are promising future directions where sequential priors may be especially valuable. We hope that clearly defining our task (Section 3.1) and framework (Section 3) will encourage future dataset collection and benchmark design in these domains.
4.2 Architecture and Training
We train on MSLS, holding out the Amsterdam and Boston images for evaluation and resize all images to squares with side-length 224 pixels.
As our pre-trained VPR model we use MegaLoc [6], which computes 8448-dimensional global descriptors. The emission network is a small MLP operating on the element-wise product of global descriptors (Eq. (5)). The transition network computes pairwise correlations between DINOv2 [33] local features (ViT-14-Base, 768-dim) and processes them with a ResNet-style CNN to obtain transition descriptors (Eq. (7)). We set the distance cutoff meters.
We keep MegaLoc frozen and only train and , first individually and then end-to-end using AdamW [26] with RandAugment [9] data augmentation (excluding geometric transforms, as they interfere with the learning of geometric transitions between images).
For pre-training, we use retrievals per query, with learning rate and batch sizes of (emission) and (transition). For end-to-end training, we use batches of 6 sequences of length 10 with retrievals and learning rate .
All training is done on a single NVIDIA A100 GPU with 48GB memory. Full architecture details are provided in Sec. C.
Computational and Memory Cost. TRAIL adds little overhead on top of the underlying VPR backbone. The DINOv2 local features used by are produced by MegaLoc en route to its global descriptor, so requires no additional backbone pass, only the small CNN and MLP heads. Taking TRAIL (MegaLoc) as the unit of inference wall-clock per query, raw MegaLoc and the hand-crafted heuristics cost and FoL , while the SelaVPR and PairVPR re-rankers cost and respectively. TRAIL is therefore substantially lighter than the re-rankers it matches or exceeds in accuracy (Sec. 4.4). On the memory side, the cached local features for a single image occupy roughly the storage of the raw reference image (5.3, 14.8, 14.6, and 0.5 GB for MSLS-Amsterdam, MSLS-Boston, Nordland, and 4Seasons, respectively). Since only the feature sets for the candidate retrievals of two consecutive frames are needed at once, these can be streamed from disk for arbitrarily large maps.
4.3 Baselines
We evaluate the performance of our approach against a number of baseline algorithms. We use the authors' code and pre-trained weights.
Global Descriptor Algorithms. MegaLoc [6] and FoL [40] are two recent, state-of-the-art Visual Place Recognition algorithms that compute global image descriptors and use these to retrieve matches from a database. We apply them to our setting by ignoring the sequential information and simply localizing the final image in the sequence. Note that while MegaLoc uses a ViT-B-based feature
TRAIL 13
backbone, the authors of FoL only release weights for a ViT-L-based backbone. FoL therefore benefits from significantly larger model capacity, which should be kept in mind when interpreting its results.
Sequence-Retrieval Algorithms. We also compare to methods trained to use sequences for Visual Place Recognition: SeqNet [11], JIST [7], and CaseVPR [25]. These methods assume that the database contains sequences of images, whereas our database consists of unordered collections of images. We apply them by using the full query sequence descriptors to retrieve unordered database images, treating each as a single-image sequence. We adapt CaseVPR's two stages as follows: we first retrieve the top- database images using the full query sequence descriptor, then choose among them the image with the highest similarity to the final query image's descriptor. Further details are given in Sec. E.3.
Re-Ranking Algorithms. The third type of Visual Place Recognition Algorithm we evaluate are two recent re-ranking algorithms, SelaVPR [27] and PairVPR [16]. These im2im methods first retrieve candidate database images using global image descriptors, before then re-ranking these images using more expensive methods. Like for the Global-Descriptor-based algorithms, we apply these algorithms to our setting by ignoring sequential information and only localizing the final image in the query sequence.
Hand-crafted Algorithms. Finally, we compare to three hand-crafted methods that use the MegaLoc algorithm for computing image descriptors for retrieval.
The first, Maximum Similarity, is briefly discussed in Warburg et al. [41] as the +MIN approach for their seq2im task. Given a window size , this algorithm computes the top-1 retrieved image for the final query images and returns the reference image that was retrieved with the highest similarity.
The second, Majority Voting, also appears in Warburg et al., under the name +MODE. Given a window size , this algorithm uses the top- images retrieved for each of the final query images and returns the reference image that was retrieved most often among these images.
Finally, Location Filtering returns the database image that is most similar to the final image in the query sequence after filtering out any database image that was not collected within a distance threshold meters of at least one of the top- retrievals for the previous images. This corresponds roughly to the maximum distance between two correctly retrieved images when their respective query images are separated by approximately 25 meters. Formal definitions for these hand-crafted heuristics can be found in Sec. E.1.
4.4 Results
Our main results are given in Tab. 1. We report the Recall@T metric for timesteps on the Amsterdam and Boston subsets of the Mapillary-SLS
| Algorithm | MSLS | Nordland | 4Seasons | ||||||
|---|---|---|---|---|---|---|---|---|---|
| R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | |
| Global Descriptor | |||||||||
| MegaLoc [6] | 55.1 | 58.0 | 58.3 | 73.8 | 73.8 | 68.8 | 69.4 | 69.1 | 68.6 |
| FoL (ViT-L) [40] | 63.8 | 62.3 | 66.7 | 53.5 | 53.9 | 55.5 | 74.6 | 74.6 | 74.2 |
| Sequence-Retrieval | |||||||||
| SeqNet [11] | 17.4 | 5.8 | 8.3 | 3.9 | 2.7 | 2.3 | 23.8 | 18.3 | 17.7 |
| JIST [7] | 17.4 | 11.6 | 16.7 | 10.9 | 1.6 | 0.4 | 34.5 | 15.1 | 6.5 |
| CaseVPR [25] | 33.3 | 27.5 | 25.0 | 18.4 | 7.0 | 7.8 | 58.7 | 21.8 | 22.2 |
| Re-Ranking | |||||||||
| SelaVPR [27] | 71.0 | 65.2 | 66.7 | 64.8 | 64.1 | 60.9 | 77.0 | 76.6 | 76.2 |
| PairVPR [16] | 59.4 | 52.2 | 50.0 | 69.5 | 69.5 | 66.0 | 92.1 | 91.7 | 91.5 |
| Hand-Crafted | |||||||||
| Max. Similarity | 55.1 | 39.1 | 66.7 | 73.8 | 43.0 | 39.1 | 69.4 | 66.3 | 65.7 |
| Majority Voting | 55.1 | 37.7 | 50.0 | 73.8 | 19.5 | 15.2 | 69.4 | 46.0 | 46.0 |
| Loc. Filtering | 55.1 | 60.9 | 58.3 | 73.8 | 79.7 | 76.2 | 69.4 | 69.4 | 66.9 |
| Ours | |||||||||
| TRAIL (MegaLoc) | 56.5 | 65.2 | 66.7 | 75.3 | 81.3 | 78.1 | 71.0 | 78.2 | 79.0 |
Table 1: Recall@T for T = 1, 5, 10 on the Amsterdam and Boston subsets of Mapillary SLS [41], on Nordland [37], and on the 4Seasons [43, 44] countryside loop (Nordland and 4Seasons: winter queries localized against a summer database). T=1 corresponds to standard single-image VPR. Best results in bold, second-best underlined; FoL uses a larger ViT-L backbone than MegaLoc (ViT-B).
dataset, using all sequences that contain at least five images with successive query images separated by at least 25 meters, on the Nordland dataset, localizing query-sequences drawn from the winter recording against the images drawn from the summer recording, and on the 4Seasons countryside loop under the analogous winter-to-summer protocol.
Whereas the improvements over vanilla MegaLoc are negligible for the first image in a sequence (when no sequential information is available), they are substantial for later frames. On MSLS at T=10, SelaVPR reaches 66.7%, tying with our method. However, SelaVPR applies per-frame re-ranking using cross-attention over local features, which is considerably more expensive than our small MLPs operating on K=10 pre-retrieved candidates. FoL, despite using a larger ViT-L backbone, does not outperform our ViT-B-based method at T≥5 on MSLS and falls clearly behind on Nordland.
Sequence-retrieval methods that assume a database consisting of sequences perform very poorly in our setting. The core issue is that these methods treat all query images equally rather than focusing on localizing the final image: their sequence descriptors average across all frames, so when database “sequences” consist of a single image the descriptor distributions are mismatched. TRAIL avoids this by explicitly modeling transitions and returning the location estimate for the final timestep. A more detailed analysis is given in Sec. E.3.
For T=1, the handcrafted heuristics reduce to pure MegaLoc. Among them, only Location Filtering consistently improves over vanilla retrieval. This heuristic performs well on Nordland’s predictable train trajectory but is less effective on
TRAIL 15
the more varied driving data in MSLS, where learned transition modeling is more robust.
On 4Seasons, the same patterns hold: our method again improves substantially over the raw MegaLoc backbone as well as over the hand-crafted heuristics and SelaVPR, remaining effective despite the compounded domain shift from snowy winter queries to a summer database and from colour training data to grayscale test images, and despite never being trained on grayscale imagery. The notable exception is PairVPR, which performs exceptionally well on this dataset. We attribute this to the comparatively small reference set of the countryside loop, which leaves far fewer distractor images, combined with PairVPR being more robust to the season and colour domain shift than SelaVPR.
In Sec. E.2 we report the performance of these baselines using different values for their hyper-parameters.
For an ablation analysis investigating the impact of some of the individual design choices for our method, refer to Sec. D in the supplement.
5 Conclusion
In this work, we presented TRAIL, a novel framework for Sequential Visual Place Recognition that exploits temporal context across a sequence of query images. Specifically, TRAIL uses localization estimates from earlier images in the sequence to improve place recognition for the current query image within a large reference database. This approach was empirically shown to improve the Recall@T metric by up to 8.3 percentage points on MSLS, 9.3 on Nordland, and 10.4 on 4Seasons, with minimal computational overhead.
Several directions for future work remain: (i) extending to domains beyond street-level driving, such as aerial or off-road imagery; (ii) exploring richer architectures for and , including fine-tuning the backbone itself; (iii) directly modeling the evolving distribution of the query image's position rather than classifying the closest reference image, which could yield smaller localization errors; and (iv) further reducing the framework's compute and memory footprint, for instance through a learned down-projection of the redundant DINOv2 local features, or by exploiting odometry data to drive lighter-weight transition potentials.
Acknowledgements
Dominik A. Kloepfer gratefully acknowledges support from the EPSRC (VisualAI, EP/T028572/1).
References
-
Ali-Bey, A., Chaib-Draa, B., Giguere, P.: Mixvpr: Feature mixing for visual place recognition. In: Proceedings of the IEEE/CVF winter conference on applications of computer vision. pp. 2998–3007 (2023)
-
Ali-Bey, A., Chaib-draa, B., Giguère, P.: Boq: A place is worth a bag of learnable queries. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. pp. 17794–17803 (2024)
-
Arandjelovic, R., Gronat, P., Torii, A., Pajdla, T., Sivic, J.: Netvlad: Cnn architecture for weakly supervised place recognition. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 5297–5307 (2016)
-
Arandjelovic, R., Zisserman, A.: All about vlad. In: Proceedings of the IEEE conference on Computer Vision and Pattern Recognition. pp. 1578–1585 (2013)
-
Bai, D., Wang, C., Zhang, B., Yi, X., Yang, X.: Sequence searching with cnn features for robust and fast visual place recognition. Computers & Graphics 70, 270–280 (2018)
-
Berton, G., Masone, C.: Megaloc: One retrieval to place them all. In: Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR) Workshops. pp. 2861–2867 (June 2025)
-
Berton, G., Trivigno, G., Caputo, B., Masone, C.: Jist: Joint image and sequence training for sequential visual place recognition. IEEE Robotics and Automation Letters 9(2), 1310–1317 (2023)
-
Cadena, C., Gálvez-López, D., Tardós, J.D., Neira, J.: Robust place recognition with stereo sequences. IEEE Transactions on Robotics 28(4), 871–885 (2012)
-
Cubuk, E.D., Zoph, B., Shlens, J., Le, Q.V.: Randaugment: Practical automated data augmentation with a reduced search space. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition workshops. pp. 702–703 (2020)
-
Cummins, M., Newman, P.: Fab-map: Probabilistic localization and mapping in the space of appearance. The International journal of robotics research 27(6), 647–665 (2008)
-
Garg, S., Milford, M.: Seqnet: Learning descriptors for sequence-based hierarchical place recognition. IEEE Robotics and Automation Letters 6(3), 4305–4312 (2021)
-
Garg, S., Vankadari, M., Milford, M.: SeqMatchNet: Contrastive learning with sequence matching for place recognition & relocalization. In: Proceedings of the 5th Conference on Robot Learning. pp. 429–443 (2022)
-
Gronat, P., Obozinski, G., Sivic, J., Pajdla, T.: Learning and calibrating per-location classifiers for visual place recognition. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 907–914 (2013)
-
Gui, L., Zeng, C., Luo, J., Yang, X.: Place recognition through multiple lidar scans based on the hidden markov model. Sensors 24(11) (2024). https://doi.org/10.3390/s24113611, https://www.mdpi.com/1424-8220/24/11/3611
-
Hammersley, J.M., Clifford, P.: Markov fields on finite graphs and lattices (1971), unpublished manuscript
-
Hausler, S., Moghadam, P.: Pair-vpr: Place-aware pre-training and contrastive pair classification for visual place recognition with vision transformers. IEEE Robotics and Automation Letters 10(4), 4013–4020 (2025). https://doi.org/10.1109/LRA.2025.3546512
-
He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 770–778 (2016)
-
Householder, A.S.: A theory of steady-state activity in nerve-fiber networks: I. definitions and preliminary lemmas. The bulletin of mathematical biophysics 3(2), 63–69 (1941)
-
Ioffe, S., Szegedy, C.: Batch normalization: Accelerating deep network training by reducing internal covariate shift. In: International conference on machine learning. pp. 448–456. pmlr (2015)
-
Izquierdo, S., Civera, J.: Close, but not there: Boosting geographic distance sensitivity in visual place recognition. In: European Conference on Computer Vision. pp. 240–257. Springer (2024)
-
Izquierdo, S., Civera, J.: Optimal transport aggregation for visual place recognition. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. pp. 17658–17668 (2024)
-
Jégou, H., Douze, M., Schmid, C., Pérez, P.: Aggregating local descriptors into a compact image representation. In: 2010 IEEE computer society conference on computer vision and pattern recognition. pp. 3304–3311. IEEE (2010)
-
Keetha, N., Mishra, A., Karhade, J., Jatavallabhula, K.M., Scherer, S., Krishna, M., Garg, S.: Anyloc: Towards universal visual place recognition. IEEE Robotics and Automation Letters 9(2), 1286–1293 (2023)
-
Lafferty, J., McCallum, A., Pereira, F.C.: Conditional random fields: Probabilistic models for segmenting and labeling sequence data. Proc. 18th International Conf. on Machine Learning (2001)
-
Li, H., Peng, G., Zhang, J., Wen, M., Ma, Y., Wang, D.: Casevpr: Correlation-aware sequential embedding for sequence-to-frame visual place recognition. IEEE Robotics and Automation Letters (2025)
-
Loshchilov, I., Hutter, F.: Decoupled weight decay regularization. In: International Conference on Learning Representations (2019), https://openreview.net/forum?id=Bkg6RiCqY7
-
Lu, F., Zhang, L., Lan, X., Dong, S., Wang, Y., Yuan, C.: Towards seamless adaptation of pre-trained models for visual place recognition. In: The Twelfth International Conference on Learning Representations (2024)
-
Lynen, S., Bosse, M., Furgale, P., Siegwart, R.: Placeless place-recognition. In: 2014 2nd International Conference on 3D Vision. vol. 1, pp. 303–310 (2014)
-
Maas, A.L., Hannun, A.Y., Ng, A.Y., et al.: Rectifier nonlinearities improve neural network acoustic models. In: Proc. icml. p. 3. Atlanta, GA (2013)
-
Maddern, W., Pascoe, G., Linegar, C., Newman, P.: 1 Year, 1000km: The Oxford RobotCar Dataset. The International Journal of Robotics Research (IJRR) 36(1), 3–15 (2017). https://doi.org/10.1177/0278364916679498, http://dx.doi.org/10.1177/0278364916679498
-
Mereu, R., Trivigno, G., Berton, G., Masone, C., Caputo, B.: Learning sequential descriptors for sequence-based visual place recognition. IEEE Robotics and Automation Letters 7(4), 10383–10390 (2022)
-
Milford, M.J., Wyeth, G.F.: Seqslam: Visual route-based navigation for sunny summer days and stormy winter nights. In: 2012 IEEE international conference on robotics and automation. pp. 1643–1649. IEEE (2012)
-
Oquab, M., Darcet, T., Moutakanni, T., Vo, H., Szafraniec, M., Khalidov, V., Fernandez, P., Haziza, D., Massa, F., El-Nouby, A., et al.: Dinov2: Learning robust visual features without supervision. arXiv preprint arXiv:2304.07193 (2023)
-
Radenović, F., Tolias, G., Chum, O.: Fine-tuning cnn image retrieval with no human annotation. IEEE transactions on pattern analysis and machine intelligence 41(7), 1655–1668 (2018)
-
Rudić, B., Pichler-Scheder, M., Schmidt, R., Helmel, C., Efrosinin, D., Kastl, C., Auer, W.: A geometry-aware hidden markov model for indoor positioning. In: 2020 IEEE/ASME International Conference on Advanced Intelligent Mechatronics (AIM). pp. 547–552. IEEE (2020)
-
Siam, S.M., Zhang, H.: Fast-seqslam: A fast appearance based place recognition algorithm. In: 2017 IEEE International Conference on Robotics and Automation (ICRA). pp. 5702–5708. IEEE (2017)
-
Sünderhauf, N., Neubert, P., Protzel, P.: Are we there yet? challenging seqslam on a 3000 km journey across all four seasons. In: Proc. of workshop on long-term autonomy, IEEE international conference on robotics and automation (ICRA). p. 2013. Citeseer (2013)
-
Sünderhauf, N., Protzel, P.: Brief-gist-closing the loop by simple means. In: 2011 IEEE/RSJ International Conference on Intelligent Robots and Systems. pp. 1234–1241. IEEE (2011)
-
Torii, A., Arandjelovic, R., Sivic, J., Okutomi, M., Pajdla, T.: 24/7 place recognition by view synthesis. In: Proceedings of the IEEE conference on computer vision and pattern recognition. pp. 1808–1817 (2015)
-
Wang, C., Chen, S., Song, Y., Xu, R., Zhang, Z., Zhang, J., Yang, H., Zhang, Y., Fu, K., Du, S., et al.: Focus on local: Finding reliable discriminative regions for visual place recognition. In: Proceedings of the AAAI Conference on Artificial Intelligence. pp. 7536–7544 (2025)
-
Warburg, F., Hauberg, S., López-Antequera, M., Gargallo, P., Kuang, Y., Civera, J.: Mapillary street-level sequences: A dataset for lifelong place recognition. In: Computer Vision and Pattern Recognition (CVPR) (June 2020)
-
Warren, M., McKinnon, D., He, H., Upcroft, B.: Unaided stereo vision based pose estimation. In: Proceedings of the 2010 Australasian Conference on Robotics and Automation. pp. 1–8. Australian Robotics & Automation Association (2010)
-
Wenzel, P., Wang, R., Yang, N., Cheng, Q., Khan, Q., von Stumberg, L., Zeller, N., Cremers, D.: 4Seasons: A cross-season dataset for multi-weather SLAM in autonomous driving. In: German Conference on Pattern Recognition (GCPR) (2020)
-
Wenzel, P., Yang, N., Wang, R., Zeller, N., Cremers, D.: 4Seasons: Benchmarking visual SLAM and long-term localization for autonomous driving in challenging conditions. International Journal of Computer Vision (IJCV) (2024)
-
Xu, M., Fischer, T., Sünderhauf, N., Milford, M.: Probabilistic appearance-invariant topometric localization with new place awareness. IEEE Robotics and Automation Letters 6(4), 6985–6992 (2021)
-
Yu, J., Yang, J., Hu, A., Wang, J., Tan, P., Zhang, H.: ROVER: Robust loop closure verification with trajectory prior in repetitive environments. IEEE Transactions on Automation Science and Engineering 23, 8476–8489 (2026)
-
Zhao, J., Zhang, F., Cai, Y., Tian, G., Mu, W., Ye, C., Feng, T.: Learning sequence descriptor based on spatio-temporal attention for visual place recognition. IEEE Robotics and Automation Letters 9(3), 2351–2358 (2024)
TRAIL: Trajectory-Aware Visual Place Recognition against Unordered Databases
Supplementary Material
A Derivation of Recurrence Relation

Fig. 3: Diagram of the undirected graph showing the conditional independence relations satisfied by the random variables . After conditioning on the sequence of query images , each is independent of all s.t. , hence the set of random variables forms a Markov random field with respect to the graph.
We are given a sequence of query images with where each query image has an associated (but unknown) location and a set of reference images with associated locations, where and .
Our goal is to model for all . Here we define , so is the random variable that indicates which reference image was taken from the closest location to query image .
We first make the locality assumption that after conditioning on the observations , the random variables form a Markov Random Field over the linear chain graph shown in Fig. 3. That means that each is conditionally independent of all other variables except for its neighbours and , so .
By the Hammersley-Clifford Theorem [15], we can write the conditional probability for each entire sequence of closest states as a product over probability potentials (functions with a range ) of cliques of the graph.
The cliques in the graph here (Fig. 3) are pairs of adjacent nodes and single vertices, so
where .
Intuitively, should be large when makes a particular value of likely, and should be large when the transition from to is plausible given .
This motivates the following further locality assumptions:
because those are the most influential query images for computing and , respectively.
We then get
where we defined as the unnormalised score for the state sequence C.
Let us now define as the unnormalised probability score of all state sequences that have length and end in state . Then, trivially,
and for other t we have
(20)
which is the recurrence relation used in the main paper (Eq. (2)).
To calculate , we have to normalise the , so with the partition function we have
as in the main paper.
B Derivation of Log-Space Equations
For numerical stability, we implement the relevant equations in log-space. In this section, we derive the relevant log-space equations for the recurrence relation (Eq. (2)), the probability aggregation (Eq. (3)), and the loss calculation (Eq. (9)), as well as the log-space form of the scaled sigmoid function (Eq. (4)).
B.1 Computing in Log-Space
We start by taking the logarithm of both sides of the recurrence relation Eq. (2).
(23)
Defining and , we get
Here logsumexp can use the log-sum-exp trick to improve numerical stability.
With this log-space recurrence relation, we then have
or
B.2 Computing in Log-Space
To compute the binary cross-entropy loss on the aggregated probabilities (see Eq. (9)), we need to compute both and .
Using from Eq. (3), we find:
To compute , we can use the fact that and write
Taking the logarithm of both sides then yields:
B.3 Computing in Log-Space
To compute the overall loss, in log-space, the remaining piece is computing and .
In Eq. (4), we defined
where is the sigmoid function and 1 is the indicator function, while and are parameters.
We therefore have for , and for
(35)
(36)
where , which has a numerically stable implementation for small x.
For , , but since this term is exponentiated inside the logsumexp in Eq. (33), we can handle it by simply masking out those terms.
Defining and for notational simplicity, for , we get
(41) where we used . Now
Therefore,
Taking the logarithm on both sides and substituting back in for A and B finally yields
C Architecture and Training Details
Emission Network. The MLP used in (Eq. (5)) has input dimension 8448 and a single hidden layer with dimension 64, using LeakyReLU [29] activations and dropout 0.1.
Transition Network. The CNN computing transition descriptors (Eq. (7)) is a ResNet [17]-inspired network with three residual blocks. Each block contains two convolutional layers with ReLU [18] activations and Batch-Normalization [19], using hidden dimension 256, kernel size 3, and stride 1. Mean-pooling and a linear projection produce 512-dimensional descriptors. The MLP in has two hidden layers of dimension 512 and 256, with LeakyReLU activations and dropout 0.1. As local features we use the DINOv2 [33] feature maps from MegaLoc (ViT-14-Base, patch size , feature dimension 768).
Training. We train on MSLS, holding out Amsterdam and Boston for evaluation. Images are resized to pixels with ImageNet normalisation, yielding local features of dimension . We apply RandAugment [9] with magnitude 9, excluding translation, shear, and rotation augmentations as they interfere with learning geometric transitions.
For pre-training : batches of query images with retrievals, AdamW [26] with learning rate and weight-decay . For pre-training : batches of query pairs with retrievals, AdamW with learning rate and weight-decay . For end-to-end training: batches of 6 sequences of length 10 with retrievals, AdamW with learning rate and weight-decay .
D Ablations
| Ablation | MSLS | Nordland | ||||
|---|---|---|---|---|---|---|
| No Pre-Training | 58.0 | 66.7 | 66.7 | 75.3 | 79.3 | 78.5 |
| Eq. (50) | 57.4 | 66.7 | 66.7 | 75.1 | 81.6 | 78.5 |
| uses | 56.5 | 65.2 | 66.7 | 75.3 | 83.2 | 80.5 |
| 56.5 | 60.9 | 62.7 | 75.3 | 76.2 | 73.4 | |
| TRAIL (FoL) | 60.9 | 59.4 | 75.0 | 55.1 | 61.3 | 53.1 |
| TRAIL (MegaLoc) | 56.5 | 65.2 | 66.7 | 75.3 | 81.3 | 78.1 |
Table 2: Performance of Ablation Experiments on the MSLS and Nordland datasets. For detailed description of the experiments and a discussion of the results, please refer to Sec. D.
To investigate the impact of some of our modeling choices on the system's performance, we perform a number of ablation experiments. Keeping all other training settings constant, we report the performance for a number of settings in Tab. 2.
No Pre-Training We experiment with training our model exclusively end-to-end, skipping the pre-training phase. While at early epochs this model's performance lags behind that of the pre-trained model, it quickly catches up and by the time the pre-trained model converges, achieves broadly similar performance.
Alternative Function. The choice of a scaled sigmoid as the functional form for the function (Eq. (4)) is not unique. We also experiment with a similar function, a generalised Gaussian of the form
where corresponds to the cut-off in the scaled-sigmoid and is set to 20.0 meters and the shape parameter is learnable and initialised to 4.0.
This setting, too, achieves broadly similar performance to the model in the main paper. This is not surprising, as the functional shape of both equations is quite similar.
uses Global Descriptors. In the main paper, we use an architecture for the transition probability potentials that uses local features to compute descriptors of the transition between a pair of images (Eq. (7)). In this ablation, we instead use the global image descriptors extracted by the pre-trained VPR algorithm to compute :
The Multi-layer Perceptron we use here has two hidden layers with 512 dimensions each, and uses leaky-ReLU activations and a dropout of 0.1 during training.
The performance is slightly stronger than that of the full model on the Nordland dataset. MegaLoc [6] uses the SALAD [21] architecture, which aggregates local features into clusters that are then concatenated. Such global descriptors may still retain information about the spatial arrangement of features in the image, which a sufficiently expressive network can exploit. For the Nordland dataset especially, this information can be enough to identify the quite consistent camera movement between subsequent frames.
We also note that the number of parameters of this Multi-layer Perceptron (4.8 million) is larger than that for the CNN used in the main paper (3 million).
Setting . We also ablate the effect of explicitly integrating the information derived from the transitions between query images compared to the effect of explicitly modeling the probability by aggregating the probabilities using Eq. (3).
We do so by setting in our trained model, which results in the recurrence relation Eq. (2) becoming . The proportionality constant cancels when computing . The performance of this modification lags significantly behind the full model, though it still outperforms the pure MegaLoc baseline.
Standard VPR-Algorithms return the single reference image with the highest similarity with the query image, so do not take into account the similarity scores assigned to other reference images. By explicitly modeling the probability , our approach allows a reference image with a slightly lower similarity score to be chosen ahead of an image with a higher similarity score, if there are other reference images with reasonably high scores at locations close to its location. This helps discard outlier similarity scores, where two unrelated places look similar from only a certain perspective or only in certain lighting conditions.
Different Backbone. Finally, we evaluate our method trained using the FoL [40] backbone (a recent VPR method using a ViT-L-based architecture), with the architecture and training recipe otherwise unchanged.
It, too, tends to improve on the raw FoL backbone, demonstrating that our framework is backbone-agnostic. The gains are more inconsistent, though, which may stem from FoL's specific training recipe making it less suited to our specific choices for the emission and transition network architectures.
Our framework's principles (Sec. 3.2, Sec. 3.4, Sec. 3.3, and Appendix Sec. A) remain applicable to any VPR backbone, however.
D.1 Sequence Pre-Processing and Transition Cutoff
| Setting | MSLS | Nordland | 4Seasons | ||||||
|---|---|---|---|---|---|---|---|---|---|
| R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | |
| TRAIL (MegaLoc) | 56.5 | 65.2 | 66.7 | 75.3 | 81.3 | 78.1 | 71.0 | 78.2 | 79.0 |
| No stationary-frame filter | 56.5 | 63.8 | 66.7 | 75.3 | 80.1 | 78.9 | 71.0 | 75.0 | 74.6 |
| m | 56.5 | 63.8 | 66.7 | 75.3 | 82.8 | 80.0 | 71.0 | 79.4 | 79.0 |
| m | 56.5 | 63.8 | 66.7 | 75.3 | 79.7 | 77.0 | 71.0 | 77.4 | 77.0 |
Table 3: Effect of removing the stationary-frame filter and of varying the transition cutoff . Performance is broadly stable across all three settings; best results per column in bold (columns in which all settings tie are left unmarked).
We further study two choices in our data pre-processing and modeling pipeline that are independent of the trained networks: the filtering of near-stationary query frames and the value of the transition cutoff . For both, we re-run the same trained TRAIL model without any retraining; the results are reported in Tab. 3.
Stationary and Variable-Speed Frames. To avoid degenerate sequences with little camera movement, we skip query frames that are less than 25.0 meters from the previous frame (Sec. 4.1). We ablate this choice by re-running trained TRAIL on the unfiltered sequences. Each Recall@T metric still refers to the same target query frame as before, but the previously-skipped intermediate frames now also flow through TRAIL. As Tab. 3 shows, performance remains broadly stable. In a deployment setting, such frames can also be removed cheaply using image similarity or coarse odometry, without recourse to ground-truth positions.
Transition Cutoff . The distance cutoff meters, beyond which transition potentials are set to zero, is the geometric ceiling on the separation between two consecutive references: given a query spacing of 25 meters and a localization threshold meters, two correctly localized consecutive references can be at most meters apart. Varying meters yields similar results (Tab. 3), confirming that the framework is insensitive to the precise value of this cutoff.
E Hand-Crafted and Sequential Baseline Details
E.1 Formal Definition
We now give the formal definitions of the three hand-crafted heuristics evaluated in the main paper in Sec. 4. As we saw there, it is not trivial to create heuristics that outperform even the simplest baseline.
For each of these algorithms, we assume the availability of a previously trained Visual Place Recognition algorithm, which, given a single query image, can retrieve the most similar images according to some algorithm-specific similarity metric. In the notation used above, such an algorithm is a function . Usually, such an algorithm computes a descriptor for the query image and all reference images and then retrieves the top-K database entries: , where is an image descriptor, and is a similarity function.
Maximum Similarity. This baseline is briefly discussed in Warburg et al. [41] as an approach for their seq2im task, calling it +MIN. Given a window size , this algorithm computes the top-1 retrieved image for the final query images and returns the reference image that was retrieved with the maximum similarity. Formally, this set of top-1 retrieved images for the final query images is and so with
the highest retrieval similarity for each retrieved image we have
Majority Voting. This baseline is also briefly discussed in [41], under the name +MODE. Again, given a window size , this algorithm computes the top-K images retrieved for each of the final query images and returns the reference image that was retrieved most often among these images. With , we have formally
Location Filtering. This baseline is built on the heuristic that correctly retrieved database images for the different images in the query sequence will have been collected from locations not too far apart from each other. It returns the database image that is most similar to the final query sequence image after filtering out any retrieved image that was not collected within a distance threshold of at least one of the top-K retrievals for the previous query images. Formally,
where we define the set of filtered retrievals as
E.2 Additional Baselines
| Setting | MSLS | Nordland | ||||
|---|---|---|---|---|---|---|
| R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | |
| Pure Retrieval (MegaLoc) | 55.1 | 58.0 | 58.3 | 73.8 | 73.8 | 68.8 |
| Maximum Similarity | ||||||
| W = 2 | 55.1 | 39.1 | 66.7 | 73.8 | 43.0 | 39.1 |
| W = 3 | 55.1 | 39.1 | 66.7 | 73.8 | 31.6 | 25.0 |
| W = 5 | 55.1 | 34.8 | 66.7 | 73.8 | 19.9 | 18.4 |
| W = 10 | 55.1 | 34.8 | 66.7 | 73.8 | 19.9 | 10.6 |
| Majority Voting | ||||||
| W = 3, K = 10 | 55.1 | 37.7 | 50.0 | 73.8 | 19.5 | 15.2 |
| W = 2, K = 10 | 55.1 | 30.4 | 58.3 | 73.8 | 38.3 | 34.8 |
| W = 3, K = 5 | 55.1 | 42.0 | 58.3 | 73.8 | 22.3 | 16.0 |
| W = 2, K = 5 | 55.1 | 37.7 | 58.3 | 73.8 | 39.1 | 36.3 |
| W = 3, K = 20 | 55.1 | 36.2 | 41.7 | 73.8 | 21.5 | 16.0 |
| W = 2, K = 20 | 55.1 | 29.0 | 58.3 | 73.8 | 40.2 | 36.7 |
| Location Filtering | ||||||
| W = 2, K = 10, | 55.1 | 60.9 | 58.3 | 73.8 | 79.7 | 76.2 |
| W = 3, K = 10, | 55.1 | 60.9 | 58.3 | 73.8 | 78.5 | 75.0 |
| W = 3, K = 10, | 55.1 | 60.9 | 58.3 | 73.8 | 78.5 | 74.2 |
| W = 2, K = 10, | 55.1 | 60.9 | 58.3 | 73.8 | 79.3 | 76.2 |
| W = 3, K = 10, | 55.1 | 60.9 | 58.3 | 73.8 | 78.1 | 75.0 |
| W = 2, K = 10, | 55.1 | 56.5 | 58.3 | 73.8 | 37.9 | 35.2 |
| TRAIL (MegaLoc) | 56.5 | 65.2 | 66.7 | 75.3 | 81.3 | 78.1 |
Table 4: Additional Results for Hand-Crafted Baselines with Different Hyperparameters. We see that the performance of the baselines can sometimes be sensitive to the hyperparameter choices made, but does not reach the performance of our method.
We also evaluated the hand-crafted heuristics using a range of different hyperparameters for the window size W, the number of candidate reference images K, and, in the case of the Location Filtering baseline, the distance filtering threshold . The results of these experiments can be found in Tab. 4.
The different hyperparameters fail to improve the overall performance, and the Majority Voting baseline is quite sensitive to the choice of hyperparameter; larger window sizes in particular decrease its performance as there are more spurious votes by earlier query images for reference images that are too far away from the final query image.
For the Maximum Similarity baseline, a higher window size primarily increases the likelihood that the highest-similarity retrieval will be for a previous time-step, and lie outside the distance threshold for correct localizations.
Similarly, the Location Filtering baseline is quite insensitive to the exact hyperparameter choice, because its hard filtering approach generally filters out the most egregious similarity-score outliers, while harder examples are not filtered out for sensible choices of hyperparameters. On the Nordland dataset, though, we see that a filtering threshold of meters is too strict and significantly reduces performance.
These results underscore the need for careful thinking about how to best integrate sequence information into a visual place recognition system.
E.3 Sequence-Retrieval Baselines
| Algorithm | MSLS | Nordland | ||||
|---|---|---|---|---|---|---|
| R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | |
| SeqNet [11] | 17.4 | 5.8 | 8.3 | 3.9 | 2.7 | 2.3 |
| JIST [7] | 17.4 | 11.6 | 16.7 | 10.9 | 1.6 | 0.4 |
| CaseVPR [25] | 33.3 | 27.5 | 25.0 | 18.4 | 7.0 | 7.8 |
| TRAIL (MegaLoc) | 56.5 | 65.2 | 66.7 | 75.3 | 81.3 | 78.1 |
Table 5: Sequence-retrieval baselines evaluated in our setting with an unordered reference database. These methods are designed for databases organised into sequences and perform poorly when this assumption is violated.
We evaluate three methods designed for sequence-to-sequence Visual Place Recognition—SeqNet [11], JIST [7], and CaseVPR [25]—in our setting, where the reference database consists of unordered images rather than sequences (Tab. 5).
These methods assume that the database is organised into sequences and compute fixed-length descriptors that aggregate information across all frames in a sequence. We apply them to our setting by using the full query sequence descriptors to retrieve the unordered database images, treating each database image as a single-frame “sequence.” For CaseVPR, which has two stages, we first retrieve the top- database images using the full query sequence descriptor, then choose among them the image with the highest similarity to the image descriptor of the final query image.
All three methods perform far below standard single-image retrieval. Two factors explain this:
-
Descriptor mismatch. Sequence descriptors are trained to match against other sequence descriptors. When the database contains only single images, the descriptor distributions are mismatched—the query descriptor averages over frames while each database descriptor represents a single frame.
-
No focus on the final image. These methods treat all frames in a sequence equally, producing a descriptor that represents the entire trajectory rather than privileging the final query image. Since earlier query images may be far from the final image's location, the aggregated descriptor is biased away from the target location. TRAIL avoids this by explicitly modeling transitions and returning the location estimate for the final timestep.
These results confirm that sequence-to-sequence methods are not directly applicable to our task setting, motivating TRAIL, which works with unordered databases by design.
F Odometry CRF Baseline
| Algorithm | MSLS | Nordland | 4Seasons | ||||||
|---|---|---|---|---|---|---|---|---|---|
| R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | R@T=1 | R@T=5 | R@T=10 | |
| MegaLoc [6] | 55.1 | 58.0 | 58.3 | 73.8 | 73.8 | 68.8 | 69.4 | 69.1 | 68.6 |
| Odometry CRF [45] | 47.8 | 58.0 | 41.7 | 73.4 | 76.6 | 75.0 | 69.1 | 69.8 | 52.5 |
| TRAIL (MegaLoc) | 56.5 | 65.2 | 66.7 | 75.3 | 81.3 | 78.1 | 71.0 | 78.2 | 79.0 |
Table 6: Comparison against a hand-crafted odometry CRF adapted from Xu et al. [45]. TRAIL outperforms both pure MegaLoc and the odometry CRF across all three datasets.
In addition to the baselines evaluated in the main paper, we compare against a hand-crafted odometry-based CRF adapted from Xu et al. [45], who perform probabilistic appearance-invariant topometric localization. The results are reported in Tab. 6.
Adapting their method to our setting is not straightforward: their motion model is built on an ordered reference map whose adjacent places are joined by relative-pose edges, which we do not have. This in turn means our references carry no orientation, so the directional part of the query odometry cannot be used and only its magnitude survives; the simplifications this forces are derived in Sec. F.1. For odometry, we use real IMU integration on 4Seasons; on MSLS and Nordland, which do not provide inertial measurements, we derive odometry from the ground-truth positions corrupted with calibrated random-walk noise.
As Tab. 6 shows, this adaptation trails pure MegaLoc on MSLS and 4Seasons, with the drop concentrated at large , where the absence of heading information most hurts long-range disambiguation. Strengthening this baseline—for example by fusing visual odometry to recover a heading estimate—is a promising direction for future work.
We further note that our forward recurrence (Eq. (2)) parallels Eq. (10) of Xu et al. [45]. Their transition potentials, however, condition on the query odometry, which violates the standard causality assumption of hidden Markov models and the textbook derivation of the forward algorithm; our derivation in Sec. A closes this gap.
F.1 Adapting the TopometricLoc Motion Model
We now derive the odometry CRF baseline in detail, adopting the notation of Xu et al. [45] where convenient. Their TopometricLoc system is a discrete Bayes filter that maintains a belief over a set of reference places together with a single off-map state , which absorbs probability mass whenever the query leaves the mapped area. At each timestep the belief is updated by a measurement model, scoring the appearance of the query against each reference, and a motion model, a transition matrix that scores how consistent each candidate-to-candidate transition is with the query odometry. The two are combined through the standard hidden-Markov-model forward recursion.
This filter is structurally the same model as TRAIL (Sec. A). Its measurement model is an emission potential, playing the role of our ; its motion model is a transition potential, playing the role of our ; its off-map state is our dustbin state; and its forward recursion is exactly ours. The substance of the adaptation lies in re-deriving these two potentials for an unordered reference set, which we do below.
Crucially, the TopometricLoc map is an ordered traverse: each reference node carries an appearance descriptor, and adjacent nodes are joined by edges that store a relative-pose estimate obtained from mapping-time odometry. As we restrict the candidate set at each timestep to the top- retrievals of the underlying VPR model, the transition matrix is of size .
Emission Potential. The measurement model is the baseline's emission potential and transfers to our setting unchanged, as it requires only descriptors and is indifferent to whether the references are ordered. Following Xu et al., the emission factor for candidate , the analogue of our , is an exponential appearance kernel
where is the global descriptor of the underlying VPR model and the sharpness is calibrated once, at , from the spread (a pair of quantiles) of the distances between the first query descriptor and all map descriptors. The off-map state is assigned the emission of the -th best match for some , yielding a likelihood that is consistently high but never optimal; the filter therefore only commits to a within-map location when the appearance matches are genuinely strong.
Transition Potential. The motion model is the baseline's transition potential, the analogue of our . In the notation of Xu et al., the relative pose of the query at time , given the hypothesis that it was at reference at time , is modelled as a Gaussian parameterised by the 3-DoF query odometry. The transition score is the likelihood of this Gaussian evaluated on the mapped trajectory segment around node , a short curve interpolated between the relative poses of 's neighbouring nodes, which reduces to a minimum squared Mahalanobis distance between the predicted pose and .
This construction relies on two ingredients the unordered setting denies us. First, the edges and per-edge relative poses needed to interpolate do not exist when the references are an unordered set of points. Second, and more subtly, each reference carries a position but no orientation: there is no local frame at node against which the direction of a query displacement could be measured. In Xu et al. this frame is provided by the heading of the mapping traverse at each node, with which a directional query odometry is implicitly assumed to be aligned. We therefore make three generalisations.
(G1) A neighbourhood ball replaces the trajectory segment. With unordered references there is no notion of a predecessor or successor of node , and hence no segment to interpolate. We replace it with a 2D ball of radius around the candidate's position,
and set , the same neighbourhood radius that defines a correct localization in our evaluation. Lacking a local trajectory, the most we can assert is that a correct candidate lies somewhere within a metric neighbourhood of .
(G2) Isotropic odometry covariance. We take with a constant scalar , so the Mahalanobis distance collapses to a scaled Euclidean distance.
(G3) Comparison of displacement magnitudes only. Our odometry yields a 2D displacement between consecutive frames, but its direction cannot be used. There is no per-reference heading to compare it against (above), and the absolute orientation of the query trajectory in the map frame is unobservable to a system localizing against an unordered database; supplying it would, for our simulated odometry, amount to feeding in ground-truth heading. We therefore retain only the rotation-invariant displacement magnitude between the odometry-derived query positions . Writing the map separation between candidates as , the predicted query position given hypothesis then lies somewhere on the circle of radius centred on . The minimum distance from this circle to the ball is (treating the radial offset as one-dimensional), which yields the squared cost
This discards all directional information, precisely the cue that most helps disambiguate distant places that happen to lie a similar travel distance away, and is reflected in the baseline's degradation at large (Tab. 6).
With in hand, the transition matrix is assembled exactly as in Xu et al. The within-map block is a softmax over the negative half-costs, rescaled by the complementary off-map mass,
while the within-to-off-map probability grows with the cost of the best available transition through a chi-squared CDF,
capped at a maximum per-step value. We set the degrees of freedom to , matching our planar motion, rather than the used by Xu et al. for 3-DoF motion. Finally, transitions out of the off-map state fall back to the emission factors, .
Inference. Localization then proceeds by the same forward recursion and decoding as our own model. In log-space,
initialised with the emission factors . This is exactly our forward recurrence (Eq. (2)), with the emission factor in place of and the transition factor in place of . As before, we normalise with a softmax, aggregate the resulting state distribution over candidate locations with the same neighbourhood aggregation used throughout our framework (Eq. (3)), and return the highest-scoring candidate. The baseline thus differs from TRAIL only in its potentials—hand-crafted, odometry-driven factors in place of the learned and . The one conceptual gap is that conditioning the transition potential on the query odometry makes the recurrence depart from the textbook forward algorithm; our learned model avoids this by deriving appearance-only potentials from first principles in Sec. A.
G Qualitative Analysis
In this section, we give some qualitative examples of query sequences in the Mapillary dataset for which our TRAIL method outperforms basic Visual Place Recognition algorithms represented by the Pure MegaLoc baseline.
As the reader can observe in Fig. 4, the query images where our method outperforms the baseline are primarily those in feature-poor rural regions and highways. Such regions make single-image visual place recognition very challenging.
By taking previous query images into account and propagating its belief about the current query image's location, our method can continue to localize these images successfully.

(a) Pure Retrieval (MegaLoc) Baseline

(b) Our TRAIL (MegaLoc)
Fig. 4: Selected Validation Sequences where TRAIL outperforms Pure Retrieval. Feature-sparse rural and high-way regions as opposed to feature-rich urban regions are overrepresented compared to the full validation set. Green borders indicate correct, red borders incorrect localization. The performance of the Pure Retrieval baseline is shown to the left in Fig. 4a, the performance of our TRAIL method to the right in Fig. 4b.