Download smoke_test.py from openmodelai/Imagt: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/openmodelai/Imagt/resolve/main/smoke_test.py
- Command line
-
hf download hf://openmodelai/Imagt/smoke_test.py
-
curl -L -o smoke_test.py https://huggingface.co/openmodelai/Imagt/resolve/main/smoke_test.py
1.08 kB
| """Smoke-тест Image: извлечение весов (если нужно) + OCR примера. | |
| Запуск: | |
| python tests/smoke_test.py | |
| """ | |
| from __future__ import annotations | |
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT)) | |
| from image_text import ImageEngine # noqa: E402 | |
| SAMPLE = ROOT / "examples" / "sample.png" | |
| def main() -> int: | |
| model_dir = ROOT / "model" | |
| if not (model_dir / "ch_PP-OCRv4_det_infer.onnx").exists(): | |
| print("Веса не найдены — извлекаю scripts/build_model.py ...") | |
| subprocess.run([sys.executable, str(ROOT / "scripts" / "build_model.py")], check=True) | |
| engine = ImageEngine() | |
| result = engine.ocr(SAMPLE) | |
| text = result["text"] | |
| print("Извлеченный текст:", repr(text)) | |
| for needle in ("Hello", "World", "123"): | |
| assert needle in text, f"В результатах нет «{needle}»" | |
| print("SMOKE TEST OK") | |
| return 0 | |
| if __name__ == "__main__": | |
| sys.exit(main()) | |