mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-02-21 07:34:05 +00:00
fix: lazy import
This commit is contained in:
@@ -2,7 +2,6 @@ from __future__ import annotations
|
||||
|
||||
from functools import partial
|
||||
|
||||
import mediapipe as mp
|
||||
import numpy as np
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
@@ -29,6 +28,8 @@ def mediapipe_predict(
|
||||
def mediapipe_face_detection(
|
||||
model_type: int, image: Image.Image, confidence: float = 0.3
|
||||
) -> PredictOutput:
|
||||
import mediapipe as mp
|
||||
|
||||
img_width, img_height = image.size
|
||||
|
||||
mp_face_detection = mp.solutions.face_detection
|
||||
@@ -84,6 +85,8 @@ def get_convexhull(points: np.ndarray) -> list[tuple[int, int]]:
|
||||
|
||||
|
||||
def mediapipe_face_mesh(image: Image.Image, confidence: float = 0.3) -> PredictOutput:
|
||||
import mediapipe as mp
|
||||
|
||||
mp_face_mesh = mp.solutions.face_mesh
|
||||
draw_util = mp.solutions.drawing_utils
|
||||
drawing_styles = mp.solutions.drawing_styles
|
||||
@@ -127,6 +130,8 @@ def mediapipe_face_mesh(image: Image.Image, confidence: float = 0.3) -> PredictO
|
||||
def mediapipe_face_mesh_eyes_only(
|
||||
image: Image.Image, confidence: float = 0.3
|
||||
) -> PredictOutput:
|
||||
import mediapipe as mp
|
||||
|
||||
mp_face_mesh = mp.solutions.face_mesh
|
||||
|
||||
left_idx = np.array(list(mp_face_mesh.FACEMESH_LEFT_EYE)).flatten()
|
||||
|
||||
@@ -5,7 +5,6 @@ from pathlib import Path
|
||||
import cv2
|
||||
from PIL import Image
|
||||
from torchvision.transforms.functional import to_pil_image
|
||||
from ultralytics import YOLO
|
||||
|
||||
from adetailer import PredictOutput
|
||||
from adetailer.common import create_mask_from_bbox
|
||||
@@ -17,6 +16,8 @@ def ultralytics_predict(
|
||||
confidence: float = 0.3,
|
||||
device: str = "",
|
||||
) -> PredictOutput:
|
||||
from ultralytics import YOLO
|
||||
|
||||
model = YOLO(model_path)
|
||||
pred = model(image, conf=confidence, device=device)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user