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
9.79k stars 6.67k forks source link

updating parsing bug #4598

Open ashivadi opened 3 months ago

ashivadi commented 3 months ago

Issue #, if available:

text = "cottage in impressionist style"
query_response = query(model_predictor, text)
img, prmpt = parse_response(query_response)
display_img_and_prompt(img, prmpt)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 3
      1 text = "cottage in impressionist style"
      2 query_response = query(model_predictor, text)
----> 3 img, prmpt = parse_response(query_response)
      4 display_img_and_prompt(img, prmpt)

Cell In[8], line 23, in parse_response(query_response)
     20 def parse_response(query_response):
     21     """Parse response and return generated image and the prompt"""
---> 23     response_dict = json.loads(query_response)
     24     return response_dict["generated_image"], response_dict["prompt"]

File /opt/conda/lib/python3.8/json/__init__.py:341, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    339 else:
    340     if not isinstance(s, (bytes, bytearray)):
--> 341         raise TypeError(f'the JSON object must be str, bytes or bytearray, '
    342                         f'not {s.__class__.__name__}')
    343     s = s.decode(detect_encoding(s), 'surrogatepass')
    345 if "encoding" in kw:

TypeError: the JSON object must be str, bytes or bytearray, not dict

*Description of changes: Removed json.loads as it seems its not needed.

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

review-notebook-app[bot] commented 3 months ago

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

sagemaker-bot commented 3 months ago

AWS CodeBuild CI Report

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

sagemaker-bot commented 3 months ago

AWS CodeBuild CI Report

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

sagemaker-bot commented 3 months ago

AWS CodeBuild CI Report

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

sagemaker-bot commented 3 months ago

AWS CodeBuild CI Report

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository