Download examples/basic.py from cwLeeDev/AIFlow-Math-Ink-0.5: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/cwLeeDev/AIFlow-Math-Ink-0.5/resolve/main/examples/basic.py
- Command line
-
hf download hf://cwLeeDev/AIFlow-Math-Ink-0.5/examples/basic.py
-
curl -L -o basic.py https://huggingface.co/cwLeeDev/AIFlow-Math-Ink-0.5/resolve/main/examples/basic.py
1.21 kB
| """AIFlow Math Ink 0.5μ JSON-like stroke μ λ ₯ μμ.""" | |
| from pathlib import Path | |
| from PIL import Image | |
| from aiflow_math_ink_05 import ( | |
| build_formula_grids, | |
| parse_writing_events, | |
| render_grid_images, | |
| ) | |
| def main() -> None: | |
| """νμ λ³μ: μμ stroke payload. μλ μ리: μμ μ μ λ§λ€κ³ UTF-8 κ²½λ‘ μλ PNGλ‘ μ μ₯νλ€.""" | |
| events = [ | |
| { | |
| "stroke_id": 0, | |
| "width": 3, | |
| "points": [{"x": 24, "y": 20}, {"x": 36, "y": 20}], | |
| }, | |
| { | |
| "stroke_id": 1, | |
| "width": 3, | |
| "points": [{"x": 10, "y": 42}, {"x": 60, "y": 42}], | |
| }, | |
| { | |
| "stroke_id": 2, | |
| "width": 3, | |
| "points": [{"x": 24, "y": 64}, {"x": 36, "y": 64}], | |
| }, | |
| ] | |
| strokes = parse_writing_events(events) | |
| grids = build_formula_grids(strokes) | |
| images = render_grid_images(Image.new("RGB", (80, 90), "white"), strokes, grids) | |
| output_directory = Path("outputs") | |
| output_directory.mkdir(exist_ok=True) | |
| for grid, image in zip(grids, images, strict=True): | |
| image.save(output_directory / f"cell-{grid.index}.png") | |
| if __name__ == "__main__": | |
| main() | |