-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
138 additions
and
248 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 |
---|---|---|
|
@@ -24,17 +24,6 @@ jobs: | |
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
|
||
- name: Unit testings | ||
run: | | ||
pip install -r requirements.txt | ||
pip install pytest | ||
wget https://github.com/RapidAI/TableStructureRec/releases/download/v0.0.0/lineless_table_rec_models.zip | ||
unzip lineless_table_rec_models.zip | ||
mv lineless_table_rec_models/*.onnx lineless_table_rec/models/ | ||
pytest tests/test_lore.py | ||
GenerateWHL_PushPyPi: | ||
needs: UnitTesting | ||
runs-on: ubuntu-latest | ||
|
@@ -54,11 +43,7 @@ jobs: | |
python -m pip install --upgrade pip | ||
pip install wheel get_pypi_latest_version | ||
wget https://github.com/RapidAI/TableStructureRec/releases/download/v0.0.0/lineless_table_rec_models.zip | ||
unzip lineless_table_rec_models.zip | ||
mv lineless_table_rec_models/*.onnx lineless_table_rec/models/ | ||
python setup_lineless.py bdist_wheel ${{ github.event.head_commit.message }} | ||
python setup.py bdist_wheel ${{ github.event.head_commit.message }} | ||
# - name: Publish distribution 📦 to Test 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,15 +1,14 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
from PIL import Image | ||
import cv2 | ||
|
||
from latex_to_image import LaTeXToImg | ||
|
||
render = LaTeXToImg() | ||
|
||
formula = "x^2 + y ^2 = 1" | ||
|
||
img_formula = render(formula) | ||
img_formula = Image.fromarray(img_formula) | ||
img_formula.save("res2.png") | ||
img = render(formula) | ||
cv2.imwrite("res.png", img) | ||
print("ok") |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
### See details for [latex_to_image](https://github.com/SWHL/latex_to_image) |
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,10 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
import argparse | ||
from typing import Optional | ||
|
||
import cv2 | ||
import numpy as np | ||
|
||
from .crop_img import CropByProject | ||
|
@@ -14,9 +18,29 @@ def __init__( | |
self.cropper = CropByProject() | ||
self.latex = RenderLaTeX() | ||
|
||
def __call__(self, math: str) -> np.ndarray: | ||
def __call__(self, math: Optional[str] = None) -> np.ndarray: | ||
if len(math.strip()) <= 0 or math is None: | ||
raise ValueError("The input of formula must have value.") | ||
|
||
img = self.latex(math) | ||
img = self.cropper(img) | ||
return img | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("math", type=str, default=None) | ||
parser.add_argument("save_path", type=str, default="res.png") | ||
args = parser.parse_args() | ||
|
||
render = LaTeXToImg() | ||
img = render(args.math) | ||
if img is not None: | ||
cv2.imwrite(args.save_path, img) | ||
print(f"The image has been saved in {args.save_path} .") | ||
else: | ||
print("The result of render formula is empty.") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,2 +1,2 @@ | ||
opencv_python_headless | ||
Pillow | ||
numpy |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# -*- encoding: utf-8 -*- | ||
# @Author: SWHL | ||
# @Contact: [email protected] | ||
import sys | ||
from pathlib import Path | ||
from typing import List | ||
|
||
import setuptools | ||
from get_pypi_latest_version import GetPyPiLatestVersion | ||
|
||
|
||
def read_txt(txt_path: str) -> List: | ||
if not isinstance(txt_path, str): | ||
txt_path = str(txt_path) | ||
|
||
with open(txt_path, "r", encoding="utf-8") as f: | ||
data = list(map(lambda x: x.rstrip("\n"), f)) | ||
return data | ||
|
||
|
||
def get_readme() -> str: | ||
root_dir = Path(__file__).resolve().parent | ||
readme_path = str(root_dir / "docs" / "doc_whl.md") | ||
with open(readme_path, "r", encoding="utf-8") as f: | ||
readme = f.read() | ||
return readme | ||
|
||
|
||
MODULE_NAME = "latex_to_image" | ||
|
||
obtainer = GetPyPiLatestVersion() | ||
try: | ||
latest_version = obtainer(MODULE_NAME) | ||
except ValueError: | ||
latest_version = "0.0.0" | ||
|
||
VERSION_NUM = obtainer.version_add_one(latest_version) | ||
|
||
if len(sys.argv) > 2: | ||
match_str = " ".join(sys.argv[2:]) | ||
matched_versions = obtainer.extract_version(match_str) | ||
if matched_versions: | ||
VERSION_NUM = matched_versions | ||
sys.argv = sys.argv[:2] | ||
|
||
setuptools.setup( | ||
name=MODULE_NAME, | ||
version=VERSION_NUM, | ||
platforms="Any", | ||
description="Use LaTeX compilation tools to convert formulas in LaTeX format into corresponding images.", | ||
long_description=get_readme(), | ||
long_description_content_type="text/markdown", | ||
author="SWHL", | ||
author_email="[email protected]", | ||
url="https://github.com/SWHL/CutVideo", | ||
license="MIT", | ||
include_package_data=True, | ||
install_requires=read_txt("requirements.txt"), | ||
packages=[MODULE_NAME], | ||
keywords=["moviepy,crop_video"], | ||
classifiers=[ | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
], | ||
python_requires=">=3.6,<3.12", | ||
entry_points={ | ||
"console_scripts": [ | ||
f"latex_to_image={MODULE_NAME}.main:main", | ||
], | ||
}, | ||
) |
Oops, something went wrong.