aws_lambda/pytorch-serverless/aws/pytorch/prediction.py
def image_to_tensor(preprocess_pipeline, body):
    """Transforms the posted image to a PyTorch Tensor."""
    
    data = json.loads(body)
    name = data['name']
    image = data['file']
    dec = base64.b64decode(image)
    img = PIL.Image.open(io.BytesIO(dec))
    img_tensor = preprocess_pipeline(img)
    img_tensor = img_tensor.unsqueeze(0) # 3d to 4d for batch
    return img_tensor
Transforms the posted image to a PyTorch Tensor.
Transforms the posted image to a PyTorch Tensor.
Transforms the posted image to a PyTorch Tensor .
def image_to_tensor(preprocess_pipeline, body):
    data = json.loads(body)
    name = data['name']
    image = data['file']
    dec = base64.b64decode(image)
    img = PIL.Image.open(io.BytesIO(dec))
    img_tensor = preprocess_pipeline(img)
    img_tensor = img_tensor.unsqueeze(0) 
    return img_tensor
def image_to_tensor ( preprocess_pipeline , body ) : data = json . loads ( body ) name = data [ 'name' ] image = data [ 'file' ] dec = base64 . b64decode ( image ) img = PIL . Image . open ( io . BytesIO ( dec ) ) img_tensor = preprocess_pipeline ( img ) img_tensor = img_tensor . unsqueeze ( 0 ) return img_tensor
Transforms the posted image to a PyTorch Tensor.
Transforms the posted image to a PyTorch Tensor .
"""Transforms the posted image to a PyTorch Tensor.""" # 3d to 4d for batch
preprocess_pipeline
body