djscanlation / detect_bubbles.py
maggidev's picture
Update detect_bubbles.py
3764f91 verified
raw
history blame contribute delete
415 Bytes
from ultralytics import YOLO
# Carregamento único do modelo
_model = None
def load_model(model_path):
global _model
if _model is None:
_model = YOLO(model_path)
return _model
def detect_bubbles(model_path, image):
"""
Detecta bolhas na página e retorna bounding boxes.
"""
model = load_model(model_path)
results = model(image)[0]
return results.boxes.data.tolist()