def write_warmup_requests(savedmodel_dir, model_name, image_size, batch_sizes=None, num_requests=8):
    'Writes warmup requests for inference into a tfrecord file.\n\n  Args:\n    savedmodel_dir: string, the file to the exported model folder.\n    model_name: string, a model name used inside the model server.\n    image_size: int, size of image, assuming image height and width.\n    batch_sizes: list, a list of batch sizes to create different input requests.\n    num_requests: int, number of requests per batch size.\n\n  Raises:\n    ValueError: if batch_sizes is not a valid integer list.\n  '
    if ((not isinstance(batch_sizes, list)) or (not batch_sizes)):
        raise ValueError('batch sizes should be a valid non-empty list.')
    extra_assets_dir = os.path.join(savedmodel_dir, 'assets.extra')
    tf.gfile.MkDir(extra_assets_dir)
    with tf.python_io.TFRecordWriter(os.path.join(extra_assets_dir, 'tf_serving_warmup_requests')) as writer:
        for batch_size in batch_sizes:
            for _ in range(num_requests):
                request = predict_pb2.PredictRequest()
                image = np.uint8((np.random.rand(image_size, image_size, 3) * 255))
                request.inputs['input'].CopyFrom(tf.make_tensor_proto(([_encode_image(image)] * batch_size), shape=[batch_size]))
                request.model_spec.name = model_name
                request.model_spec.signature_name = 'serving_default'
                log = prediction_log_pb2.PredictionLog(predict_log=prediction_log_pb2.PredictLog(request=request))
                writer.write(log.SerializeToString())
Writes warmup requests for inference into a tfrecord file.

Args:
  savedmodel_dir: string, the file to the exported model folder.
  model_name: string, a model name used inside the model server.
  image_size: int, size of image, assuming image height and width.
  batch_sizes: list, a list of batch sizes to create different input requests.
  num_requests: int, number of requests per batch size.

Raises:
  ValueError: if batch_sizes is not a valid integer list.
def write_warmup_requests(savedmodel_dir, model_name, image_size, batch_sizes=None, num_requests=8):
    'Writes warmup requests for inference into a tfrecord file.\n\n  Args:\n    savedmodel_dir: string, the file to the exported model folder.\n    model_name: string, a model name used inside the model server.\n    image_size: int, size of image, assuming image height and width.\n    batch_sizes: list, a list of batch sizes to create different input requests.\n    num_requests: int, number of requests per batch size.\n\n  Raises:\n    ValueError: if batch_sizes is not a valid integer list.\n  '
    if ((not isinstance(batch_sizes, list)) or (not batch_sizes)):
        raise ValueError('batch sizes should be a valid non-empty list.')
    extra_assets_dir = os.path.join(savedmodel_dir, 'assets.extra')
    tf.gfile.MkDir(extra_assets_dir)
    with tf.python_io.TFRecordWriter(os.path.join(extra_assets_dir, 'tf_serving_warmup_requests')) as writer:
        for batch_size in batch_sizes:
            for _ in range(num_requests):
                request = predict_pb2.PredictRequest()
                image = np.uint8((np.random.rand(image_size, image_size, 3) * 255))
                request.inputs['input'].CopyFrom(tf.make_tensor_proto(([_encode_image(image)] * batch_size), shape=[batch_size]))
                request.model_spec.name = model_name
                request.model_spec.signature_name = 'serving_default'
                log = prediction_log_pb2.PredictionLog(predict_log=prediction_log_pb2.PredictLog(request=request))
                writer.write(log.SerializeToString())