Calling Image Classification Model Deployed in SageMaker Endpoint

Hi, I am still having issues getting this wildifre model endpoint to call correctly and return the result.

I have worked with the example you sent for image segmentation, which works fine - notebooks/sagemaker-notebook.ipynb at main · huggingface/notebooks · GitHub.

Here is the code for deploying the wildifre model in SageMaker Notebook that I am using.

import base64
import json
import sagemaker

# Role
role = sagemaker.get_execution_role()
print(role)

# SageMaker 
from sagemaker.huggingface import HuggingFaceModel
from sagemaker.serializers import DataSerializer

role = sagemaker.get_execution_role()
# Hub Model configuration. https://huggingface.co/models
hub = {
	'HF_MODEL_ID':'EdBianchi/vit-fire-detection',
	'HF_TASK':'image-classification'
}

# create Hugging Face Model Class
huggingface_model = HuggingFaceModel(
    transformers_version='4.17.0',
	pytorch_version='1.10.2',
	py_version='py38',
	env=hub,
	role=role, 
)

# create a serializer for the data
image_serializer = DataSerializer(content_type='image/x-image') # using x-image to support multiple image formats

# deploy model to SageMaker Inference
predictor = huggingface_model.deploy(
	initial_instance_count=1, # number of instances
	instance_type='ml.m5.xlarge', # ec2 instance type
        serializer=image_serializer, # serializer for image data.
)

# download the image 
!wget https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/raw/main/ADE_val_00000001.jpg

# File path
image_path = "ADE_val_00000001.jpg"

# Call the endpoint
with open(image_path, "rb") as data_file:
  image_data = data_file.read()
  res = predictor.predict(data=image_data)
  print(res)

I run into this error…

ModelError: An error occurred (ModelError) when calling the InvokeEndpoint operation: Received client error (400) from primary with message "{
  "code": 400,
  "type": "InternalServerException",
  "message": "an integer is required (got type str)"
}