georgescutelnicu commited on
Commit
bb69d0a
·
verified ·
1 Parent(s): 5e7fcd6

Update detect_bubbles.py

Browse files
Files changed (1) hide show
  1. detect_bubbles.py +5 -4
detect_bubbles.py CHANGED
@@ -6,7 +6,7 @@ def safe_load_model(model_path):
6
  Manually loads the YOLO model weights with 'weights_only' set to False
7
  to avoid the security check issue with PyTorch.
8
  """
9
- model = torch.load(model_path, map_location='cpu', weights_only=False)
10
  return model
11
 
12
  def detect_bubbles(model_path, image_path):
@@ -19,7 +19,8 @@ def detect_bubbles(model_path, image_path):
19
  list: A list containing the coordinates, score, and class_id of
20
  the detected bubbles.
21
  """
22
- model = safe_load_model(model_path)
23
- bubbles = model(image_path)[0]
 
24
 
25
- return bubbles.boxes.data.tolist()
 
6
  Manually loads the YOLO model weights with 'weights_only' set to False
7
  to avoid the security check issue with PyTorch.
8
  """
9
+ model = YOLO(model_path)
10
  return model
11
 
12
  def detect_bubbles(model_path, image_path):
 
19
  list: A list containing the coordinates, score, and class_id of
20
  the detected bubbles.
21
  """
22
+ model = safe_load_model(model_path)
23
+ results = model(image_path)
24
+ bubbles = results[0].boxes.data.tolist()
25
 
26
+ return bubbles