forked from JarvisUSTC/DiffPure-VLM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminigpt_eval_rtp_multi.sh
58 lines (42 loc) · 1.63 KB
/
minigpt_eval_rtp_multi.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
output_path=$1
image_prompt_path=$2
# 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
nohup bash -c "CUDA_VISIBLE_DEVICES=$i 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=7 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 "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=15 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"