mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-04-22 23:39:07 +00:00
feat: predictor lazy import
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user