def _generate_bottlenecks(self, image_gen):
    'Generator adapter that passes images through the bottleneck model.\n\n    Args:\n      image_gen: A generator that returns images to be processed. Images are\n        paired with ground truth labels.\n\n    Yields:\n      Bottlenecks from input images, paired with ground truth labels.\n    '
    interpreter = tf.lite.Interpreter(model_content=self.bottleneck_model)
    [x_in] = interpreter.get_input_details()
    [bottleneck_out] = interpreter.get_output_details()
    for (x, y) in image_gen:
        batch_size = x.shape[0]
        interpreter.resize_tensor_input(x_in['index'], (batch_size, IMAGE_SIZE, IMAGE_SIZE, 3))
        interpreter.allocate_tensors()
        interpreter.set_tensor(x_in['index'], x)
        interpreter.invoke()
        bottleneck = interpreter.get_tensor(bottleneck_out['index'])
        (yield (bottleneck, y))
Generator adapter that passes images through the bottleneck model.

Args:
  image_gen: A generator that returns images to be processed. Images are
    paired with ground truth labels.

Yields:
  Bottlenecks from input images, paired with ground truth labels.
def _generate_bottlenecks(self, image_gen):
    'Generator adapter that passes images through the bottleneck model.\n\n    Args:\n      image_gen: A generator that returns images to be processed. Images are\n        paired with ground truth labels.\n\n    Yields:\n      Bottlenecks from input images, paired with ground truth labels.\n    '
    interpreter = tf.lite.Interpreter(model_content=self.bottleneck_model)
    [x_in] = interpreter.get_input_details()
    [bottleneck_out] = interpreter.get_output_details()
    for (x, y) in image_gen:
        batch_size = x.shape[0]
        interpreter.resize_tensor_input(x_in['index'], (batch_size, IMAGE_SIZE, IMAGE_SIZE, 3))
        interpreter.allocate_tensors()
        interpreter.set_tensor(x_in['index'], x)
        interpreter.invoke()
        bottleneck = interpreter.get_tensor(bottleneck_out['index'])
        (yield (bottleneck, y))