rmbg/Makefile
Michael Pilosov 3f24ce2f80 publishing
2026-05-16 19:14:46 -06:00

65 lines
1.8 KiB
Makefile

# BiRefNet background removal service — CLI shortcuts.
# Override defaults inline, e.g.: make test BG=white INPUT=photo.jpg
COMPOSE ?= docker compose
PYTHON ?= python3
PORT ?= 8000
INPUT ?= test.jpg
OUTPUT ?= output.png
BG ?= alpha
BLUR ?= 0
.DEFAULT_GOAL := help
.PHONY: help build run up stop down logs log ps test test-mask dev sync shell clean fmt testpub
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## ' $(MAKEFILE_LIST) \
| awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
build: ## Build the Docker image
$(COMPOSE) build
run up: ## Start the service (GPU) in the background
$(COMPOSE) up -d
stop down: ## Stop and remove the service container
$(COMPOSE) down
logs log: ## Follow service logs
$(COMPOSE) logs -f
ps: ## Show service status
$(COMPOSE) ps
test: ## Send INPUT to the running service, save OUTPUT
$(PYTHON) scripts/client.py --url http://localhost:$(PORT) \
--input $(INPUT) --output $(OUTPUT) --background $(BG) --mask-blur $(BLUR)
test-mask: ## Like 'test' but also save the raw mask (mask.png)
$(PYTHON) scripts/client.py --url http://localhost:$(PORT) \
--input $(INPUT) --output $(OUTPUT) --background $(BG) \
--mask-blur $(BLUR) --mask-output mask.png
sync: ## Install dependencies locally with uv
uv sync
dev: sync ## Run the service locally (no Docker; needs local CUDA)
uv run rmbg-as-a-service
shell: ## Open a shell inside a fresh container
$(COMPOSE) run --rm --entrypoint bash rmbg
fmt: ## Format code with ruff
uv run ruff format src scripts
clean: ## Stop the service and remove build artifacts
-$(COMPOSE) down
rm -f $(OUTPUT) mask.png
testpub: ## Publish dist/ to TestPyPI (UV_PUBLISH_TOKEN from .env)
uv build
set -a && . ./.env && set +a && \
uv publish --publish-url https://test.pypi.org/legacy/ -t "$$UV_PUBLISH_TOKEN" --dry-run