From cbe36aafacd28a46a2d692e955f8059feae3f1f0 Mon Sep 17 00:00:00 2001
From: Amir MOHAMMADI <amir.mohammadi@idiap.ch>
Date: Tue, 10 Apr 2018 17:41:10 +0200
Subject: [PATCH] Annotations might not be ordered

---
 bob/pad/face/utils/load_utils.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/bob/pad/face/utils/load_utils.py b/bob/pad/face/utils/load_utils.py
index 69725e07..907a8eb6 100644
--- a/bob/pad/face/utils/load_utils.py
+++ b/bob/pad/face/utils/load_utils.py
@@ -4,6 +4,7 @@ from bob.io.video import reader
 from bob.ip.base import scale, block, block_output_shape
 from bob.ip.color import rgb_to_yuv, rgb_to_hsv
 from bob.ip.facedetect import bounding_box_from_annotation
+from collections import OrderedDict
 from functools import partial
 import numpy
 import six
@@ -108,14 +109,12 @@ def yield_faces(database, padfile, cropper, normalizer=None):
     if annotations is None:
         raise ValueError("No annotations were returned.")
 
-    if normalizer is None:
-        annotations_gen = annotations.items()
-    else:
-        annotations_gen = normalizer(annotations)
+    if normalizer is not None:
+        annotations = OrderedDict(normalizer(annotations))
 
     # normalize annotations and crop faces
-    for _, annot in annotations_gen:
-        frame = six.next(frames_gen)
+    for frame_id, frame in enumerate(frames_gen):
+        annot = annotations.get(str(frame_id), None)
         if annot is None:
             continue
         face = cropper(frame, annotations=annot)
-- 
GitLab