Skip to content

Commit

Permalink
Prefer pictures that are only missing one label for labelizer. This i…
Browse files Browse the repository at this point in the history
…s done because pictures are now ordered to show the newest first. To avoid a situation where we have a lot of picturs with just one label the labelizer should prefer pictures with one missing label to pictures with both labels missing.
  • Loading branch information
Joona Pääkkönen committed Jun 15, 2017
1 parent 1ffa3e0 commit 6eaf93c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions recognition/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ def labelize_picture_left_sides(request):
formset.save()
return redirect('left_labelizer')
else:
pics = Picture.objects.filter(left_label__isnull=True).order_by('-created_at')[0:50]
# Prefere pictures with right label but without left label
pics = Picture.objects.filter(left_label__isnull=True, right_label__isnull=False)
if not pics.exists():
# But no pictures are missing just the left label then fetch all unlabeled ones
pics = Picture.objects.filter(left_label__isnull=True)

pics = pics.order_by('-created_at')[0:50]
formset = form_set(queryset=pics)
return render(request, 'labelizer.html', {
'labelizer_side': 'left',
Expand All @@ -39,7 +45,13 @@ def labelize_picture_right_sides(request):
formset.save()
return redirect('right_labelizer')
else:
pics = Picture.objects.filter(right_label__isnull=True).order_by('-created_at')[0:50]
# Prefere pictures with right label but without left label
pics = Picture.objects.filter(right_label__isnull=True, left_label__isnull=False)
if not pics.exists():
# But no pictures are missing just the left label then fetch all unlabeled ones
pics = Picture.objects.filter(right_label__isnull=True)

pics = pics.order_by('-created_at')[0:50]
formset = form_set(queryset=pics)
return render(request, 'labelizer.html', {
'labelizer_side': 'right',
Expand Down

0 comments on commit 6eaf93c

Please sign in to comment.