ocra: toolbox for analyzing text fragments (OrientationPredictor).
Project description
ocra
ocra — Python-библиотека с инструментами анализа фрагментов печатного текста (сканы, вырезки и т.п.).
Первый инструмент — OrientationPredictor:
Установка
pip install ocra
OrientationPredictor
Определяет ориентацию фрагмента как HORZ (горизонт) или VERT (вертикаль).
Пример:
from ocra import OrientationPredictor
IMAGE_PATH = r"examples\hrk_463.png"
def main():
model = OrientationPredictor()
result = model.predict_path(IMAGE_PATH)
label = "VERT" if result["pred"] == 1 else "HORZ"
print("Path:", result["path"])
print("Pred:", label, f"(class={result['pred']})")
print(f"Prob VERT: {result['prob_vert']:.4f}")
print(f"Prob HORZ: {result['prob_horz']:.4f}")
print(f"Aspect (w/h): {result['aspect']:.4f}")
if __name__ == "__main__":
main()
Пример вывода:
Path: examples\hrk_463.png
Pred: HORZ (class=0)
Prob VERT: 0.0001
Prob HORZ: 0.9999
Aspect (w/h): 6.5926
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ocra-0.1.0.tar.gz
(11.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ocra-0.1.0-py3-none-any.whl
(12.8 kB
view details)
File details
Details for the file ocra-0.1.0.tar.gz.
File metadata
- Download URL: ocra-0.1.0.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de88e372edda677a3c193452f17d22e93d58a4dcf0e6d4745c5fa58588d48493
|
|
| MD5 |
2c7c4de2db07d83c23760f2107202b36
|
|
| BLAKE2b-256 |
70f60133629560852b5c0afd6ebb8f7cbcce77b96d5f6faf404d4317ece61f4a
|
File details
Details for the file ocra-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ocra-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7d81e441d01d5e61bb1a2fe876e68dd93ff81efc493f3dc3e94f8f6272637c7
|
|
| MD5 |
4488fd1655aa90c47f10b846a1a0e06d
|
|
| BLAKE2b-256 |
d2d4138521ad21d2a8fb90e83bef841b85a1344935b5d455eaac51041a6b0bac
|