Skip to content

Commit

Permalink
Update face_detection command to use iterator and to exclude too big …
Browse files Browse the repository at this point in the history
…images in selection
  • Loading branch information
MaertHaekkinen committed Oct 24, 2024
1 parent fc25096 commit 4cabb2b
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ class Command(BaseCommand):
help = 'Will run face detection on all photos in our database that haven\'t had it run yet'

def handle(self, *args, **options):
photos = Photo.objects.filter(rephoto_of__isnull=True, back_of__isnull=True,
face_detection_attempted_at__isnull=True).all()
print('Found %s photos to run on' % photos.count())
photo_qs = Photo.objects.filter(rephoto_of__isnull=True, back_of__isnull=True,
face_detection_attempted_at__isnull=True, width__lte=5000,
height__lte=5000)
count = photo_qs.count()
photos = photo_qs.iterator(chunk_size=100)
print('Found %s photos to run on' % count)
for photo in photos:
analyse_single_photo(photo)

0 comments on commit 4cabb2b

Please sign in to comment.