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()