PetTrace ML
Python tools for research on visual re-identification of individual dogs and cats.
The distribution is pettrace-ml; the Python import is pettrace.
Dataset preparation, model inference, metric learning and evaluation live in the package.
Notebooks describe and run the experiments.
Installation
Python 3.11–3.13 is supported. Install a published version in your Python environment:
python -m pip install 'pettrace-ml[notebooks]==0.2.5'
Use pettrace-ml for the base package, [notebooks] for plots and interactive review,
or [notebooks,training] to also install PyTorch, ONNX export and pandas.
Before the first PyPI publication, install the checkout with
python -m pip install -e '.[notebooks]' or install the built wheel.
Model weights and datasets are separate artifacts and are not included in the package. Data lookup uses CPU. GPU screening requires the separately validated E3 environment; installing the training extra alone does not configure CUDA.
Public methods
These are the supported import paths for the research workflows. Helpers whose names
start with _ are internal. Existing experiment imports continue to work.
| Module | Methods | Purpose |
|---|---|---|
pettrace.data.lookup |
lookup_duplicates, restore_lookup_review |
Audit exact duplicates and retrieve only the backed-up inventory from Drive. |
pettrace.data.sources |
discover_body_ids, write_review |
Build a SHA-256 inventory from locally extracted source photos and publisher labels. |
pettrace.data.review |
exclusion_summary, quarantine_groups, quarantine_gallery, save_decisions |
Inspect filtering, review conflicting labels and record explicit decisions. |
pettrace.data.workflow |
TrainingPreparation.restore, .prepare, .publish |
Reuse or prepare versioned training data; Hugging Face publication is a separate explicit step. |
pettrace.data.checkpoints |
DriveBackup.restore, stage_archive |
Verify and restore checkpoints; stage a source ZIP on local scratch storage. |
pettrace.data.versions |
load_local_training, load_training, record_version |
Load verified local or Hub snapshots and assign immutable version names. |
pettrace.models.pipeline |
Pipeline.preprocess, .embed |
Apply the artifact-defined preprocessing and ONNX encoder. |
pettrace.training.features |
feature_cache |
Reuse frozen embeddings by image and model hashes. |
pettrace.training.triplet |
Config, Head, fit, export_encoder |
Train the MLP projection using validation identities and export it with the frozen encoder. |
pettrace.evaluation.core |
load_model, evaluate, report |
Verify registered models and calculate retrieval results. |
pettrace.evaluation.metrics |
retrieval, pair_scores, eer, at_threshold |
Calculate same-species retrieval and pair-score metrics. |
pettrace.tracking |
publish_evaluation, source_identity, save_provenance |
Publish experiment evidence and record its code/runtime identity. |
pettrace.experiments.e1 |
resume_publication |
Retry publication from saved evidence without repeating inference. |
Duplicate audit without model inference
Given a raw review.csv containing source paths, labels and recorded SHA-256 hashes:
import json
from pettrace.data.lookup import lookup_duplicates
report = lookup_duplicates("review.csv", "reports/data-lookup")
summary = json.loads((report / "summary.json").read_text())
print(summary["files"], summary["unique_images"], summary["duplicate_copies"])
This exports one representative per hash, every original label, a mapping of duplicate copies and identity conflicts for review. It does not delete photos or merge identities. Counts cover the supplied inventory, not unobserved photos. Recorded hashes are used without rereading images; exact-byte duplicates do not identify every visually similar photo.
In Colab, after mounting Drive, recover the confirmed raw inventory of the selected volume:
from pathlib import Path
from pettrace.data.lookup import restore_lookup_review
drive = Path("/content/drive/MyDrive/PetTrace")
review = restore_lookup_review(drive, "/content", percent=100)
report = lookup_duplicates(review, drive / "data-lookup")
This uses PetTrace preparation backups in checkpoints/preparation. It copies and verifies
the TAR block containing the CSV and restores only that file. Missing backups fail explicitly;
it does not silently change the percentage or run preparation. Reports persist in Drive.
The optional quarantine_gallery needs the original photos at their recorded paths.
Experiments and reproducibility
Use the versioned experiment notebooks for the complete public-test and private-PetTrace protocols. Keep their galleries separate. Retrieval is closed-set and same-species, with photo-level leave-one-out evaluation. EER fitted and reported on the same pairs is descriptive, not an independently calibrated threshold.
All PetTrace experiment runs must publish results to MLflow. Low-level metric functions alone do not complete an experiment. Model registration and serving promotion are separate from publication. Keep saved evidence when publication fails so it can be retried. Data preparation is a separate workflow.
pip install resolves the declared dependency ranges; it does not apply uv.lock.
For a locked environment use the matching Git tag and uv sync --locked, or the experiment's
published runtime profile. Reproduction also requires the recorded data/model hashes,
configuration, seed and compatible hardware. A version pin does not guarantee identical
floating-point results across hardware.
The package code is MIT-licensed. Original datasets and model weights retain their own licenses. See release instructions and dataset preparation.
Metadata
Release files for pettrace-ml 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pettrace_ml-0.2.5.tar.gz | 214.6 kB | With provenance | Details for pettrace_ml-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pettrace_ml-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for pettrace_ml-0.2.5-py3-none-any.whl |
Total release size: 320.1 kB
Release files / pettrace_ml-0.2.5.tar.gz
| Download URL | pettrace_ml-0.2.5.tar.gz |
|---|---|
| Size | 214.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b654771bdf04df7cae1d10f8610cb62054e9bae6f668e01e0309df6c3b4af2a8
|
|
BLAKE2b-256 checksum How to use checksums |
dc32f7562839a07e56acfd55436c39868b054f6f3850dd39da0925720b168ced
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logRelease files / pettrace_ml-0.2.5-py3-none-any.whl
| Download URL | pettrace_ml-0.2.5-py3-none-any.whl |
|---|---|
| Size | 105.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
12af578722f7ee2569eafbc8f1fe48af6e00b45d9e052d34b6732e0c79581c9a
|
|
BLAKE2b-256 checksum How to use checksums |
f5f46276e3766d342c4d69a3c91f1b7ad67ac382cf92b36ca4670a161387877d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logSecurity for pettrace-ml 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pettrace_ml-0.2.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.