mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-06-10 12:53:56 +02:00
fix(instantid): inline YuNet detection (the imagined _get_yunet doesn't exist)
The InstantID restore module imported `_get_yunet` from `auto_config`, but auto_config doesn't export that function -- the YuNet singleton lives inline inside `detect_face()`. Caught by the Modal cert sweep: restore_faces post-pass failed (cannot import name '_get_yunet' from 'remove_ai_watermarks.auto_config'); keeping un-restored output Inline the YuNet builder the same way `photomaker_restore` does (read `auto_config._FACE_SCORE` and the bundled `face_detection_yunet_2023mar.onnx` asset, build a fresh `FaceDetectorYN` per call). This is the proven pattern from PhotoMaker and avoids a private-API drift between the modules. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -278,12 +278,14 @@ def restore_faces_instantid(
|
||||
import torch
|
||||
|
||||
if detect_faces_fn is None:
|
||||
from remove_ai_watermarks.auto_config import _get_yunet
|
||||
from pathlib import Path
|
||||
|
||||
det = _get_yunet()
|
||||
from remove_ai_watermarks import auto_config as _ac
|
||||
|
||||
def _default_detect(bgr: NDArray[Any]) -> list[tuple[int, int, int, int]]:
|
||||
h_d, w_d = bgr.shape[:2]
|
||||
model = Path(_ac.__file__).parent / "assets" / "face_detection_yunet_2023mar.onnx"
|
||||
det = cv2.FaceDetectorYN.create(str(model), "", (w_d, h_d), _ac._FACE_SCORE, 0.3, 5000)
|
||||
det.setInputSize((w_d, h_d))
|
||||
_, faces = det.detect(bgr)
|
||||
if faces is None:
|
||||
|
||||
Reference in New Issue
Block a user