|
from handler import EndpointHandler |
|
import json |
|
|
|
|
|
my_handler = EndpointHandler(path=".") |
|
|
|
import base64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import io |
|
from PIL import Image |
|
import requests |
|
response = requests.get('https://mystore-12345-product-images.s3-us-east-2.amazonaws.com/0c817b58-2774-4f02-95b8-3ae379aa2e98.jpeg') |
|
image = Image.open(io.BytesIO(response.content)).convert('RGB') |
|
|
|
response2 = requests.get('https://mystore-12345-product-images.s3-us-east-2.amazonaws.com/3b9c698b-b7ae-4c5d-a978-2179ccc08d12.jpeg') |
|
image2 = Image.open(io.BytesIO(response2.content)).convert('RGB') |
|
|
|
response3 = requests.get('https://mystore-12345-product-images.s3-us-east-2.amazonaws.com/72801dfa-5d6a-442e-91cd-80bdb394a323.jpeg') |
|
image3 = Image.open(io.BytesIO(response3.content)).convert('RGB') |
|
|
|
pil_images = [image.copy() for i in range(10)] |
|
pil_images[1] = image2.copy() |
|
pil_images[2] = image3.copy() |
|
|
|
base64_strings = [] |
|
for output_image in pil_images: |
|
buffered = io.BytesIO() |
|
output_image = output_image.convert('RGB') |
|
output_image.save(buffered, format="png") |
|
img_str = base64.b64encode(buffered.getvalue()) |
|
base64_strings.append(img_str) |
|
|
|
inputs = { |
|
'image': base64_strings |
|
} |
|
|
|
|
|
|
|
import time |
|
start = time.time() |
|
prediction=my_handler(inputs) |
|
|
|
print("inference time itself is", time.time() - start) |
|
|
|
|
|
|
|
|
|
print("type of prediction", type(prediction)) |
|
|
|
data_json = prediction |
|
|
|
|
|
print("type of prediction", data_json.keys()) |
|
|
|
img_str = data_json['image'] |