Update handler.py
Browse files- handler.py +3 -1
handler.py
CHANGED
|
@@ -2,6 +2,7 @@ from huggingface_hub import hf_hub_download
|
|
| 2 |
from typing import Dict, List, Any
|
| 3 |
from ultralytics import YOLO
|
| 4 |
import json
|
|
|
|
| 5 |
|
| 6 |
class EndpointHandler():
|
| 7 |
def __init__(self, path=""):
|
|
@@ -40,7 +41,8 @@ class EndpointHandler():
|
|
| 40 |
image_path = event["inputs"]
|
| 41 |
|
| 42 |
try:
|
| 43 |
-
|
|
|
|
| 44 |
return {
|
| 45 |
"statusCode": 200,
|
| 46 |
"body": json.dumps(predictions),
|
|
|
|
| 2 |
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=""):
|
|
|
|
| 41 |
image_path = event["inputs"]
|
| 42 |
|
| 43 |
try:
|
| 44 |
+
image = urlopen(image_path).read()
|
| 45 |
+
predictions = self.predict_objects(image)
|
| 46 |
return {
|
| 47 |
"statusCode": 200,
|
| 48 |
"body": json.dumps(predictions),
|