Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Bing-su committed Sep 19, 2023
2 parents a0b4c56 + 56c4cf0 commit 910bf3b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.287"
rev: "v0.0.290"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.0
rev: 23.9.1
hooks:
- id: black
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2023-09-20

- v23.9.3
- ultralytics 버전 8.0.181로 업데이트 (https://github.com/ultralytics/ultralytics/pull/4891)
- mediapipe와 ultralytics의 lazy import

## 2023-09-10

- v23.9.2
Expand Down
2 changes: 1 addition & 1 deletion adetailer/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "23.9.2"
__version__ = "23.9.3"
7 changes: 6 additions & 1 deletion adetailer/mediapipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from functools import partial

import mediapipe as mp
import numpy as np
from PIL import Image, ImageDraw

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion adetailer/ultralytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def run_pip(*args):
def install():
deps = [
# requirements
("ultralytics", "8.0.173", None),
("mediapipe", "0.10.3", None),
("ultralytics", "8.0.181", None),
("mediapipe", "0.10.5", None),
("rich", "13.0.0", None),
# mediapipe
("protobuf", "3.20", "3.9999"),
Expand Down

0 comments on commit 910bf3b

Please sign in to comment.