forked from er-muyue/DeFRCN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_only.sh
96 lines (84 loc) · 5.3 KB
/
main_only.sh
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
#!/usr/bin/env bash
python3 clear_memory.py
EXP_NAME=$1
SAVE_DIR=/root/DeFRCN/checkpoints/voc/${EXP_NAME}
IMAGENET_PRETRAIN=/root/DeFRCN/ImageNetPretrained/MSRA/R-101.pkl # <-- change it to you path
IMAGENET_PRETRAIN_TORCH=/root/DeFRCN/ImageNetPretrained/torchvision/resnet101-5d3b4d8f.pth # <-- change it to you path
SPLIT_ID=$2
echo "EXP_NAME: ${EXP_NAME}"
echo "SAVE_DIR: ${SAVE_DIR}"
echo "IMAGENET_PRETRAIN: ${IMAGENET_PRETRAIN}"
echo "IMAGENET_PRETRAIN_TORCH: ${IMAGENET_PRETRAIN_TORCH}"
echo "SPLIT_ID: ${SPLIT_ID}"
# ------------------------------- Base Pre-train ---------------------------------- #
python3 main.py --num-gpus 1 --config-file configs/voc/defrcn_det_r101_base${SPLIT_ID}.yaml \
--opts MODEL.WEIGHTS ${IMAGENET_PRETRAIN} \
OUTPUT_DIR ${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}
# # ------------------------------ Model Preparation -------------------------------- #
# python3 tools/model_surgery.py --dataset voc --method remove \
# --src-path ${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}/model_final.pth \
# --save-dir ${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}
# BASE_WEIGHT=${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}/model_reset_remove.pth
# # ------------------------------ Novel Fine-tuning -------------------------------- #
# # --> 1. FSRW-like, i.e. run seed0 10 times (the FSOD results on voc in most papers)
# for repeat_id in 0 1 2 3 4 5 6 7 8 9
# do
# for shot in 1 2 3 5 10 # if final, 10 -> 1 2 3 5 10
# do
# for seed in 0
# do
# python3 tools/create_config.py --dataset voc --config_root configs/voc \
# --shot ${shot} --seed ${seed} --setting 'fsod' --split ${SPLIT_ID}
# CONFIG_PATH=configs/voc/defrcn_fsod_r101_novel${SPLIT_ID}_${shot}shot_seed${seed}.yaml
# OUTPUT_DIR=${SAVE_DIR}/defrcn_fsod_r101_novel${SPLIT_ID}/fsrw-like/${shot}shot_seed${seed}_repeat${repeat_id}
# python3 main.py --num-gpus 1 --config-file ${CONFIG_PATH} \
# --opts MODEL.WEIGHTS ${BASE_WEIGHT} OUTPUT_DIR ${OUTPUT_DIR} \
# TEST.PCB_MODELPATH ${IMAGENET_PRETRAIN_TORCH}
# rm ${CONFIG_PATH}
# rm ${OUTPUT_DIR}/model_final.pth
# done
# done
# done
# python3 tools/extract_results.py --res-dir ${SAVE_DIR}/defrcn_fsod_r101_novel${SPLIT_ID}/fsrw-like --shot-list 1 2 3 5 10 # surmarize all results
# # ----------------------------- Model Preparation --------------------------------- #
# python3 tools/model_surgery.py --dataset voc --method randinit \
# --src-path ${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}/model_final.pth \
# --save-dir ${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}
# BASE_WEIGHT=${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}/model_reset_surgery.pth
# # ------------------------------ Novel Fine-tuning ------------------------------- #
# # --> 2. TFA-like, i.e. run seed0~9 for robust results (G-FSOD, 80 classes)
# for seed in 0 1 2 3 4 5 6 7 8 9
# do
# for shot in 1 2 3 5 10 # if final, 10 -> 1 2 3 5 10
# do
# python3 tools/create_config.py --dataset voc --config_root configs/voc \
# --shot ${shot} --seed ${seed} --setting 'gfsod' --split ${SPLIT_ID}
# CONFIG_PATH=configs/voc/defrcn_gfsod_r101_novel${SPLIT_ID}_${shot}shot_seed${seed}.yaml
# OUTPUT_DIR=${SAVE_DIR}/defrcn_gfsod_r101_novel${SPLIT_ID}/tfa-like/${shot}shot_seed${seed}
# python3 main.py --num-gpus 1 --config-file ${CONFIG_PATH} \
# --opts MODEL.WEIGHTS ${BASE_WEIGHT} OUTPUT_DIR ${OUTPUT_DIR} \
# TEST.PCB_MODELPATH ${IMAGENET_PRETRAIN_TORCH}
# rm ${CONFIG_PATH}
# rm ${OUTPUT_DIR}/model_final.pth
# done
# done
# python3 tools/extract_results.py --res-dir ${SAVE_DIR}/defrcn_gfsod_r101_novel${SPLIT_ID}/tfa-like --shot-list 1 2 3 5 10 # surmarize all results
# # ------------------------------ Novel Fine-tuning ------------------------------- # not necessary, just for the completeness of defrcn
# # --> 3. TFA-like, i.e. run seed0~9 for robust results
# BASE_WEIGHT=${SAVE_DIR}/defrcn_det_r101_base${SPLIT_ID}/model_reset_remove.pth
# for seed in 0 1 2 3 4 5 6 7 8 9
# do
# for shot in 1 2 3 5 10 # if final, 10 -> 1 2 3 5 10
# do
# python3 tools/create_config.py --dataset voc --config_root configs/voc \
# --shot ${shot} --seed ${seed} --setting 'fsod' --split ${SPLIT_ID}
# CONFIG_PATH=configs/voc/defrcn_fsod_r101_novel${SPLIT_ID}_${shot}shot_seed${seed}.yaml
# OUTPUT_DIR=${SAVE_DIR}/defrcn_fsod_r101_novel${SPLIT_ID}/tfa-like/${shot}shot_seed${seed}
# python3 main.py --num-gpus 1 --config-file ${CONFIG_PATH} \
# --opts MODEL.WEIGHTS ${BASE_WEIGHT} OUTPUT_DIR ${OUTPUT_DIR} \
# TEST.PCB_MODELPATH ${IMAGENET_PRETRAIN_TORCH}
# rm ${CONFIG_PATH}
# rm ${OUTPUT_DIR}/model_final.pth
# done
# done
# python3 tools/extract_results.py --res-dir ${SAVE_DIR}/defrcn_fsod_r101_novel${SPLIT_ID}/tfa-like --shot-list 1 2 3 5 10 # surmarize all results