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.4.tar.gz
(2.4 MB
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.4-py3-none-any.whl
(2.4 MB
view details)
File details
Details for the file ocra-0.1.4.tar.gz.
File metadata
- Download URL: ocra-0.1.4.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a4c9b89041e9a5cae439b3f891e5130bcf2ae2318340330ccd08a51ae9a45c1
|
|
| MD5 |
9fbcdfa60a5c4123e987a5f8884e7312
|
|
| BLAKE2b-256 |
e3bf094aeee8da2821d6fa001d106a2c08264bdf562175fce29e86a865ee043e
|
File details
Details for the file ocra-0.1.4-py3-none-any.whl.
File metadata
- Download URL: ocra-0.1.4-py3-none-any.whl
- Upload date:
- Size: 2.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
304dcc567d6ffbba7796892ab88b887ebb0be696ef071151ee9d6acd40155726
|
|
| MD5 |
887c10cd2be581beea1f3f7f574eecab
|
|
| BLAKE2b-256 |
dc73e9e5023806eb8d7525a6102f04b2a1a8edeb77ff51a66bb0b395122654f8
|