qwen25_vl_scripts/qwen25_vl_rtp_diffpure.sh
output_path=$1
image_prompt_path=$2
def_num_denoising_steps=$3
# default gpu_id=0
gpu_id="${4:-0}"
model_path="${5:-Qwen/Qwen2.5-VL-7B-Instruct}"

# if output path does not exist, create it
if [ ! -d $output_path ]; then
    mkdir -p $output_path
fi

# for i in {0..6}
# do
#   # 限制可见GPU
#   nohup bash -c "CUDA_VISIBLE_DEVICES=$i python qwen2vl_general_inference.py --model_path $model_path --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts_challenges_$i.jsonl --output_file $output_path/rtp_prompts_challenges_$i.jsonl" > $i.log 2>&1 &
# done

# CUDA_VISIBLE_DEVICES=7 python qwen2vl_general_inference.py --model_path $model_path  --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
# 限制可见GPU
nohup bash -c "CUDA_VISIBLE_DEVICES=$gpu_id python qwen25vl_general_inference_diffpure.py --model_path $model_path --gpu-id 0 --image_file $image_prompt_path --input_file harmful_corpus/rtp_prompts.jsonl --output_file $output_path/rtp_prompts_challenges.jsonl --def_max_timesteps $def_num_denoising_steps --def_num_denoising_steps $def_num_denoising_steps" > $output_path/output.log 2>&1 &

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_id 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
CUDA_VISIBLE_DEVICES=$gpu_id python cal_metrics_markdown.py --input $output_path/rtp_prompts_challenges_metrics.jsonl

echo "Calculated metrics"