P1 서연 리노컷 아트 원본과 자산 파이프라인
- 아트 디렉션 v3 스타일 프레임·프롬프트(소유자 선택: 리노컷) - P1 정면 원화·얼굴 없는 기본형, 분할 레이어, 원화 픽셀 입술·턱 조각, 모티프 스프라이트, 소유자 기준 이미지 - 파이프라인 스크립트(분할·얼굴 음영·눈썹 중심선·입술 결·턱 조각·게시)와 manifest 검사 수치 - MediaPipe 모델과 재생성 가능한 진단 PNG는 무시하고 README에 받는 곳을 적었다
This commit is contained in:
parent
85bd079d18
commit
00169533d8
83 changed files with 7843 additions and 0 deletions
49
docs/avatar-art/p1-linocut/scripts/_run_face_landmarks.py
Normal file
49
docs/avatar-art/p1-linocut/scripts/_run_face_landmarks.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
"""단독 프로세스로 FaceLandmarker를 실행해 478 랜드마크를 JSON으로 출력한다.
|
||||
(같은 프로세스에서 ImageSegmenter와 함께 쓰면 세그폴트가 재현되어 분리했다.)
|
||||
|
||||
사용: python _run_face_landmarks.py <이미지경로> <출력json경로>
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import mediapipe as mp
|
||||
import numpy as np
|
||||
from mediapipe.tasks import python as mp_python
|
||||
from mediapipe.tasks.python import vision
|
||||
from PIL import Image
|
||||
|
||||
MODEL_FACE = Path(__file__).resolve().parent / "_models" / "face_landmarker.task"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
image_path = Path(sys.argv[1])
|
||||
out_path = Path(sys.argv[2])
|
||||
|
||||
base_options = mp_python.BaseOptions(model_asset_path=str(MODEL_FACE))
|
||||
options = vision.FaceLandmarkerOptions(
|
||||
base_options=base_options, running_mode=vision.RunningMode.IMAGE, num_faces=1
|
||||
)
|
||||
im = Image.open(image_path).convert("RGB")
|
||||
w, h = im.size
|
||||
arr = np.array(im)
|
||||
mp_image = mp.Image(image_format=mp.ImageFormat.SRGB, data=arr)
|
||||
with vision.FaceLandmarker.create_from_options(options) as landmarker:
|
||||
result = landmarker.detect(mp_image)
|
||||
|
||||
if not result.face_landmarks:
|
||||
out_path.write_text(json.dumps({"ok": False}), encoding="utf-8")
|
||||
print("FACE_LANDMARKS_FAILED")
|
||||
return 1
|
||||
|
||||
lm = result.face_landmarks[0]
|
||||
pts = [[p.x * w, p.y * h] for p in lm]
|
||||
out_path.write_text(json.dumps({"ok": True, "width": w, "height": h, "points": pts}), encoding="utf-8")
|
||||
print(f"FACE_LANDMARKS_OK n={len(pts)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue