vandal-vpr / vg-transformers

Official Repository of "Learning Sequential Descriptors for Sequence-based Visual Place Recognition "
MIT License
39 stars 5 forks source link

Help! #9

Closed wpumain closed 1 year ago

wpumain commented 1 year ago

Your paper is a great work. I have read your source code for a long time, but I often get lost in it, which is very painful. Can you provide a code comment, or a brief explanation of the code execution process? Think you !

ga1i13o commented 1 year ago

thank you for the suggestion. can you give me any pointers on the parts of the code that you find the most obscure ?

wpumain commented 1 year ago

https://github.com/vandal-vpr/vg-transformers/blob/c57fca9085a8dfcfd74e21ddea8f6722940de5dd/tvg/datasets/dataset.py#L327

This function is difficult to understand, please help

wpumain commented 1 year ago
def compute_triplets_partial(self, model):

        self.triplets_global_indexes = []

        # Take 1000 random queries

        sampled_queries_indexes = np.random.choice(self.queries_num, self.cached_queries, replace=False)

        # Sample 1000 random database images for the negatives

        sampled_database_indexes = np.random.choice(self.database_num, self.cached_negatives, replace=False)

        positives_indexes = np.unique([idx for db_idx in self.pIdx[sampled_queries_indexes] for idx in db_idx])

        database_indexes = list(sampled_database_indexes) + list(positives_indexes)

        subset_ds = Subset(self, database_indexes + list(sampled_queries_indexes + self.database_num))

        cache = self.compute_cache(model, subset_ds, cache_shape=(len(self), self.features_dim))

self.queries_num indicates the number of sequences in the q data. At the same time, sampled_queries_indexes is also the number representing the sequence. But positives_indexes indicates the number of a picture. So in the following statement, what does it mean to add the number of the sequence to the number of the single picture?

database_indexes = list(sampled_database_indexes) + list(positives_indexes)

wpumain commented 1 year ago

Think you ,I hava got it.

ga1i13o commented 1 year ago

Sorry for the delay, it has been a busy week. I guess you figured out the issue in the end, anyway where I sum those two lists together I am concatenating them. The first list are randomly sampled db indexes that will be used to search for negatives for the sampled queries; whereas the second list contains the positives for the sampled queries.

The lists are concatenated since we then need to extract features for all of those images in the database in order to compute triplets