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.2.tar.gz
(11.5 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.2-py3-none-any.whl
(12.9 kB
view details)
File details
Details for the file ocra-0.1.2.tar.gz.
File metadata
- Download URL: ocra-0.1.2.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6924081bc703c8e26082cebde743830dd474a14e2bdf0f895ad0d2a7b92037af
|
|
| MD5 |
23e261f779e514b31cc352c056412c77
|
|
| BLAKE2b-256 |
d710f7f2ca3ea523d947b7143645adad079dbfe6d11c330da09f45b3bbb84a4e
|
File details
Details for the file ocra-0.1.2-py3-none-any.whl.
File metadata
- Download URL: ocra-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.9 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 |
119c0702fe68ce36256101d05894d6999a402e80d649eab54534e62e790e99cb
|
|
| MD5 |
94b85fb9a36d2532651202f7694c32a2
|
|
| BLAKE2b-256 |
60b42312ce3f51ef33dbbcd61f55a29c8354fc45d93056166c5d12e88e9e1399
|