Drazcat-AI commited on
Commit
75d7149
·
verified ·
1 Parent(s): df31ba7

Update handler.py

Browse files
Files changed (1) hide show
  1. 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(image_path)
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),