-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Description
After deploying a scikit model on AWS Sagemaker, I invoke my model using below:
import pandas as pd
payload = pd.read_csv('test3.csv')
payload_file = io.StringIO()
payload.to_csv(payload_file, header = None, index = None)
import boto3
client = boto3.client('sagemaker-runtime')
response = client.invoke_endpoint(
EndpointName= endpoint_name,
Body= payload_file.getvalue(),
ContentType = 'text/csv')
import json
result = json.loads(response['Body'].read().decode())
print(result)
The above code works perfectly but when I try:
Body = payload = np.array([[100,5,1,2,3,4]])
or,
Body = payload = '100, 5,1,2,3,4'
I get the error:
ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (500) from container-1 with message
"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <title>500 Internal Server Error</title> <h1>
Internal Server Error</h1> <p>The server encountered an internal error and was unable to complete your request.
Either the server is overloaded or there is an error in the application.</p>
It was mentioned in Scikit-learn SageMaker Estimators and Models, that the
SageMaker Scikit-learn model server provides a default implementation of input_fn. This function deserializes JSON, CSV, or NPY encoded data into a NumPy array.
I would like to know how I can modify the default to accept a 2D numpy array so it can be used for real-time prediction.
Any suggestion?
I have tried using Inference Pipeline with Scikit-learn and Linear Learner as a reference but could not replace the Linear Learner with a Scikit model. I received the same error.
Metadata
Metadata
Assignees
Labels
No labels