Build & Run#
Local install#
Requires Python 3.10+ and pip >= 23.
Smoke-test:
Run the test suite#
Expected: 113 passed, ~94% coverage on the library.
Train from the CLI#
bash scripts/train.sh # uses configs/default.yaml
bash scripts/train.sh configs/mnist.yaml # custom config
The checkpoint is written to checkpoints/kanx_model.keras by default
(configurable in YAML).
Benchmark#
Serve the REST API locally#
Docker#
docker build -t kanx:latest .
docker run --rm -p 8000:8000 \
-e KANX_CHECKPOINT=/app/checkpoints/kanx_model.keras \
-v $(pwd)/checkpoints:/app/checkpoints \
kanx:latest
Or via compose:
Kubernetes#
docker build -t kanx:latest .
kind load docker-image kanx:latest # if you use kind
kubectl apply -f k8s/
kubectl port-forward svc/kanx-api 8000:80
curl http://localhost:8000/api/health
See k8s/ — Deployment with rolling updates, Service, Ingress, HPA, PVC for
model storage.
Environment variables#
| Variable | Default | Used by |
|---|---|---|
KANX_CONFIG |
configs/default.yaml |
api/app.py startup |
KANX_CHECKPOINT |
checkpoints/kanx_model.keras |
api/app.py startup |
KANX_MAX_BATCH |
4096 |
/api/predict guard |
TF_CPP_MIN_LOG_LEVEL |
2 (recommended in prod) |
TensorFlow stderr noise |
Reproducibility#
Seeds Python random, numpy, tf.random and tf.keras.utils.set_random_seed
in one call. Called automatically by kanx.train.