From 3b646d4f6800e3093b5a921b97d02336a02d4abf Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Wed, 22 Dec 2021 10:26:20 +0800 Subject: [PATCH] fix vq utils (#5001) * fix vq utils * fix bs --- ppstructure/vqa/eval_re.py | 2 +- ppstructure/vqa/eval_ser.py | 2 +- ppstructure/vqa/infer_re.py | 2 +- ppstructure/vqa/infer_ser.py | 6 +++++- ppstructure/vqa/infer_ser_e2e.py | 8 ++++++-- ppstructure/vqa/infer_ser_re_e2e.py | 2 +- ppstructure/vqa/train_re.py | 2 +- ppstructure/vqa/train_ser.py | 2 +- ppstructure/vqa/{utils.py => vqa_utils.py} | 0 9 files changed, 17 insertions(+), 9 deletions(-) rename ppstructure/vqa/{utils.py => vqa_utils.py} (100%) diff --git a/ppstructure/vqa/eval_re.py b/ppstructure/vqa/eval_re.py index 12bb9cab..68c27bad 100644 --- a/ppstructure/vqa/eval_re.py +++ b/ppstructure/vqa/eval_re.py @@ -24,7 +24,7 @@ import paddle from paddlenlp.transformers import LayoutXLMTokenizer, LayoutXLMModel, LayoutXLMForRelationExtraction from xfun import XFUNDataset -from utils import parse_args, get_bio_label_maps, print_arguments +from vqa_utils import parse_args, get_bio_label_maps, print_arguments from data_collator import DataCollator from metric import re_score diff --git a/ppstructure/vqa/eval_ser.py b/ppstructure/vqa/eval_ser.py index 52eeb8a1..95f428c7 100644 --- a/ppstructure/vqa/eval_ser.py +++ b/ppstructure/vqa/eval_ser.py @@ -33,7 +33,7 @@ from paddlenlp.transformers import LayoutLMModel, LayoutLMTokenizer, LayoutLMFor from xfun import XFUNDataset from losses import SERLoss -from utils import parse_args, get_bio_label_maps, print_arguments +from vqa_utils import parse_args, get_bio_label_maps, print_arguments from ppocr.utils.logging import get_logger diff --git a/ppstructure/vqa/infer_re.py b/ppstructure/vqa/infer_re.py index 7937700a..b6774e77 100644 --- a/ppstructure/vqa/infer_re.py +++ b/ppstructure/vqa/infer_re.py @@ -15,7 +15,7 @@ import paddle from paddlenlp.transformers import LayoutXLMTokenizer, LayoutXLMModel, LayoutXLMForRelationExtraction from xfun import XFUNDataset -from utils import parse_args, get_bio_label_maps, draw_re_results +from vqa_utils import parse_args, get_bio_label_maps, draw_re_results from data_collator import DataCollator from ppocr.utils.logging import get_logger diff --git a/ppstructure/vqa/infer_ser.py b/ppstructure/vqa/infer_ser.py index 7994b544..f5fb581f 100644 --- a/ppstructure/vqa/infer_ser.py +++ b/ppstructure/vqa/infer_ser.py @@ -14,6 +14,10 @@ import os import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(__dir__) + import json import cv2 import numpy as np @@ -22,7 +26,7 @@ from copy import deepcopy import paddle # relative reference -from utils import parse_args, get_image_file_list, draw_ser_results, get_bio_label_maps +from vqa_utils import parse_args, get_image_file_list, draw_ser_results, get_bio_label_maps from paddlenlp.transformers import LayoutXLMModel, LayoutXLMTokenizer, LayoutXLMForTokenClassification from paddlenlp.transformers import LayoutLMModel, LayoutLMTokenizer, LayoutLMForTokenClassification diff --git a/ppstructure/vqa/infer_ser_e2e.py b/ppstructure/vqa/infer_ser_e2e.py index 6bb02475..33fe4dbb 100644 --- a/ppstructure/vqa/infer_ser_e2e.py +++ b/ppstructure/vqa/infer_ser_e2e.py @@ -14,6 +14,10 @@ import os import sys + +__dir__ = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(__dir__) + import json import cv2 import numpy as np @@ -25,9 +29,9 @@ from paddlenlp.transformers import LayoutXLMModel, LayoutXLMTokenizer, LayoutXLM from paddlenlp.transformers import LayoutLMModel, LayoutLMTokenizer, LayoutLMForTokenClassification # relative reference -from utils import parse_args, get_image_file_list, draw_ser_results, get_bio_label_maps +from vqa_utils import parse_args, get_image_file_list, draw_ser_results, get_bio_label_maps -from utils import pad_sentences, split_page, preprocess, postprocess, merge_preds_list_with_ocr_info +from vqa_utils import pad_sentences, split_page, preprocess, postprocess, merge_preds_list_with_ocr_info MODELS = { 'LayoutXLM': diff --git a/ppstructure/vqa/infer_ser_re_e2e.py b/ppstructure/vqa/infer_ser_re_e2e.py index 32d8850a..e24c9f69 100644 --- a/ppstructure/vqa/infer_ser_re_e2e.py +++ b/ppstructure/vqa/infer_ser_re_e2e.py @@ -24,7 +24,7 @@ import paddle from paddlenlp.transformers import LayoutXLMModel, LayoutXLMTokenizer, LayoutXLMForRelationExtraction # relative reference -from utils import parse_args, get_image_file_list, draw_re_results +from vqa_utils import parse_args, get_image_file_list, draw_re_results from infer_ser_e2e import SerPredictor diff --git a/ppstructure/vqa/train_re.py b/ppstructure/vqa/train_re.py index 47d69467..eeff2bfb 100644 --- a/ppstructure/vqa/train_re.py +++ b/ppstructure/vqa/train_re.py @@ -27,7 +27,7 @@ import paddle from paddlenlp.transformers import LayoutXLMTokenizer, LayoutXLMModel, LayoutXLMForRelationExtraction from xfun import XFUNDataset -from utils import parse_args, get_bio_label_maps, print_arguments, set_seed +from vqa_utils import parse_args, get_bio_label_maps, print_arguments, set_seed from data_collator import DataCollator from eval_re import evaluate diff --git a/ppstructure/vqa/train_ser.py b/ppstructure/vqa/train_ser.py index 2670ef9e..22617205 100644 --- a/ppstructure/vqa/train_ser.py +++ b/ppstructure/vqa/train_ser.py @@ -32,7 +32,7 @@ from paddlenlp.transformers import LayoutXLMModel, LayoutXLMTokenizer, LayoutXLM from paddlenlp.transformers import LayoutLMModel, LayoutLMTokenizer, LayoutLMForTokenClassification from xfun import XFUNDataset -from utils import parse_args, get_bio_label_maps, print_arguments, set_seed +from vqa_utils import parse_args, get_bio_label_maps, print_arguments, set_seed from eval_ser import evaluate from losses import SERLoss from ppocr.utils.logging import get_logger diff --git a/ppstructure/vqa/utils.py b/ppstructure/vqa/vqa_utils.py similarity index 100% rename from ppstructure/vqa/utils.py rename to ppstructure/vqa/vqa_utils.py -- GitLab