Commit ·
a8bc875
1
Parent(s): 77955ed
Update handler.py
Browse files- handler.py +5 -4
handler.py
CHANGED
|
@@ -23,15 +23,16 @@ class EndpointHandler():
|
|
| 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 |
-
|
| 29 |
response = requests.get(image_url)
|
| 30 |
pil_image = Image.open(BytesIO(response.content))
|
| 31 |
|
| 32 |
-
|
| 33 |
t1 = time.time()
|
| 34 |
results = self.model(pil_image)
|
| 35 |
-
|
| 36 |
# postprocess the prediction -> results[0].boxes.data.tolist()
|
| 37 |
return {"bbox": results[0].boxes.data.tolist()}
|
|
|
|
| 23 |
def __call__(self, data: Dict) -> Dict:
|
| 24 |
|
| 25 |
# logging.info(f'Value of data is : {data}')
|
| 26 |
+
logger.info(f'data: {data}')
|
| 27 |
+
logger.info(f'type of data: {type(data)}')
|
| 28 |
image_url = data.get('image_url')
|
| 29 |
+
logger.info(f'Image url is : {image_url}')
|
| 30 |
response = requests.get(image_url)
|
| 31 |
pil_image = Image.open(BytesIO(response.content))
|
| 32 |
|
| 33 |
+
logger.info('Model inference started....')
|
| 34 |
t1 = time.time()
|
| 35 |
results = self.model(pil_image)
|
| 36 |
+
logger.info(f'TIME Model inference: {time.time() - t1}')
|
| 37 |
# postprocess the prediction -> results[0].boxes.data.tolist()
|
| 38 |
return {"bbox": results[0].boxes.data.tolist()}
|