Fix numpy-free metadata mode after the pixel-layer merge

Guard module-level numpy touchpoints so the metadata-only mode imports
and runs without numpy installed (deferred annotations, lazy DCT basis);
pixel modes now exit early with a clear numpy requirement message.
This commit is contained in:
Victor Kuznetsov
2026-07-23 11:13:13 -07:00
parent 47ef60c2a1
commit 68fb3dded6
+3 -2
View File
@@ -1,5 +1,4 @@
"""Collect all raw metadata over a dataset, for later offline analysis.
Read-only; analysis is NOT this script's job. For every image it writes
one JSONL record containing:
@@ -55,6 +54,8 @@ Dependencies: pip install pillow piexif c2pa-python pillow-heif
(pillow-heif is only needed for HEIC/AVIF inputs).
"""
from __future__ import annotations
import base64
import contextlib
import csv
@@ -954,7 +955,7 @@ def _dct_matrix(n: int = 8) -> np.ndarray:
return m * np.sqrt(2 / n)
_DCT_M = _dct_matrix()
_DCT_M = _dct_matrix() if np is not None else None
def dct_features(gray: np.ndarray) -> dict[str, Any]: