Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… latexocr_paddle
  • Loading branch information
liuhongen1234567 committed Jul 22, 2024
2 parents ac5d6c1 + c556b90 commit 357bdf3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
13 changes: 12 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@
# 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.
from .paddleocr import *
from .paddleocr import (
PaddleOCR,
PPStructure,
draw_ocr,
draw_structure_result,
save_structure_res,
download_with_progressbar,
sorted_layout_boxes,
convert_info_docx,
to_excel,
)
import importlib.metadata as importlib_metadata

try:
__version__ = importlib_metadata.version(__package__ or __name__)
except importlib_metadata.PackageNotFoundError:
__version__ = "0.0.0"

__all__ = [
"PaddleOCR",
"PPStructure",
Expand Down
9 changes: 4 additions & 5 deletions paddleocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
sys.path.append(os.path.join(__dir__, ""))

import cv2
from copy import deepcopy
import logging
import numpy as np
from pathlib import Path
Expand Down Expand Up @@ -64,6 +65,7 @@ def _import_file(module_name, file_path, make_importable=False):
from tools.infer.utility import draw_ocr, str2bool, check_gpu
from ppstructure.utility import init_args, draw_structure_result
from ppstructure.predict_system import StructureSystem, save_structure_res, to_excel
from ppstructure.recovery.recovery_to_doc import sorted_layout_boxes, convert_info_docx

logger = get_logger()

Expand All @@ -75,6 +77,8 @@ def _import_file(module_name, file_path, make_importable=False):
"save_structure_res",
"download_with_progressbar",
"to_excel",
"sorted_layout_boxes",
"convert_info_docx",
]

SUPPORT_DET_MODEL = ["DB"]
Expand Down Expand Up @@ -991,18 +995,13 @@ def main():
save_structure_res(result, args.output, img_name, index)

if args.recovery and result != []:
from copy import deepcopy
from ppstructure.recovery.recovery_to_doc import sorted_layout_boxes

h, w, _ = img.shape
result_cp = deepcopy(result)
result_sorted = sorted_layout_boxes(result_cp, w)
all_res += result_sorted

if args.recovery and all_res != []:
try:
from ppstructure.recovery.recovery_to_doc import convert_info_docx

convert_info_docx(img, all_res, args.output, img_name)
except Exception as ex:
logger.error(
Expand Down
2 changes: 1 addition & 1 deletion tools/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def train(
and dist.get_rank() == 0
):
if model_average:
Model_Average = paddle.incubate.optimizer.ModelAverage(
Model_Average = paddle.incubate.ModelAverage(
0.15,
parameters=model.parameters(),
min_average_window=10000,
Expand Down

0 comments on commit 357bdf3

Please sign in to comment.