Update cli.py
This commit is contained in:
+3
-22
@@ -423,36 +423,17 @@ def _show_preview(jobs: list[dict]) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def _enrich_asset_with_face_data(asset: dict, person: dict) -> dict:
|
def _enrich_asset_with_face_data(asset: dict, person: dict) -> dict:
|
||||||
"""Enrich an asset dict with face data from the Immich faces API.
|
|
||||||
|
|
||||||
The search/metadata endpoint does not include face bounding box data,
|
|
||||||
so we fetch it from GET /api/faces?id={asset_id} and inject it into
|
|
||||||
the asset's "people" field so process_face_mode can find it.
|
|
||||||
|
|
||||||
Returns the enriched asset dict (modifies in place and returns it).
|
|
||||||
"""
|
|
||||||
person_id = person["id"]
|
person_id = person["id"]
|
||||||
face_data = fetch_face_data(asset["id"], person_id=person_id)
|
face_data = fetch_face_data(asset["id"], person_id=person_id)
|
||||||
|
|
||||||
if face_data is None:
|
if face_data is None:
|
||||||
logger.debug(
|
logger.debug(f"No face data returned for {person.get('name')} in asset {asset.get('id')}")
|
||||||
f"Face data API returned nothing for {person.get('name')} "
|
|
||||||
f"in asset {asset.get('id')} — Immich may not have detected a face"
|
|
||||||
)
|
|
||||||
return asset
|
return asset
|
||||||
|
|
||||||
# Skip zero-area bounding boxes (face detection failed or no face found)
|
|
||||||
if face_data.bbox == (0, 0, 0, 0):
|
if face_data.bbox == (0, 0, 0, 0):
|
||||||
logger.debug(
|
logger.debug(f"Zero-area bounding box for {person.get('name')} in asset {asset.get('id')}")
|
||||||
f"Zero-area bounding box for {person.get('name')} in asset {asset.get('id')}"
|
|
||||||
)
|
|
||||||
return asset
|
return asset
|
||||||
|
|
||||||
logger.debug(
|
|
||||||
f"Got face data for {person.get('name')} in asset {asset.get('id')}: "
|
|
||||||
f"bbox={face_data.bbox}, img_size={face_data.image_width}x{face_data.image_height}"
|
|
||||||
)
|
|
||||||
|
|
||||||
face_info = {
|
face_info = {
|
||||||
"boundingBoxX1": face_data.bbox[0],
|
"boundingBoxX1": face_data.bbox[0],
|
||||||
"boundingBoxY1": face_data.bbox[1],
|
"boundingBoxY1": face_data.bbox[1],
|
||||||
@@ -462,11 +443,11 @@ def _enrich_asset_with_face_data(asset: dict, person: dict) -> dict:
|
|||||||
"imageHeight": face_data.image_height,
|
"imageHeight": face_data.image_height,
|
||||||
}
|
}
|
||||||
|
|
||||||
# Inject into asset so process_face_mode can find it via asset["people"]
|
|
||||||
asset["people"] = [{"id": person_id, "faces": [face_info]}]
|
asset["people"] = [{"id": person_id, "faces": [face_info]}]
|
||||||
return asset
|
return asset
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def execute_jobs(jobs: list[dict]) -> None:
|
def execute_jobs(jobs: list[dict]) -> None:
|
||||||
"""Download and process images for all jobs."""
|
"""Download and process images for all jobs."""
|
||||||
if not jobs:
|
if not jobs:
|
||||||
|
|||||||
Reference in New Issue
Block a user