代码拉取完成,页面将自动刷新
import json
import base64
from PIL import Image
import io
from model_handler import ModelHandler
def init_context(context):
context.logger.info("Init context... 0%")
model = ModelHandler()
setattr(context.user_data, 'model', model)
context.logger.info("Init context...100%")
def handler(context, event):
context.logger.info("Run person-reidentification-retail-0300 model")
data = event.body
buf0 = io.BytesIO(base64.b64decode(data["image0"].encode('utf-8')))
buf1 = io.BytesIO(base64.b64decode(data["image1"].encode('utf-8')))
threshold = float(data.get("threshold", 0.5))
max_distance = float(data.get("max_distance", 50))
image0 = Image.open(buf0)
image1 = Image.open(buf1)
boxes0 = data["boxes0"]
boxes1 = data["boxes1"]
results = context.user_data.model.infer(image0, boxes0,
image1, boxes1, threshold, max_distance)
return context.Response(body=json.dumps(results), headers={},
content_type='application/json', status_code=200)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。