data = "$(shell readlink -f "mscoco-1st-caption/000{00..11}.tar")"
openai = ViT-B/16 ViT-B/32 ViT-L/14
open_clip = open_clip__ViT-B-16 open_clip__ViT-B-32

recreate: install-pip dataset embeds

embeds: coco-embeds-openai-vit-b-16 $(open_clip) $(openai)
	echo DONE ^_^

$(openai):
	mkdir -p coco/openai/$@
	python -m clip_retrieval.clip_inference.main "$(data)" coco/openai/$@ --clip_model '$@' --input_format webdataset

$(open_clip):
	touch $@
	mkdir -p coco/open_clip/$(subst __,:,$@)
	python -m clip_retrieval.clip_inference.main "$(data)" coco/open_clip/$(subst __,:,$@) \
		--clip_model '$(subst __,:,$@)' \
		--input_format webdataset


dataset:
	echo Downloading dataset o_O
	git lfs install
	git clone https://huggingface.co/datasets/cat-state/mscoco-1st-caption || true

coco-embeds-openai-vit-b-16:
	python -m clip_retrieval.clip_inference.main "$(data)" coco-embeds-openai-vit-b-16 --clip_model 'ViT-B/16' --input_format webdataset


install-pip:
	echo Installing requirements...
	pip install -r requirements.txt