-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fix encode error when reading yaml
- Loading branch information
Showing
7 changed files
with
55 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,6 @@ name: Push rapid_latex_ocr to pypi | |
|
||
on: | ||
push: | ||
# branches: [ main ] | ||
# paths: | ||
# - 'rapid_latex_ocr/**' | ||
# - 'docs/doc_whl.md' | ||
# - 'setup.py' | ||
# - '.github/workflows/gen_whl_to_pypi.yml' | ||
tags: | ||
- v* | ||
|
||
|
@@ -51,14 +45,7 @@ jobs: | |
pip install -r requirements.txt | ||
python -m pip install --upgrade pip | ||
pip install wheel get_pypi_latest_version | ||
python setup.py bdist_wheel ${{ github.ref_name }} | ||
# - name: Publish distribution 📦 to Test PyPI | ||
# uses: pypa/[email protected] | ||
# with: | ||
# password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
# repository_url: https://test.pypi.org/legacy/ | ||
# packages_dir: dist/ | ||
python setup.py bdist_wheel "${{ github.ref_name }}" | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
from rapid_latex_ocr import LatexOCR | ||
from rapid_latex_ocr import LaTeXOCR | ||
|
||
model = LatexOCR() | ||
model = LaTeXOCR() | ||
|
||
img_path = "tests/test_files/6.png" | ||
with open(img_path, "rb") as f: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
from .main import LatexOCR | ||
from .main import LaTeXOCR | ||
|
||
__all__ = ["LatexOCR"] | ||
__all__ = ["LaTeXOCR"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
import io | ||
from pathlib import Path | ||
from typing import List, Union, Optional | ||
from typing import List, Optional, Union | ||
|
||
import chardet | ||
import cv2 | ||
import numpy as np | ||
import requests | ||
import tqdm | ||
from PIL import Image | ||
from tokenizers import Tokenizer | ||
from tokenizers.models import BPE | ||
import requests | ||
import tqdm | ||
import io | ||
|
||
|
||
class PreProcess: | ||
|
@@ -171,6 +172,17 @@ def save_file(save_path: Union[str, Path], file: bytes): | |
f.write(file) | ||
|
||
|
||
def get_file_encode(file_path: Union[str, Path]) -> str: | ||
try: | ||
with open(file_path, "rb") as f: | ||
raw_data = f.read(100) | ||
result = chardet.detect(raw_data) | ||
encoding = result["encoding"] | ||
return encoding | ||
except Exception: | ||
return "utf-8" | ||
|
||
|
||
if __name__ == "__main__": | ||
downloader = DownloadModel() | ||
downloader("decoder.onnx") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters