Testing in Mithridatium has two layers:
- Unit tests for contracts, helper functions, and report structure.
- CLI/manual tests against local or Hugging Face models.
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"Optional extras:
pip install -e ".[hf]" # Hugging Face model loading
pip install -e ".[ui]" # Streamlit and Gradio UI dependencies
pip install -e ".[all]" # Development, HF, UI, and demo dependenciespytestRun a focused subset:
pytest tests/test_freeeagle.py tests/test_freeeagle_wrapper.py
pytest tests/test_strip_scores.py tests/test_strip_entropy.py
pytest tests/tests_report.pySome tests skip when local benchmark checkpoints are not available.
Train or provide a checkpoint, then run one defense at a time:
mithridatium detect \
--model models/resnet18_poison.pth \
--data cifar10 \
--defense mmbd \
--out reports/mmbd.json \
--forceUse a known clean model and a known poisoned model when possible. A defense is easier to evaluate when you can compare both reports.
Use --provider huggingface and a model that loads through AutoModelForImageClassification:
mithridatium detect \
--provider huggingface \
--hf-model-id microsoft/resnet-50 \
--data cifar10_for_imagenet \
--defense strip \
--out reports/hf_strip.json \
--forceHugging Face model support may depend on architecture compatibility and preprocessing. FreeEagle is not currently compatible with the Hugging Face wrapper because the wrapper does not expose stable internal ResNet stages.
The report JSON has top-level metadata and a defense-specific results object. Start with:
results.verdictresults.thresholds- the defense's key score, such as
anomaly_metric,p_value,entropy_mean, orsuspicion_score results.parameters, to confirm what settings were used
Treat a single report as a signal, not a complete proof. Thresholds may need calibration for a new dataset, architecture, or preprocessing pipeline.