Improve speed
This commit is contained in:
@@ -43,6 +43,23 @@ POSE_LITE_URL = (
|
||||
POSE_LITE_NAME = "pose_landmarker_lite.task"
|
||||
|
||||
|
||||
def build_pose_landmarker(
|
||||
model_path: Path,
|
||||
*,
|
||||
min_pose_detection_confidence: float = 0.3,
|
||||
) -> PoseLandmarker:
|
||||
"""Headless/Docker-safe: force CPU delegate (avoids libGLESv2 GPU path)."""
|
||||
opts = PoseLandmarkerOptions(
|
||||
base_options=BaseOptions(
|
||||
model_asset_path=str(model_path),
|
||||
delegate=BaseOptions.Delegate.CPU,
|
||||
),
|
||||
running_mode=VisionRunningMode.IMAGE,
|
||||
min_pose_detection_confidence=min_pose_detection_confidence,
|
||||
)
|
||||
return PoseLandmarker.create_from_options(opts)
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Input mp4 -> middle 10s pose crop -> doctor identity",
|
||||
@@ -282,12 +299,7 @@ def main() -> int:
|
||||
|
||||
try:
|
||||
model_path = _ensure_pose_lite_model(THIS_DIR / ".mediapipe_models")
|
||||
opts = PoseLandmarkerOptions(
|
||||
base_options=BaseOptions(model_asset_path=str(model_path)),
|
||||
running_mode=VisionRunningMode.IMAGE,
|
||||
min_pose_detection_confidence=0.3,
|
||||
)
|
||||
landmarker = PoseLandmarker.create_from_options(opts)
|
||||
landmarker = build_pose_landmarker(model_path, min_pose_detection_confidence=0.3)
|
||||
try:
|
||||
best_crop = pick_best_person_crop(
|
||||
video_path=args.video,
|
||||
|
||||
@@ -57,14 +57,12 @@ def _infer_doctor_text(args: Namespace, video_path: Path) -> str:
|
||||
try:
|
||||
doctor_mod = _load_doctor_module(script_path)
|
||||
model_path = doctor_mod._ensure_pose_lite_model(script_path.parent / ".mediapipe_models")
|
||||
opts = doctor_mod.PoseLandmarkerOptions(
|
||||
base_options=doctor_mod.BaseOptions(model_asset_path=str(model_path)),
|
||||
running_mode=doctor_mod.VisionRunningMode.IMAGE,
|
||||
landmarker = doctor_mod.build_pose_landmarker(
|
||||
model_path,
|
||||
min_pose_detection_confidence=float(
|
||||
args.doctor_identity_pose_min_detection_confidence
|
||||
),
|
||||
)
|
||||
landmarker = doctor_mod.PoseLandmarker.create_from_options(opts)
|
||||
try:
|
||||
best_crop = doctor_mod.pick_best_person_crop(
|
||||
video_path=video_path,
|
||||
|
||||
Reference in New Issue
Block a user