Commit ·
77955ed
1
Parent(s): 83d24c3
Update handler.py
Browse files- handler.py +12 -11
handler.py
CHANGED
|
@@ -15,22 +15,23 @@ class EndpointHandler():
|
|
| 15 |
current_directory = os.getcwd()
|
| 16 |
logging.info(f'current dir: {current_directory}')
|
| 17 |
logging.info(f'all files: {os.listdir(path)}')
|
|
|
|
| 18 |
self.model = YOLO(os.path.join(path, 'yolov8m_detect_usdl.pt'))
|
| 19 |
-
|
| 20 |
|
| 21 |
|
| 22 |
def __call__(self, data: Dict) -> Dict:
|
| 23 |
|
| 24 |
-
logging.info(f'Value of data is : {data}')
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
# postprocess the prediction -> results[0].boxes.data.tolist()
|
| 36 |
-
return {"bbox": data}
|
|
|
|
| 15 |
current_directory = os.getcwd()
|
| 16 |
logging.info(f'current dir: {current_directory}')
|
| 17 |
logging.info(f'all files: {os.listdir(path)}')
|
| 18 |
+
t1 = time.time()
|
| 19 |
self.model = YOLO(os.path.join(path, 'yolov8m_detect_usdl.pt'))
|
| 20 |
+
logging.info(f'TIME: loading the model {time.time() - t1}')
|
| 21 |
|
| 22 |
|
| 23 |
def __call__(self, data: Dict) -> Dict:
|
| 24 |
|
| 25 |
+
# logging.info(f'Value of data is : {data}')
|
| 26 |
|
| 27 |
+
image_url = data.get('image_url')
|
| 28 |
+
print(f'Image url is : {image_url}')
|
| 29 |
+
response = requests.get(image_url)
|
| 30 |
+
pil_image = Image.open(BytesIO(response.content))
|
| 31 |
|
| 32 |
+
print('Model inference started....')
|
| 33 |
+
t1 = time.time()
|
| 34 |
+
results = self.model(pil_image)
|
| 35 |
+
print(f'TIME Model inference: {time.time() - t1}')
|
| 36 |
# postprocess the prediction -> results[0].boxes.data.tolist()
|
| 37 |
+
return {"bbox": results[0].boxes.data.tolist()}
|