Skip to content

Commit

Permalink
Loading images from large datasets #152
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbroks committed Mar 27, 2019
1 parent 181caec commit 43f7e21
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/api/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ def get(self, image_id):

categories = CategoryModel.objects(deleted=False).in_bulk(dataset.categories).items()


# Get next and previous image
images = list(ImageModel.objects(dataset_id=dataset.id, deleted=False).order_by('file_name').all())
image_index = images.index(image)
image_previous = None if image_index - 1 < 0 else images[image_index - 1].id
image_next = None if image_index + 1 == len(images) else images[image_index + 1].id
images = ImageModel.objects(dataset_id=dataset.id, deleted=False)
pre = images.filter(file_name__lt=image.file_name).order_by('-file_name').first()
nex = images.filter(file_name__gt=image.file_name).order_by('file_name').first()

preferences = {}
if not Config.LOGIN_DISABLED:
Expand All @@ -149,8 +149,8 @@ def get(self, image_id):
}
}

data['image']['previous'] = image_previous
data['image']['next'] = image_next
data['image']['previous'] = pre.id if pre else None
data['image']['next'] = nex.id if nex else None

for category in categories:
category = query_util.fix_ids(category[1])
Expand Down

0 comments on commit 43f7e21

Please sign in to comment.