File size: 3,605 Bytes
c881b77 | 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 | #!/usr/bin/env bash
set -e
CONFIGS=()
SEEDS=()
CKPTS=()
RUN_IDS=()
METASEED=""
NUM_SEED=-1
META_START=0
K_SHOTS=()
while [[ $# -gt 0 ]]; do
case $1 in
--config)
shift
CONFIGS=($1)
;;
--seed)
shift
SEEDS=($1)
;;
--metaseed)
shift
METASEED=$1
;;
--num_seed)
shift
NUM_SEED=$1
;;
--meta_start)
shift
META_START=$1
;;
--ckpt)
shift
CKPTS=($1)
;;
--run_id)
shift
RUN_IDS=($1)
;;
--k_shot)
shift
K_SHOTS=($1)
;;
*)
echo "Unknown argument: $1"
exit 1
;;
esac
shift
done
if [[ ${#CONFIGS[@]} -eq 0 ]] \
|| [[ ${#CKPTS[@]} -eq 0 ]] \
|| [[ ${#K_SHOTS[@]} -eq 0 ]] \
|| [[ ${#RUN_IDS[@]} -eq 0 ]]; then
echo "Error: missing required arguments."
echo "You must provide: --config, --gpu_ids, --run_id, --k_shot"
echo "And one of: --seed OR --metaseed"
exit 1
fi
if [[ -z "$METASEED" && ${#SEEDS[@]} -eq 0 ]]; then
echo "Error: either --seed or --metaseed must be provided."
exit 1
fi
IFS=',' read -r -a GPU_ARRAY <<< "$GPU_IDS"
NUM_PROCESSES=${#GPU_ARRAY[@]}
if [[ -n "$METASEED" ]]; then
if [[ $NUM_SEED -lt 0 ]]; then
echo "Error: you must set --num_seed when using --metaseed."
exit 1
fi
echo "[INFO] Using metaseed=$METASEED"
echo "[INFO] Will use seeds index range [$META_START, $NUM_SEED)"
mapfile -t ALL_SEEDS < <(
shuf -i 0-9999 \
--random-source=<(awk -v s="$METASEED" 'BEGIN { while (1) printf "%s", s }') \
| head -n $NUM_SEED
)
# SEEDS=("${ALL_SEEDS[@]:META_START:NUM_SEED-META_START}")
SEEDS=("${ALL_SEEDS[@]:$META_START:$((NUM_SEED - META_START))}")
echo "[INFO] Total Seeds Generated: ${#ALL_SEEDS[@]}"
echo "[INFO] Using Seeds: ${SEEDS[@]}"
fi
echo "CONFIGS: ${CONFIGS[@]}"
echo "SEEDS: ${SEEDS[@]}"
echo "RUN_IDS: ${RUN_IDS[@]}"
echo "K_SHOTS: ${K_SHOTS[@]}"
echo "CKPTS: ${CKPTS[@]}"
for k_shot in "${K_SHOTS[@]}"; do
for run_id in "${RUN_IDS[@]}"; do
for config in "${CONFIGS[@]}"; do
for ckpt in "${CKPTS[@]}"; do
python summarize-partial.py --cfg $config -r $run_id -c $ckpt -k $k_shot \
-m yolo_mAP yolo_mAP50 yolo_mAP75 FasterRCNN_mAP FasterRCNN_mAP50 FasterRCNN_mAP75 \
FasterRCNN_mAP_airport FasterRCNN_mAP_chimney FasterRCNN_mAP_dam FasterRCNN_mAP_trainstation FasterRCNN_mAP_windmill \
FasterRCNN_mAP_corals FasterRCNN_mAP_cuttlefish FasterRCNN_mAP_jellyfish FasterRCNN_mAP_turtle \
FasterRCNN_mAP_diver FasterRCNN_mAP_holothurian FasterRCNN_mAP_scallop FasterRCNN_mAP_starfish \
FasterRCNN_Subset_mAP FasterRCNN_Subset_mAP50 FasterRCNN_Subset_mAP75 \
FasterRCNN_Subset_mAP_airport FasterRCNN_Subset_mAP_chimney FasterRCNN_Subset_mAP_dam FasterRCNN_Subset_mAP_trainstation FasterRCNN_Subset_mAP_windmill \
FasterRCNN_Subset_mAP_corals FasterRCNN_Subset_mAP_cuttlefish FasterRCNN_Subset_mAP_jellyfish FasterRCNN_Subset_mAP_turtle \
FasterRCNN_mAP_bus FasterRCNN_mAP_dog FasterRCNN_mAP_motorbike FasterRCNN_mAP_table \
FID KID_mean\
-s "${SEEDS[@]}"
done
done
done
done |