File size: 1,380 Bytes
47cb9bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
.PHONY: setup detect export finetune clean app help

PYTHON := python
UV     := uv
DATA_RAW := data/raw
DATA_DET := data/detections
DATA_LAB := data/labeled

help:
	@echo "autolabel — OWLv2 labeling pipeline"
	@echo ""
	@echo "Targets:"
	@echo "  setup     Install dependencies"
	@echo "  app       Launch the Gradio UI (primary workflow)"
	@echo "  detect    Run OWLv2 batch detection via CLI → data/detections/"
	@echo "  export    Build COCO JSON from data/labeled/ via CLI"
	@echo "  finetune  Fine-tune OWLv2 via CLI (future use)"
	@echo "  clean     Remove generated JSON files (raw images untouched)"

setup:
	$(UV) sync
	@cp -n .env.example .env 2>/dev/null || true
	@echo "Done. Run: make app"

app:
	PYTORCH_ENABLE_MPS_FALLBACK=1 $(UV) run python app.py

detect:
	$(UV) run python scripts/run_detection.py \
		--image-dir $(DATA_RAW) \
		--output-dir $(DATA_DET)

export:
	$(UV) run python scripts/export_coco.py \
		--labeled-dir $(DATA_LAB) \
		--output $(DATA_LAB)/coco_export.json

finetune:
	PYTORCH_ENABLE_MPS_FALLBACK=1 $(UV) run python scripts/finetune_owlv2.py \
		--coco-json $(DATA_LAB)/coco_export.json \
		--image-dir $(DATA_RAW)

clean:
	@echo "Removing generated files..."
	find $(DATA_DET) -name "*.json" -delete 2>/dev/null || true
	find $(DATA_LAB) -name "*.json" -delete 2>/dev/null || true
	@echo "Done. Raw images in $(DATA_RAW) are untouched."