Retrieve the batches. This is a generator object, so you can use it within a loop as: for batch, images in batcher.get_batch(): ... Or outside of a batch with the next() function. :return: A generator yielding three items per iteration: a numpy array holdi
(self)
| 188 | return image[[2,1,0]], scale |
| 189 | |
| 190 | def get_batch(self): |
| 191 | """ |
| 192 | Retrieve the batches. This is a generator object, so you can use it within a loop as: |
| 193 | for batch, images in batcher.get_batch(): |
| 194 | ... |
| 195 | Or outside of a batch with the next() function. |
| 196 | :return: A generator yielding three items per iteration: a numpy array holding a batch of images, the list of |
| 197 | paths to the images loaded within this batch, and the list of resize scales for each image in the batch. |
| 198 | """ |
| 199 | for i, batch_images in enumerate(self.batches): |
| 200 | batch_data = np.zeros(self.shape, dtype=self.dtype) |
| 201 | batch_scales = [None] * len(batch_images) |
| 202 | for i, image in enumerate(batch_images): |
| 203 | self.image_index += 1 |
| 204 | batch_data[i], batch_scales[i] = self.preprocess_image(image) |
| 205 | self.batch_index += 1 |
| 206 | yield batch_data, batch_images, batch_scales |
no test coverage detected