I have done training a model with the build in image classification model to classify two phone models by raw images with lst file.(Ex:Iphone6splus and Iphone7plus) So the num of classes is 2, num of datasets I use is 1600 images, 800 for each class.
After that, I created the end point in console using the artifacts data from tanning job that have been done.
In order to deploy the model to test the accuracy, I need to use the juputer notebook?
import json
import numpy as np
import boto3
runtime = boto3.Session().client(service_name='sagemaker-runtime')
# set the object categories array
object_categories = ['class1','class0'}
# Load the image bytes
img = open('xxxfolder/xxx.jpg', 'rb').read()
# Call your model for predicting which object appears in this image.
response = runtime.invoke_endpoint(
EndpointName=endpoint_name,
ContentType='application/x-image',
Body=bytearray(img)
)
# read the prediction result and parse the json
result = response['Body'].read()
result = json.loads(result)
# which category has the highest confidence?
pred_label_id = np.argmax(result)
print( “%s (%f)” % (object_categories[pred_label_id], result[pred_label_id] )
)
Is this the sample code that I need to refer to get the results?