-
Notifications
You must be signed in to change notification settings - Fork 3
/
Taskfile.yml
77 lines (66 loc) · 2.5 KB
/
Taskfile.yml
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
version: '3'
# requirements: Install taskfile, nvidia-container-toolkit and docker.
# Global Variables
vars:
GT_IMAGE_NAME: roar-attribution-metrics
DATA_DIR: /data
PYTHON_FLAGS: "TORCH_HOME=./.pytorchcache/ PYTHONPATH=. "
DOCKER_FLAGS: "--shm-size 8G --gpus all --network=host --ipc=host -it --rm "
tasks:
install-nvidia-container-toolkit:
desc: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker
cmds:
- echo "See https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#docker if this doesnt work."
- curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | sudo apt-key add -
- distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
- |
curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
- sudo apt-get update
- sudo systemctl restart docker
build-docker:
desc: Build docker image
cmds:
- |
docker build -t {{.GT_IMAGE_NAME}} - < ./Dockerfile
_run-in-docker:
cmds:
- |
docker run {{.DOCKER_FLAGS}} \
-v {{.PWD}}/:/workspace/ \
-v {{.DATA_DIR}}/:/data/ \
-v $(pwd)/.bash_history:/.bash_history \
{{.GT_IMAGE_NAME}} \
{{.GT_CMD}}
bash-docker:
desc: Run bash in docker container
cmds:
- task: _run-in-docker
vars:
GT_CMD: bash
train-cls:
desc: Train a classification network on PASCAL dataset. To be run from inside docker. Optional var - CONFIG_PATH
cmds:
- |
PYTHONPATH=. TORCH_HOME=./.py-cache python src/roar/train_model.py
extract-attribution-maps:
desc: This task computes attribution maps and extracts them to specified directory.
cmds:
- |
PYTHONPATH=. TORCH_HOME=./.py-cache python src/roar/generate_attribution_dataset.py
evaluate-attribution-maps-roar:
desc: This task computes roar metrics on extracted attribution maps.
cmds:
- |
PYTHONPATH=. TORCH_HOME=./.py-cache python src/roar/retrain_and_evaluate.py
roar:
desc: Run full roar pipeline.
cmds:
- task: train-cls
- task: extract-attribution-maps
- task: evaluate-attribution-maps-roar
lerf:
desc: This task computes lerf metrics. By default uses Resnet50 and ImageNet dataset.
cmds:
- |
PYTHONPATH=. TORCH_HOME=./.py-cache python src/lerf/pixel_perturbation_analysis.py