Update handler.py
Browse files- handler.py +4 -1
handler.py
CHANGED
|
@@ -3,6 +3,8 @@ from typing import Dict, List, Any
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
import json
|
| 5 |
from urllib.request import urlopen
|
|
|
|
|
|
|
| 6 |
|
| 7 |
class EndpointHandler():
|
| 8 |
def __init__(self, path=""):
|
|
@@ -42,8 +44,9 @@ class EndpointHandler():
|
|
| 42 |
image_path = event["inputs"]
|
| 43 |
|
| 44 |
try:
|
|
|
|
| 45 |
#image = urlopen(image_path).read()
|
| 46 |
-
predictions = self.predict_objects(
|
| 47 |
return {
|
| 48 |
"statusCode": 200,
|
| 49 |
"body": json.dumps(predictions),
|
|
|
|
| 3 |
from ultralytics import YOLO
|
| 4 |
import json
|
| 5 |
from urllib.request import urlopen
|
| 6 |
+
from PIL import Image
|
| 7 |
+
from io import BytesIO
|
| 8 |
|
| 9 |
class EndpointHandler():
|
| 10 |
def __init__(self, path=""):
|
|
|
|
| 44 |
image_path = event["inputs"]
|
| 45 |
|
| 46 |
try:
|
| 47 |
+
image = Image.Image()._new(Image.open(BytesIO(image)))
|
| 48 |
#image = urlopen(image_path).read()
|
| 49 |
+
predictions = self.predict_objects(imag)
|
| 50 |
return {
|
| 51 |
"statusCode": 200,
|
| 52 |
"body": json.dumps(predictions),
|