Initial commit

This commit is contained in:
hanluzhi0429@gmail.com
2025-04-13 09:30:46 +08:00
commit 4f8972e88a
248 changed files with 34689 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
# evaluate
./scripts/interleave/eval_interleave_3d.sh /path/to/ckpt /path/to/images multi_image_in_domain
./scripts/interleave/eval_interleave_3d.sh /path/to/ckpt /path/to/images multi_image_out_domain
./scripts/interleave/eval_interleave_3d.sh /path/to/ckpt /path/to/images multi_view_in_domain
+28
View File
@@ -0,0 +1,28 @@
alias python=python3
CKPT_PATH=$1
NAME=$(echo "$CKPT_PATH" | awk -F'/' '{print $NF}')
echo $NAME
##### set images path
DATA_PATH=$2
EVAL_TYPE=$3
JSON_PATH=$2/$3.json
############################### eval multi-image
RESULT_NAME="logs/${NAME}/${EVAL_TYPE}"
echo $RESULT_NAME
mkdir -p logs/${NAME}
file_path=${RESULT_NAME}/result.jsonl
bash scripts/interleave/eval_multiprocess.sh \
${CKPT_PATH} \
${JSON_PATH} \
${RESULT_NAME} \
${DATA_PATH} \
"" \
8 0
python3 llava/eval/evaluate_interleave.py --result-dir ${RESULT_NAME}
+54
View File
@@ -0,0 +1,54 @@
#!/bin/bash
# Check if three arguments are passed
if [ "$#" -ne 7 ]; then
echo "Usage: $0 <model_path> <question_path> <base_answer_path> <image_folder> <extra_prompt> <N> <temperature>"
exit 1
fi
# Assign the command line arguments to variables
model_path=$1
question_path=$2
base_answer_path=$3
image_folder=$4
extra_prompt=$5
N=$6
temperature=$7
# Loop over each chunk/process
for (( chunk_id=0; chunk_id<N; chunk_id++ ))
do
# Define the answer path for each chunk
answer_path="${base_answer_path}/result_${chunk_id}.jsonl"
if [ -f "$answer_path" ]; then
rm "$answer_path"
fi
# Run the Python program in the background
CUDA_VISIBLE_DEVICES="$chunk_id" python3 llava/eval/model_vqa.py --model-path "$model_path" --question-file "$question_path" --answers-file "$answer_path" --num-chunks "$N" --chunk-idx "$chunk_id" --image-folder "$image_folder" --extra-prompt "$extra_prompt" --temperature "$temperature" &
# Uncomment below if you need a slight delay between starting each process
# sleep 0.1
done
# Wait for all background processes to finish
wait
merged_file="${base_answer_path}/result.jsonl"
if [ -f "$merged_file" ]; then
rm "$merged_file"
fi
# Merge all the JSONL files into one
#cat "${base_answer_path}"_*.jsonl > "${base_answer_path}.jsonl"
for ((i=0; i<N; i++)); do
input_file="${base_answer_path}/result_${i}.jsonl"
cat "$input_file" >> "${base_answer_path}/result.jsonl"
done
# remove the unmerged files
for (( chunk_id=0; chunk_id<N; chunk_id++ ))
do
# Define the answer path for each chunk
answer_path="${base_answer_path}/result_${chunk_id}.jsonl"
if [ -f "$answer_path" ]; then
rm "$answer_path"
fi
done