forked from JarvisUSTC/DiffPure-VLM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminigpt_eval_rtp_zys.sh
91 lines (60 loc) · 3.68 KB
/
minigpt_eval_rtp_zys.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
output_path=$1
image_prompt_path=$2
gpu_device=$3
# dp_f_step=$3
# dp_r_step=$4
# if output path does not exist, create it
if [ ! -d $output_path ]; then
mkdir -p $output_path
fi
# for i in {9..15}
# do
# j=$((i-9))
# # 限制可见GPU
# bash -c "CUDA_VISIBLE_DEVICES=10 python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_$j.jsonl --output_file $output_path/rtp_prompts_challenges_$j.jsonl" > $j.log 2>&1 &
# done
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_0.jsonl --output_file $output_path/rtp_prompts_challenges_0.jsonl
echo "part 1 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_1.jsonl --output_file $output_path/rtp_prompts_challenges_1.jsonl
echo "part 2 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_2.jsonl --output_file $output_path/rtp_prompts_challenges_2.jsonl
echo "part 3 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_3.jsonl --output_file $output_path/rtp_prompts_challenges_3.jsonl
echo "part 4 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_4.jsonl --output_file $output_path/rtp_prompts_challenges_4.jsonl
echo "part 5 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_5.jsonl --output_file $output_path/rtp_prompts_challenges_5.jsonl
echo "part 6 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_6.jsonl --output_file $output_path/rtp_prompts_challenges_6.jsonl
echo "part 7 done"
CUDA_VISIBLE_DEVICES=$gpu_device python minigpt_inference.py --cfg-path eval_configs/minigpt4_eval.yaml --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_7.jsonl --output_file $output_path/rtp_prompts_challenges_7.jsonl
echo "part 8 done"
# echo "Started all processes"
# # wait for all processes to finish
# wait
# echo "All processes finished"
## merge all the jsonl outputs
# loop
for i in {0..7}
do
cat $output_path/rtp_prompts_challenges_$i.jsonl >> $output_path/rtp_prompts_challenges.jsonl
done
echo "Merged all jsonl outputs"
# remove the individual jsonl outputs
for i in {0..7}
do
rm $output_path/rtp_prompts_challenges_$i.jsonl
done
echo "Removed individual jsonl outputs"
# # move the logs to output path
# for i in {0..7}
# do
# mv $i.log $output_path
# done
# echo "Moved logs"
# evaluate the generated prompts
CUDA_VISIBLE_DEVICES=$gpu_device python get_metric.py --input $output_path/rtp_prompts_challenges.jsonl --output $output_path/rtp_prompts_challenges_metrics.jsonl
echo "Evaluated the generated prompts"
# cal metric
python cal_metrics_markdown.py --input $output_path/rtp_prompts_challenges_metrics.jsonl
echo "Calculated metrics"