-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
44 lines (37 loc) · 1.75 KB
/
Makefile
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
OUT_DIR=output
MODEL_DIR=$(OUT_DIR)/model
MSCOCO_DATA=$(CLCV_HOME)/resources/data/Microsoft_COCO
MSCOCO_IMAGE_DIR=$(CLCV_HOME)/resources/corpora/Microsoft_COCO/images
GID?=0
BATCH_SIZE?=128
LEARNING_RATE?=0.0001
CNN_TYPE?=vgg19
FINETUNE?=False
NUM_WORKERS?=4
EXP_NAME?=$(CNN_TYPE)_$(FINETUNE)
MYCONCEPTS=myconceptsv3 mydepsv4 mydepsprepv4 mypasv4 mypasprepv4
EXCONCEPTS=exconceptsv3 exdepsv4 exdepsprepv4 expasv4 expasprepv4
SPLITS=dev1 dev2
TRAIN_SPLIT=$(firstword $(SPLITS))
TEST_SPLIT=val
train: $(patsubst %,$(MODEL_DIR)/$(EXP_NAME)/mscoco2014_$(TRAIN_SPLIT)_captions_%.pth,$(MYCONCEPTS) $(EXCONCEPTS))
$(MODEL_DIR)/$(EXP_NAME)/mscoco2014_$(TRAIN_SPLIT)_captions_%.pth: \
$(foreach s,$(SPLITS), $(MSCOCO_DATA)/mscoco2014_$(s)_captions_%.h5) \
$(patsubst %,$(MSCOCO_DATA)/mscoco2014_%_imageinfo.json, $(SPLITS))
mkdir -p $(MODEL_DIR)/$(EXP_NAME)
CUDA_VISIBLE_DEVICES=$(GID) python train.py $^ $@ \
--batch_size $(BATCH_SIZE) --learning_rate $(LEARNING_RATE) \
--cnn_type $(CNN_TYPE) --finetune $(FINETUNE) \
--train_image_dir $(MSCOCO_IMAGE_DIR)/train2014 \
--val_image_dir $(MSCOCO_IMAGE_DIR)/train2014 \
--num_workers $(NUM_WORKERS) \
2>&1 | tee $(basename $@).log
test: $(patsubst %,$(MODEL_DIR)/$(EXP_NAME)/mscoco2014_$(TRAIN_SPLIT)_captions_%.json,$(MYCONCEPTS) $(EXCONCEPTS))
$(MODEL_DIR)/$(EXP_NAME)/mscoco2014_$(TRAIN_SPLIT)_captions_%.json: \
$(MSCOCO_DATA)/mscoco2014_$(TEST_SPLIT)_captions_%.h5 \
$(MSCOCO_DATA)/mscoco2014_$(TEST_SPLIT)_imageinfo.json \
$(MODEL_DIR)/$(EXP_NAME)/mscoco2014_$(TRAIN_SPLIT)_captions_%.pth
CUDA_VISIBLE_DEVICES=$(GID) python test.py $^ $@ \
--batch_size $(BATCH_SIZE) \
--test_image_dir $(MSCOCO_IMAGE_DIR)/val2014 \
--num_workers $(NUM_WORKERS)