-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·63 lines (55 loc) · 2.33 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·63 lines (55 loc) · 2.33 KB
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
#!/bin/bash
###
# @Author: Hadlay Zhang
# @Date: 2024-05-12 00:33:48
# @LastEditors: Hadlay Zhang
# @LastEditTime: 2024-05-31 00:38:01
# @FilePath: /root/MedicalVQA-RAD/run.sh
# @Description: Running Shell Script for training and testing
###
image="ConvNeXt" # Image Encoder, [ViTL16, ConvNeXt, SwinTV2B]
text="BioBERT" # Text Encoder, [BioBERT, BERT]
# <pretrained model path>
text_path="/root/autodl-tmp/BioBERT-v1.1/" # for BioBERT
# text_path="/root/autodl-tmp/BERT/" # for BERT
attention="BAN"
epochs=20
last_epoch=$(($epochs - 1))
# <modify local paths>
prefix="/root/autodl-tmp/RAD/"
models_dir="saved_models/"
result_dir="results/"
model_name="${image}-${text}-${attention}-${epochs}epochs/"
###############
# 1. If only running a single train or test
###############
model_path="${prefix}${models_dir}${model_name}T1/"
results_path="${prefix}${result_dir}${model_name}T1/"
if [ "$1" == "train" ]; then
python3 main.py --use_RAD --RAD_dir data_RAD/ --epochs $epochs --text $text --text_path $text_path --image $image --att $attention --output $model_path
elif [ "$1" == "test" ]; then
python3 test.py --use_RAD --RAD_dir data_RAD/ --epoch $last_epoch --text $text --text_path $text_path --image $image --att $attention --input $model_path --output $results_path
else
echo "Usage: $0 [train|test]"
exit 1
fi
# ###############
# # 2. If running for several iterations using fixed seeds
# ###############
# counter=10
# start=1
# # random seeds
# # seeds=(1204 88 308 12345 9999) # five iters
# seeds=(670487 116739 262949 777572 625049 168726 971963 196842 967067 619993) # ten iters
# for i in $(seq $start $counter); do
# sub="T$i/"
# model_path="${prefix}${models_dir}${model_name}${sub}"
# results_path="${prefix}${result_dir}${model_name}${sub}"
# seed=${seeds[$i-1]}
# # Training
# echo "Training iteration $i, current seed: $seed, Models will be saved in: $model_path"
# python3 main.py --use_RAD --RAD_dir data_RAD/ --epochs $epochs --text $text --text_path $text_path --image $image --att $attention --seed $seed --output $model_path
# # Testing
# echo "Testing iteration $i, Results will be saved in: $results_path"
# python3 test.py --use_RAD --RAD_dir data_RAD/ --epoch $last_epoch --text $text --text_path $text_path --image $image --att $attention --input $model_path --output $results_path
# done