Manglify_Backend / services /bubble_detector_kitsumed_service.py
tonyliu404's picture
Merge branch 'main' of https://github.com/TonyLiu2004/Multimodal-Manga-Translator
35672c7
raw
history blame
665 Bytes
# not currently in use
from ultralytics import YOLO
from PIL import Image, ImageDraw, ImageFont
class Bubble_Detector_Kitsumed_Service:
def __init__(self, path):
model_path = path / "kitsumed.pt"
self.model = YOLO(model_path)
print("Loaded Bubble Detector Kitsumed")
def predict(self, img_path, conf=0.2, iou=0.4, show_labels=True, show_conf=True, imgsz=640):
img = Image.open(img_path)
results = self.model.predict(
source=img,
conf=conf,
iou=iou,
show_labels=show_labels,
show_conf=show_conf,
imgsz=imgsz,
)
return results[0]