OML-Team / open-metric-learning

Metric learning and retrieval pipelines, models and zoo.
https://open-metric-learning.readthedocs.io/en/latest/index.html
Apache License 2.0
890 stars 61 forks source link

RetrievalResults when separated query gallery #583

Closed AlekseySh closed 5 months ago

AlekseySh commented 5 months ago

Here is the current usage of RetrievalResults:

dataset = QueryGalleryDataset(df_test)
embeddings = inference(extractor, dataset)

rr = RetrievalResults.from_embeddings(embeddings, dataset)

The problem may appear in a few following cases:

To address this cases, we may implement something like:

dataset_g = BaseDataset(galleries)
dataset_q = BaseDataset(queries) 

embeddings_g = inference(model_g, dataset_g)
embeddings_q = inference(model_q, dataset_q)

rr = RetrievalResults.from_qg_embeddings(embeddings_q, embeddings_g, dataset_q, dataset_g)

In the example above different nature of queries and galleries is acceptable. We can also easily organize loop over queries without need of recalculating gallery embeddings.