Skip to content

After upgrading to 2.x SDK, i'm seeing Blazing Text Prediction Error: TypeError: string indices must be integers #1989

Closed

Description

@cfregly

sagemaker==2.16.1

I'm seeing this issue after upgrading the following sample to SDK 2.x: https://github.com/aws/amazon-sagemaker-examples/blob/master/introduction_to_amazon_algorithms/blazingtext_text_classification_dbpedia/blazingtext_text_classification_dbpedia.ipynb

here is the upgraded 2.x version: https://github.com/data-science-on-aws/workshop/blob/8ba7a00/08_train/wip/blazingtext_text_classification_dbpedia.ipynb

Traceback (most recent call last):
  File "/opt/amazon/lib/python3.6/site-packages/blazingtext/serve.py", line 308, in invocations
    texts = data["instances"]

TypeError: string indices must be integers

Activity

  1. SitiBanc commented on Nov 13, 2020

    @SitiBanc

    Change response = text_classifier.predict(json.dumps(payload)) to response = text_classifier.predictor(payload) . You don't need to serialize your payload with JSONSerializer() specified.

  2. PacktAsh commented on Mar 2, 2021

    @PacktAsh

    When I make similar call:
    customer_entity.content_type = 'application/json'

    I am seeing the following error:
    customer_entity.content_type = 'application/json'

  3. martinRenou commented on Sep 27, 2023

    @martinRenou
    Collaborator

    Closing for triaging. Please reopen if you feel like this still applies.

  4. added a commit that references this issue on Jun 3, 2026
  5. added a commit that references this issue on Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions