use onnx models, new deepdoc (#68)

This commit is contained in:
KevinHuSh
2024-02-21 16:32:38 +08:00
committed by GitHub
parent 8c4ec9955e
commit cacd36c5e1
26 changed files with 8730 additions and 136 deletions

View File

@ -1,16 +1,27 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import copy
import re
from io import BytesIO
from docx import Document
from rag.parser import bullets_category, is_english, tokenize, remove_contents_table, hierarchical_merge, \
from deepdoc.parser import bullets_category, is_english, tokenize, remove_contents_table, hierarchical_merge, \
make_colon_as_title
from rag.nlp import huqie
from rag.parser.docx_parser import HuDocxParser
from rag.parser.pdf_parser import HuParser
from deepdoc.parser import PdfParser, DocxParser
from rag.settings import cron_logger
class Docx(HuDocxParser):
class Docx(DocxParser):
def __init__(self):
pass
@ -35,7 +46,7 @@ class Docx(HuDocxParser):
return [l for l in lines if l]
class Pdf(HuParser):
class Pdf(PdfParser):
def __call__(self, filename, binary=None, from_page=0,
to_page=100000, zoomin=3, callback=None):
self.__images__(
@ -47,7 +58,7 @@ class Pdf(HuParser):
from timeit import default_timer as timer
start = timer()
self._layouts_paddle(zoomin)
self._layouts_rec(zoomin)
callback(0.77, "Layout analysis finished")
cron_logger.info("paddle layouts:".format((timer()-start)/(self.total_page+0.1)))
self._naive_vertical_merge()