EVAx10_Video_analitics/tools/check-poc-assets.py

22 lines
928 B
Python

"""Verify the independently reviewed inventory for the consent-gated APK."""
import hashlib
import json
from pathlib import Path
import sys
poc = Path(__file__).resolve().parents[1] / "poc"
assets = poc / "assets"
lock = json.loads((poc / "asset-lock.json").read_text())
inventory = {
path.relative_to(assets).as_posix(): hashlib.sha256(path.read_bytes()).hexdigest()
for path in assets.rglob("*") if path.is_file()
}
if inventory != lock:
sys.exit("Face Re-ID PoC assets differ from the reviewed inventory")
manifest = json.loads((assets / "models/sface-int8.json").read_text())
if (manifest["productionAllowed"] is not False or manifest["controlledPocAllowed"] is not True
or manifest["sha256"] != inventory[manifest["file"]]
or manifest["size"] != (assets / manifest["file"]).stat().st_size):
sys.exit("SFace is only admitted in the controlled PoC")
print("Face Re-ID PoC asset gate passed")