mirror of
https://github.com/Bing-su/adetailer.git
synced 2026-03-13 17:30:01 +00:00
fix: mediapipe, ultralytics import
This commit is contained in:
@@ -1 +1 @@
|
||||
__version__ = "23.7.9"
|
||||
__version__ = "23.7.10.dev0"
|
||||
|
||||
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from functools import partial
|
||||
|
||||
import mediapipe as mp
|
||||
import numpy as np
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
@@ -28,8 +29,6 @@ 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
|
||||
@@ -85,8 +84,6 @@ 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
|
||||
@@ -130,8 +127,6 @@ 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()
|
||||
|
||||
@@ -4,14 +4,14 @@ 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
|
||||
|
||||
|
||||
def load_yolo(model_path: str | Path):
|
||||
from ultralytics import YOLO
|
||||
|
||||
try:
|
||||
return YOLO(model_path)
|
||||
except ModuleNotFoundError:
|
||||
@@ -57,7 +57,5 @@ def mask_to_pil(masks, shape: tuple[int, int]) -> list[Image.Image]:
|
||||
shape: tuple[int, int]
|
||||
(width, height) of the original image
|
||||
"""
|
||||
from torchvision.transforms.functional import to_pil_image
|
||||
|
||||
n = masks.shape[0]
|
||||
return [to_pil_image(masks[i], mode="L").resize(shape) for i in range(n)]
|
||||
|
||||
Reference in New Issue
Block a user