aws / amazon-sagemaker-examples

Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
https://sagemaker-examples.readthedocs.io
Apache License 2.0
10.1k stars 6.76k forks source link

[Bug Report] #2046

Closed PacktAsh closed 3 years ago

PacktAsh commented 3 years ago

Link to the notebook https://textclassification-az3m.notebook.us-east-2.sagemaker.aws/notebooks/blazingtext-v2.ipynb

Describe the bug Using blazing text model, when making predictions on model end-point

payload= {"instances": ["johhny rocketts", "steak & shake"], "configuration": {"k":2}} customer_entity.content_type = 'application/json' response = customer_entity.predict(json.dumps(payload))

Getting the following error: AttributeError: can't set attribute

To Reproduce deploy blazing text model to container provide payload as shown; define attribute as json make the model call

hongshanli23 commented 3 years ago

@PacktAsh the link you provided points to your notebook instance. You need to provide the link of the notebook published on github

PacktAsh commented 3 years ago

Let me know if this will suffice or I need to actually output a nb and upload it to git. Thanks!

My container -> Blazing Text Model

container=sagemaker.amazon.amazon_estimator.get_image_uri(region_name, "blazingtext", "latest")

My estimator: bt = sagemaker.estimator.Estimator(container, role, instance_count=1, instance_type='ml.m5.large', input_mode='File',
output_path=s3_output_location)

bt.set_hyperparameters(mode='supervised')

Model tuning: bt.fit(inputs=s3_channels)

Deploying to container: customer_entity = bt.deploy(initial_instance_count=1, instance_type='ml.t2.medium')

Defining the payload: payload = {"instances": ["sears roebuck 4692346789", "jc penny 8185551212 jspenn@jcp@com"], "configuration": {"k":2}}

Invoking the model: customer_entity.content_type = 'application/json' response = customer_entity.predict(json.dumps(payload))

Error:


AttributeError Traceback (most recent call last)

in ----> 1 customer_entity.content_type = 'application/json' 2 response = customer_entity.predict(json.dumps(payload)) 3 #response = customer_entity.predict(payload) AttributeError: can't set attribute
hongshanli23 commented 3 years ago

Bug report is intended to be used a place to report bugs in the notebooks we provide as examples. I would suggest you to use stackoverflow to handle your specific use case

PacktAsh commented 3 years ago

This would be the aws notebook I am following. The bug is under Hosting/Inference.

Sorry I misunderstood your question.

https://github.com/aws/amazon-sagemaker-examples/blob/master/introduction_to_amazon_algorithms/blazingtext_text_classification_dbpedia/blazingtext_text_classification_dbpedia.ipynb

hongshanli23 commented 3 years ago

Nice. thanks for the reporting. take a look at this PR https://github.com/aws/amazon-sagemaker-examples/pull/2051

hongshanli23 commented 3 years ago

Fixed in #2051