A Prime Neural Network (PNN) version of dima806/fairface_age_image_detection, made on primeneural.net. 72 linear layers are PNN layers at 100 % density: in each layer every output reads a fixed, structured set of inputs, the same number for every output, and no index is stored. Each connection is one bit, its sign, with an FP16 scale per input and per output. Each PNN layer also reads its inputs as one bit (+1 at or above an FP16 threshold per input, -1 below): the layer is XOR and a bit count in the PNN kernel library; the file needs the PNN package V4.4.
| Original model | dima806/fairface_age_image_detection |
| PNN layers | 72 at 100 % density |
| Agreement with the original model (top-1, held-out data) | 61.53 % |
| Distillation | 20 epochs on HuggingFaceM4/FairFace (least-squares initialisation, hidden-state matching) |
| Model file | 12.95 MB (1-bit weights and activations; dense parts float16) |
AutoModelForImageClassification.from_pretrained on this repository does not work: PNN layers are not a transformers layer type. pnn_load.py (in this repository) builds the original model from dima806/fairface_age_image_detection, turns the listed layers into PNN layers and loads this file into it.
# pip install torch huggingface_hub transformers -- and the PNN package on the Python path
import importlib.util, torch
from huggingface_hub import hf_hub_download
REPO = "PrimeNeural/fairface_age_image_detection-pnn-d100-w1a1-j36"
spec = importlib.util.spec_from_file_location("pnn_load", hf_hub_download(REPO, "pnn_load.py"))
pnn_load = importlib.util.module_from_spec(spec); spec.loader.exec_module(pnn_load)
load = pnn_load.load
model = load(REPO) # a transformers AutoModelForImageClassification, ready to use
# tokenizer / processor: the original's, e.g. transformers.AutoTokenizer.from_pretrained("dima806/fairface_age_image_detection")
The PNN layers run in plain PyTorch. The PNN kernel library (part of the PNN package) runs them faster on CPUs and NVIDIA GPUs, and primeneural.net serves this model as an inference endpoint.
The weights are derived from dima806/fairface_age_image_detection and are distributed under its licence, apache-2.0: see LICENSE.txt in this repository. Its terms apply to this model.
The PNN file format, pnn_load.py and the PNN package are © PreciseStatistics GmbH; the PNN package is licensed separately (evaluation licence: info@primeneural.net).
© PreciseStatistics GmbH (Prime Neural Networks) · Patent pending (US 19/685,168).
dima806/fairface_age_image_detection