skumar1998 commited on
Commit
77955ed
·
1 Parent(s): 83d24c3

Update handler.py

Browse files
Files changed (1) hide show
  1. 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
- print('Yolo model loaded successfully')
20
 
21
 
22
  def __call__(self, data: Dict) -> Dict:
23
 
24
- logging.info(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}
 
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()}