Skip to content

Commit

Permalink
Fix how dataset is accessed (#758)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippmwirth authored Apr 5, 2022
1 parent 947d3fd commit c9fa2c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lightly/embedding/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ def embed(self,
self.model.eval()
embeddings, labels, filenames = None, None, []

dataset = dataloader.dataset
if lightly._is_prefetch_generator_available():
dataloader = BackgroundGenerator(dataloader, max_prefetch=3)

pbar = tqdm(
total=len(dataloader.dataset),
total=len(dataset),
unit='imgs'
)

Expand Down Expand Up @@ -157,7 +158,7 @@ def embed(self,
embeddings = embeddings.cpu().numpy()
labels = labels.cpu().numpy()

sorted_filenames = dataloader.dataset.get_filenames()
sorted_filenames = dataset.get_filenames()
sorted_embeddings = sort_items_by_keys(
filenames, embeddings, sorted_filenames
)
Expand Down

0 comments on commit c9fa2c5

Please sign in to comment.