Commit ·
4504977
1
Parent(s): 79bd306
Update handler.py
Browse files- handler.py +20 -14
handler.py
CHANGED
|
@@ -4,27 +4,33 @@ import requests
|
|
| 4 |
from io import BytesIO
|
| 5 |
from PIL import Image
|
| 6 |
import time
|
|
|
|
| 7 |
|
| 8 |
|
| 9 |
class EndpointHandler():
|
| 10 |
def __init__(self, path=""):
|
| 11 |
# load the model
|
| 12 |
-
print('
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
print('
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
|
| 18 |
def __call__(self, data: Dict) -> Dict:
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
print('Model inference started....')
|
| 26 |
-
t1 = time.time()
|
| 27 |
-
results = self.model(pil_image)
|
| 28 |
-
print(f'TIME Model inference: {time.time() - t1}')
|
| 29 |
-
# postprocess the prediction
|
| 30 |
-
return {"bbox":
|
|
|
|
| 4 |
from io import BytesIO
|
| 5 |
from PIL import Image
|
| 6 |
import time
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
|
| 10 |
class EndpointHandler():
|
| 11 |
def __init__(self, path=""):
|
| 12 |
# load the model
|
| 13 |
+
print(f'value of path is : {path}')
|
| 14 |
+
current_directory = os.getcwd()
|
| 15 |
+
print(f'current dir: {current_directory}')
|
| 16 |
+
print(f'all files: {os.listdir(current_directory)}')
|
| 17 |
+
# model_path = "yolov8m_detect_usdl.pt"
|
| 18 |
+
# self.model = YOLO(model_path)
|
| 19 |
+
# print('Yolo model loaded successfully')
|
| 20 |
|
| 21 |
|
| 22 |
def __call__(self, data: Dict) -> Dict:
|
| 23 |
|
| 24 |
+
print(f'Value of data is : {data}')
|
| 25 |
+
|
| 26 |
+
# image_url = data.get('image_url')
|
| 27 |
+
# print(f'Image url is : {image_url}')
|
| 28 |
+
# response = requests.get(image_url)
|
| 29 |
+
# pil_image = Image.open(BytesIO(response.content))
|
| 30 |
|
| 31 |
+
# print('Model inference started....')
|
| 32 |
+
# t1 = time.time()
|
| 33 |
+
# results = self.model(pil_image)
|
| 34 |
+
# print(f'TIME Model inference: {time.time() - t1}')
|
| 35 |
+
# postprocess the prediction -> results[0].boxes.data.tolist()
|
| 36 |
+
return {"bbox": 'data'}
|