MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / get_batch

Method get_batch

samples/python/detectron2/image_batcher.py:190–206  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 2

mainFunction · 0.95
mainFunction · 0.95

Calls 1

preprocess_imageMethod · 0.95

Tested by

no test coverage detected