vqa_v1 fix
@@ -201,6 +201,7 @@ class OeTeacher(FixedDialogTeacher):
def reset(self):
super().reset()
self.example = None
+ self.imageEpochDone = False
def num_examples(self):
"""Number of examples in VQA-v1."""
@@ -230,16 +231,21 @@ class OeTeacher(FixedDialogTeacher):
return action
def next_example(self):
- # save the currently queued example
+ """Returns the next example from this dataset after starting to queue
+ up the next example.
+ """
ready = None
+ # pull up the currently queued example
if self.example is not None:
- if self.image_mode != 'none':
+ if self.image_mode != 'none' and 'image_id' in self.example:
+ # move the image we loaded in the background into the example
image = self.data_queue.get()
self.example['image'] = image
- ready = (self.example, self.epochDone)
- # queue up the next example
- self.example, self.epochDone = super().next_example()
+ ready = (self.example, self.imageEpochDone)
+ # get the next base example: super().next_example() calls self.get()
+ self.example, self.imageEpochDone = super().next_example()
if self.image_mode != 'none' and 'image_id' in self.example:
+ # load the next image in the background
image_id = self.example['image_id']
self.submit_load_request(image_id)
# Try to return the previously cached example
