aws / aws/amazon-sagemaker-examples

[Bug Report] Introduction to JumpStart - Text to Image (TypeError)

Open
#4,515 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
11k
Forks
7k
Avg merge
8h 29m
Merged PRs (30d)
8

Description

**Link to the notebook**
[notebook link.
](https://github.com/aws/amazon-sagemaker-examples/blob/main/introduction_to_amazon_algorithms/jumpstart_text_to_image/Amazon_JumpStart_Text_To_Image.ipynb)

**Describe the bug**
. While running through the demo notebook ‘model-txt2img-stabilityai-stable-diffusion-v2-1-base-SDK_2’ there appears to be a TypeError with one of the functions defined (‘parse_response’); it assumes a string is being passed in but the previous function (‘query’) is returning a dictionary already.

```
def query(model_predictor, text):
"""Query the model predictor."""

encoded_text = text.encode("utf-8")

query_response = model_predictor.predict(
encoded_text,
{
"ContentType": "application/x-text",
"Accept": "application/json",
},
)
return query_response

def parse_response(query_response):
"""Parse response and return generated image and the prompt"""

response_dict = json.loads(query_response) ##### query response is already dict
return response_dict["generated_image"], response_dict["prompt"]
```

**To reproduce**
Execute notebook as is returns TypeError: the JSON object must be str, bytes or bytearray, not dict

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.