CARGO := cargo
RELEASE := --release
BIN := target/release/latent-inspector
MODELS := dinov2-vit-l14,ijepa-vit-h14,vjepa2-vitl-fpc2-256,eupe-vit-b16
SAMPLE_IMG := docs/assets/img/samples/elephant_sample_image.jpg
SAMPLE_DATASET := docs/assets/img/samples
CACHE_DIR := $(HOME)/.cache/latent-inspector
COVERAGE_IGNORE := (^|/)src/tui/|(^|/)src/cli/tui.rs$$
COVERAGE_LINE_MIN := 85
COVERAGE_FUNCTION_MIN := 80
.PHONY: build build-release build-stub check clippy coverage coverage-ci fmt \
test clean tui tui-demo inspect compare compare-dataset models download-models help
build:
$(CARGO) build
build-release:
$(CARGO) build $(RELEASE)
build-stub: ## Build default binary; use LATENT_INSPECTOR_MODEL_BACKEND=stub at runtime
$(CARGO) build
check:
$(CARGO) check
clippy: ## Lint with clippy (warnings = errors)
$(CARGO) clippy --all-targets -- -D warnings
coverage:
$(CARGO) llvm-cov --workspace --ignore-filename-regex '$(COVERAGE_IGNORE)' --summary-only
coverage-ci:
$(CARGO) llvm-cov --workspace --ignore-filename-regex '$(COVERAGE_IGNORE)' \
--fail-under-lines $(COVERAGE_LINE_MIN) --fail-under-functions $(COVERAGE_FUNCTION_MIN) \
--summary-only
fmt:
$(CARGO) fmt
test:
$(CARGO) test
tui: build-release
$(BIN) tui $(SAMPLE_IMG) -m $(MODELS)
tui-demo: build-release
$(BIN) tui
inspect: build-release
$(BIN) inspect $(SAMPLE_IMG) --model dinov2-vit-l14
compare: build-release
@outdir=./target/comparison-reports/$$(date +%Y%m%d-%H%M%S)/; \
$(BIN) compare $(SAMPLE_IMG) --models $(MODELS) --format html --output "$$outdir"
compare-dataset: build-release
@outdir=./target/profile-reports/$$(date +%Y%m%d-%H%M%S)/; \
for model in $$(printf '%s' "$(MODELS)" | tr ',' ' '); do \
echo "Profiling $$model on $(SAMPLE_DATASET) -> $$outdir/$$model"; \
$(BIN) profile --model "$$model" --dataset "$(SAMPLE_DATASET)" --format html --output "$$outdir/$$model"; \
done
models: build-release
$(BIN) models
validate: build-release
$(BIN) validate --model dinov2-vit-l14
download-models: build-release
$(BIN) models --download dinov2-vit-l14
cache-status:
@echo "Cache directory: $(CACHE_DIR)"
@ls -lh $(CACHE_DIR)/ 2>/dev/null || echo " (empty — run 'make download-models' first)"
cache-clean:
@echo "This will delete all cached models in $(CACHE_DIR)"
@echo "Press Ctrl+C to cancel, or Enter to continue..."
@read _confirm
rm -rf $(CACHE_DIR)
@echo "Cache cleared."
clean:
$(CARGO) clean
all: fmt clippy test build-release
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'