Skip to content

Commit bf17be3

Browse files
authored
Merge pull request #126 from alibaba/refactor_clip
test mul gpu for clip
2 parents ae2b488 + d9864ad commit bf17be3

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

easynlp/appzoo/multi_modal/evaluator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def evaluate(self, model):
6262
mean_recall = (r1 + r5 + r10) / 3.0
6363
result = [mean_recall, r1, r5, r10]
6464
result = [item * 100 for item in result]
65-
print(r1_stat,r5_stat,r10_stat,query_len)
66-
print(result)
65+
print('r1_num:'+str(r1_stat),'r5_num:'+str(r5_stat),'r10_num:'+str(r10_stat),'query_num:'+str(query_len))
66+
print('r1(%):'+str(result[1]),'r5(%):'+str(result[2]),'r10(%):'+str(result[3]),'mean_recall(%):'+str(result[0]))
6767
logger.info("Inference time = {:.2f}s, [{:.4f} ms / sample] ".format(
6868
total_spent_time, total_spent_time * 1000 / query_len))
6969
eval_outputs = list()

examples/clip_retrieval/run_clip_local.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
export CUDA_VISIBLE_DEVICES=$1
22

3+
#动态获取GPU数
4+
OLD_IFS="$IFS"
5+
IFS=","
6+
arr=($1)
7+
IFS="$OLD_IFS"
8+
39
if [ ! -f ./MUGE_MR_train_base64_part.tsv ]; then
410
wget https://atp-modelzoo-sh.oss-cn-shanghai.aliyuncs.com/release/tutorials/CLIP/MUGE_MR_train_base64_part.tsv
511
fi
@@ -21,7 +27,7 @@ mode=$2
2127
if [ "$mode" = "train" ]; then
2228
easynlp \
2329
--mode $mode \
24-
--worker_gpu=1 \
30+
--worker_gpu=${#arr[@]} \
2531
--tables=./MUGE_MR_train_base64_part.tsv,./MUGE_MR_valid_base64_part.tsv \
2632
--input_schema=text:str:1,image:str:1 \
2733
--first_sequence=text \
@@ -41,7 +47,7 @@ if [ "$mode" = "train" ]; then
4147
elif [ "$mode" = "evaluate" ]; then
4248
easynlp \
4349
--mode $mode \
44-
--worker_gpu=1 \
50+
--worker_gpu=${#arr[@]} \
4551
--tables=./MUGE_MR_valid_base64_part.tsv \
4652
--input_schema=text:str:1,image:str:1 \
4753
--first_sequence=text \
@@ -57,7 +63,7 @@ elif [ "$mode" = "evaluate" ]; then
5763
elif [ "$mode" = "predict" ]; then
5864
easynlp \
5965
--mode $mode \
60-
--worker_gpu=1 \
66+
--worker_gpu=${#arr[@]} \
6167
--tables=./MUGE_MR_test_base64_part_text.tsv \
6268
--input_schema=text:str:1 \
6369
--output_schema=text_feat \
@@ -74,7 +80,7 @@ elif [ "$mode" = "predict" ]; then
7480
# elif [ "$mode" = "predict" ]; then
7581
# easynlp \
7682
# --mode $mode \
77-
# --worker_gpu=1 \
83+
# --worker_gpu=${#arr[@]} \
7884
# --tables=./MUGE_MR_test_base64_part_image.tsv \
7985
# --input_schema=image:str:1 \
8086
# --output_schema=image_feat \

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ rouge
1717
tqdm>=4.48.2
1818
pillow
1919
albumentations
20-
einops
20+
einops
21+
torchvision

0 commit comments

Comments
 (0)