|
|
|
|
@ -6,6 +6,9 @@ import yaml
|
|
|
|
|
from model_handler import ModelHandler
|
|
|
|
|
from PIL import Image
|
|
|
|
|
|
|
|
|
|
from PIL import ImageFile
|
|
|
|
|
ImageFile.LOAD_TRUNCATED_IMAGES = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init_context(context):
|
|
|
|
|
context.logger.info("Init context... 0%")
|
|
|
|
|
@ -28,7 +31,7 @@ def handler(context, event):
|
|
|
|
|
context.logger.info("Run YoloV7 ONNX model")
|
|
|
|
|
data = event.body
|
|
|
|
|
buf = io.BytesIO(base64.b64decode(data["image"]))
|
|
|
|
|
threshold = float(data.get("threshold", 0.5))
|
|
|
|
|
threshold = float(data.get("threshold", 0.3))
|
|
|
|
|
image = Image.open(buf)
|
|
|
|
|
|
|
|
|
|
results = context.user_data.model.infer(image, threshold)
|
|
|
|
|
|