Skip to main content

zeromodel-perception

zeromodel-perception is the domain-neutral learning and inference runtime for ZeroModel visual evidence.

Phase P3 status

P3 is the first complete prediction slice:

immutable image/action dataset
        +
unknown SourceVPMDTO
        ↓
ranked actions
+ confidence
+ nearest supporting observations
+ explicit rejection

The baseline deliberately uses the entire normalized VPM. Field relevance, evidence weighting, sparse translation, semantic annotation, and temporal models belong to later stages.

Representation

P1 provides deterministic source-image and target-action artifacts:

bounded image bytes or uint8 array -> SourceVPMDTO
bounded discrete action            -> TargetVPMDTO

SourceImageEncoderSpecDTO declares colour space and hard width, height, pixel, and input-byte limits. P1 accepts L, RGB, and RGBA uint8 observations and performs no implicit crop, resize, augmentation, denoising, EXIF transpose, object detection, or learned embedding.

DiscreteActionSchemaDTO owns a canonical sorted action vocabulary. Each action is encoded as a deterministic one-row one-hot grayscale PNG.

Dataset ledger

P2 records authoritative pairings in RecordedInteractionDTO and builds immutable PerceptionDatasetManifestDTO values. It detects conflicting actions for identical pixels, duplicate sequence steps, non-monotonic timestamps, mixed schemas, and missing identities. Dataset splits are deterministic from interaction identity and an explicit seed.

Baseline model

fit_baseline_nearest_neighbor accepts:

  • a P2 dataset manifest;
  • an explicit mapping of source_vpm_id to SourceVPMDTO;
  • a bounded BaselineInferenceConfigDTO;
  • a declared training split.

The fitter validates every source reference, requires one source shape and encoder contract, and materializes a self-contained immutable BaselineNearestNeighborModelDTO.

The model uses normalized mean absolute pixel distance:

0.0 = pixel-identical
1.0 = maximum possible uint8 difference

The nearest observations vote with inverse-distance weights. Predictions preserve:

  • ranked ActionCandidateDTO values;
  • NeighborEvidenceDTO records with exact interaction identities;
  • winning weight share as confidence;
  • nearest distance;
  • top-two action margin;
  • deterministic prediction identity.

Prediction statuses are:

accepted
rejected_out_of_distribution
rejected_ambiguous

A rejected prediction still retains its candidates and neighbour evidence.

Example

import numpy as np

from zeromodel.perception import (
    BaselineInferenceConfigDTO,
    DiscreteActionSchemaDTO,
    RecordedInteractionDTO,
    SourceImageEncoderSpecDTO,
    build_dataset_manifest,
    encode_discrete_action,
    encode_source_array,
    fit_baseline_nearest_neighbor,
    predict_baseline_action,
)

spec = SourceImageEncoderSpecDTO(color_space="L")
schema = DiscreteActionSchemaDTO.from_labels(["LEFT", "RIGHT"])

left = encode_source_array(np.zeros((4, 4), dtype=np.uint8), spec)
right = encode_source_array(np.full((4, 4), 255, dtype=np.uint8), spec)

interactions = [
    RecordedInteractionDTO.from_vpms(
        sequence_id="example",
        step_index=0,
        source=left,
        target=encode_discrete_action("LEFT", schema),
    ),
    RecordedInteractionDTO.from_vpms(
        sequence_id="example",
        step_index=1,
        source=right,
        target=encode_discrete_action("RIGHT", schema),
    ),
]
manifest = build_dataset_manifest(
    interactions,
    source_encoder_spec_ids=[spec.encoder_spec_id],
)
model = fit_baseline_nearest_neighbor(
    manifest,
    {left.source_vpm_id: left, right.source_vpm_id: right},
    training_split="all",
    config=BaselineInferenceConfigDTO(neighbor_count=2),
)
unknown = encode_source_array(np.full((4, 4), 10, dtype=np.uint8), spec)
prediction = predict_baseline_action(model, unknown)

assert prediction.selected_action == "LEFT"

Dependencies and ownership

The production dependencies remain deliberately small:

  • numpy for deterministic array operations and distance calculation;
  • pillow for bounded image decoding and canonical PNG serialization;
  • zeromodel for core VPM artifact contracts;
  • zeromodel-observation for observation-owned contracts.

Pillow remains an input/output adapter. Perception internals operate on validated NumPy arrays and immutable DTOs.

The package does not own the conservative core artifact kernel, closed-world zeromodel.vision addressing, video capture, arcade semantics, SQLAlchemy persistence, artifact signatures, or game-specific concepts.

See docs/architecture/perception-runtime-design.md for the comprehensive architecture and staged delivery plan.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zeromodel_perception-1.2.0-py3-none-any.whl (172.1 kB view details)

Uploaded Python 3

File details

Details for the file zeromodel_perception-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zeromodel_perception-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fd1ac14d2a1db52989bfec8fb2da5b1ce8311195976ea52ba92158857be7b55b
MD5 c428080fe404ce46ea79c28a19c38074
BLAKE2b-256 f448e16b051c0bb8447ed8a8eb1e136730187154582741be2d209c4d5d14a6dd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.0 This release

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page