How to make the input format for Real Time endpoints ?

Anonymous
2023-11-21T15:18:03.33+00:00

Hello,

I want to test my endpoint. My data are images.

Here's what is indicated for input data :

{
  "input_data": {
    "columns": [
      "image"
    ],
    "index": [],
    "data": []
  }
}


But how do I give my images ? What sould I add in this json file ?

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,333 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-11-21T15:25:31.1733333+00:00

    I found the answer :

    image_path = 'path/to/image.png'
    
    # Read the image and encode it as base64
    with open(image_path, "rb") as img_file:
        image_data = base64.b64encode(img_file.read()).decode('utf-8')
    
    # Structure the data payload
    data = {
      "input_data": {
        "columns": [
          "image"
        ],
        "index": [0], #index of the image data
        "data": [image_data]
      }
    }
    body = str.encode(json.dumps(data))
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.