feat: predictor lazy import

This commit is contained in:
Bingsu
2023-05-04 13:52:13 +09:00
parent 778b5ebe29
commit 0632f70bd0
2 changed files with 4 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
from typing import Union
import mediapipe as mp
import numpy as np
from PIL import Image
@@ -11,6 +10,8 @@ from adetailer.common import create_mask_from_bbox
def mediapipe_predict(
model_type: Union[int, str], image: Image.Image, confidence: float = 0.3
) -> PredictOutput:
import mediapipe as mp
if isinstance(model_type, str):
model_type = mediapipe_model_name_to_type(model_type)
img_width, img_height = image.size

View File

@@ -3,7 +3,6 @@ from typing import Union
import cv2
from PIL import Image
from ultralytics import YOLO
from adetailer import PredictOutput
from adetailer.common import create_mask_from_bbox
@@ -15,6 +14,8 @@ def ultralytics_predict(
confidence: float = 0.3,
device: str = "",
) -> PredictOutput:
from ultralytics import YOLO
model_path = str(model_path)
model = YOLO(model_path)