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.3.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.3-py3-none-any.whl
(2.4 MB
view details)
File details
Details for the file ocra-0.1.3.tar.gz.
File metadata
- Download URL: ocra-0.1.3.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 |
05d944862c2c461d6958a0fa9d8766a92ab5f39c39dc80776fa46b4dc0f02474
|
|
| MD5 |
f1cc5d713f39e6e5ae7e34b17476d9d7
|
|
| BLAKE2b-256 |
a944b0bb5a722510e16f0eda8d16f20a032c9fd0b1cf2d1331c31c2f835bf4a4
|
File details
Details for the file ocra-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ocra-0.1.3-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 |
17229f1c59a051fe8c22a04ec9b1f7177e2de119fb92adc88fe166c3827ee35c
|
|
| MD5 |
a46b8cbc596970a11a1aa6c11adafa60
|
|
| BLAKE2b-256 |
f617aecc01040758c7710671c77fe37774a3334e60ac9ee2c4dfeed9e3118376
|