-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathspotty.yaml
192 lines (170 loc) · 7.04 KB
/
spotty.yaml
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
project:
name: imaterialist2020
syncFilters:
- exclude:
- .git/*
- .idea/*
- '*/__pycache__/*'
- training/*
container:
projectDir: /workspace/project
image: tensorflow/tensorflow:1.15.2-gpu-py3-jupyter
ports: [6006, 6007, 8888]
volumeMounts:
- name: project
mountPath: /workspace/project
- name: data
mountPath: /workspace/data
commands: |
apt update && apt install -y git vim zip htop
pip install -r requiremets-spotty.txt
instances:
# - name: gcp-i1
# provider: gcp
# parameters:
# zone: europe-west4-a
## machineType: n1-highmem-2
# machineType: n1-standard-16
# onDemandInstance: true
# bootDiskSize: 20
# volumes:
# - name: data
# parameters:
# size: 300
# deletionPolicy: retain
- name: gcp-i2
provider: gcp
parameters:
zone: europe-west4-a
machineType: n1-highmem-4
# machineType: n1-standard-2
onDemandInstance: true
bootDiskSize: 30
scripts:
tensorboard: |
tensorboard --logdir gs://kaggle-imaterialist2020-data-europe-west4/training/{{MODEL}}
jupyter: |
CUDA_VISIBLE_DEVICES="" jupyter notebook --allow-root --ip 0.0.0.0 --notebook-dir=/workspace/project
train: |
if [ -n "{{MODEL}}" ] && [ -n "{{CONFIG}}" ] && [ -n "{{TPU}}" ] && [ -n "{{MODE}}" ]; then
export STORAGE_BUCKET=gs://kaggle-imaterialist2020-data-europe-west4
export MODEL_DIR=${STORAGE_BUCKET}/training/{{MODEL}}
PYTHONPATH=. python tf_tpu_models/official/mask_rcnn/mask_rcnn_main.py \
--use_tpu=True \
--tpu={{TPU}} \
--model_dir=${MODEL_DIR} \
--num_cores=8 \
--mode="{{MODE}}" \
--eval_wait_next_checkpoint=False \
--config_file=configs/mask_rcnn/{{CONFIG}}.yaml
else
echo "MODEL, CONFIG, TPU and MODE parameters are required."
fi
train-spinenet: |
if [ -n "{{MODEL}}" ] && [ -n "{{CONFIG}}" ] && [ -n "{{TPU}}" ] && [ -n "{{MODE}}" ]; then
export STORAGE_BUCKET=gs://kaggle-imaterialist2020-data-europe-west4
export MODEL_DIR=${STORAGE_BUCKET}/training/{{MODEL}}
PYTHONPATH=tf_tpu_models python tf_tpu_models/official/detection/main.py \
--model="mask_rcnn" \
--model_dir=${MODEL_DIR} \
--mode={{MODE}} \
--eval_after_training=False \
--config_file=configs/spinenet/{{CONFIG}}.yaml \
--use_tpu=True \
--tpu={{TPU}}
else
echo "MODEL, CONFIG, TPU and MODE parameters are required."
fi
submit-spinenet: |
if [ -n "{{MODEL}}" ] && [ -n "{{CONFIG}}" ] && [ -n "{{DATASET}}" ] && [ -n "{{TPU}}" ] && [ -n "{{STEP}}" ]; then
export STORAGE_BUCKET=gs://kaggle-imaterialist2020-data-europe-west4
export MODEL_DIR=${STORAGE_BUCKET}/training/{{MODEL}}
PYTHONPATH=tf_tpu_models python tf_tpu_models/official/detection/main.py \
--model="mask_rcnn" \
--model_dir=${MODEL_DIR} \
--mode=submit \
--submit_checkpoint_step={{STEP}} \
--submit_dataset={{DATASET}} \
--config_file=configs/spinenet/{{CONFIG}}.yaml \
--use_tpu=True \
--tpu={{TPU}}
else
echo "MODEL, CONFIG, DATASET, TPU and STEP parameters are required."
fi
submit: |
if [ -n "{{MODEL}}" ] && [ -n "{{CONFIG}}" ] && [ -n "{{TPU}}" ]; then
export STORAGE_BUCKET=gs://kaggle-imaterialist2020-data-europe-west4
export MODEL_DIR=${STORAGE_BUCKET}/training/{{MODEL}}
PYTHONPATH=. python tf_tpu_models/official/mask_rcnn/mask_rcnn_main.py \
--use_tpu=True \
--tpu={{TPU}} \
--model_dir=${MODEL_DIR} \
--num_cores=8 \
--mode="submit" \
--config_file=configs/mask_rcnn/{{CONFIG}}.yaml \
--params_override="include_groundtruth_in_features=False, validation_file_pattern=${STORAGE_BUCKET}/datasets/imaterialist2020/tfrecords/test-*"
else
echo "MODEL, CONFIG and TPU parameters are required."
fi
predict: |
if [ -n "{{MODEL}}" ] && [ -n "{{DATASET_PREFIX}}" ] && [ -n "{{OUTPUT_DIR}}" ] && [ -n "{{TPU}}" ] && [ -n "{{STEP}}" ]; then
export STORAGE_BUCKET=gs://kaggle-imaterialist2020-data-europe-west4
export MODEL_DIR=${STORAGE_BUCKET}/training/{{MODEL}}
export FILE_PATTERN="${STORAGE_BUCKET}/datasets/{{DATASET_PREFIX}}-*"
export OUTPUT_DIR=${STORAGE_BUCKET}/predictions/{{OUTPUT_DIR}}/{{MODEL}}_{{STEP}}
PYTHONPATH=tf_tpu_models python tf_tpu_models/official/detection/main.py \
--model="mask_rcnn" \
--model_dir=${MODEL_DIR} \
--mode=predict \
--predict_checkpoint_step={{STEP}} \
--predict_file_pattern=$FILE_PATTERN \
--predict_output_dir=$OUTPUT_DIR \
--config_file=${MODEL_DIR}/params.yaml \
--use_tpu=True \
--tpu={{TPU}}
else
echo "MODEL, CONFIG, DATASET, TPU and STEP parameters are required."
fi
eval-coco: |
if [ -n "{{MODEL}}" ] && [ -n "{{CONFIG}}" ] && [ -n "{{TPU}}" ]; then
export TPU_NAME={{TPU}}
export ACCELERATOR_TYPE=v3-8
export STORAGE_BUCKET=gs://kaggle-imaterialist2020-data-europe-west4
export DATA_DIR=${STORAGE_BUCKET}/datasets/coco
export MODEL_DIR=${STORAGE_BUCKET}/training/{{MODEL}}
export CONFIG_PATH=configs/mask_rcnn/{{CONFIG}}.yaml
# export CHECKPOINT=gs://cloud-tpu-artifacts/resnet/resnet-nhwc-2018-10-14/model.ckpt-112602
# export CHECKPOINT=gs://kaggle-imaterialist2020-data-europe-west4/training/200408-mask-rcnn-test1/model.ckpt-22500
export TRAIN_FILE_PATTERN=${DATA_DIR}/train-*
export EVAL_FILE_PATTERN=${DATA_DIR}/val-*
export VAL_JSON_FILE=${DATA_DIR}/instances_val2017.json
# train_and_eval
PYTHONPATH=. python tf_tpu_models/official/mask_rcnn/mask_rcnn_main.py \
--use_tpu=True \
--tpu=${TPU_NAME} \
--model_dir=${MODEL_DIR} \
--num_cores=8 \
--mode="eval" \
--config_file=${CONFIG_PATH} \
--params_override="training_file_pattern=${TRAIN_FILE_PATTERN}, validation_file_pattern=${EVAL_FILE_PATTERN}, include_groundtruth_in_features=True"
else
echo "MODEL, CONFIG and TPU parameters are required."
fi
install-tfrecord-requirements: |
apt update && apt install -y protobuf-compiler python3-pil python3-lxml python3-pip python3-dev git unzip
pip install Cython
pip install git+https://github.com/cocodataset/cocoapi#subdirectory=PythonAPI
if [ ! -e tf-models ]; then
git clone https://github.com/tensorflow/models.git tf-models
touch tf-models/__init__.py
touch tf-models/research/__init__.py
fi
(cd tf-models/research && protoc object_detection/protos/*.proto --python_out=.)
create-tfrecords: |
PYTHONPATH="tf-models:tf-models/research" python tools/datasets/create_coco_tf_record.py \
--logtostderr \
--include_masks \
--image_dir="/workspace/data/imaterialist-fashion-2020-fgvc7/train" \
--object_annotations_file="/workspace/data/imaterialist-fashion-2020-fgvc7/split/valid_coco.json" \
--output_file_prefix="/workspace/data/imaterialist-fashion-2020-fgvc7/tfrecords/valid" \
--num_shards=50