Skip to main content

ocra: toolbox for analyzing text fragments (OrientationPredictor).

Project description

ocra

ocra — Python-библиотека с инструментами анализа фрагментов печатного текста (сканы, вырезки и т.п.). Первый инструмент — OrientationPredictor:

Установка

pip install ocra

OrientationPredictor

Определяет ориентацию фрагмента как HORZ (горизонт) или VERT (вертикаль). Объяснение OrientationPredictor Пример:

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.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ocra-0.1.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file ocra-0.1.1.tar.gz.

File metadata

  • Download URL: ocra-0.1.1.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

Hashes for ocra-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b8782f4a7e9b1ad4adc0b7e537c9760ea020fafff5910eb6ba68821fbdc1adf3
MD5 d33c9fe3637ea690eefae23d99cf5663
BLAKE2b-256 1e7e5193961b9d3032c1bae84d8aaeb341afc6224ff3572b0f9672b196f503cd

See more details on using hashes here.

File details

Details for the file ocra-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: ocra-0.1.1-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

Hashes for ocra-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b06218691a55370c937ebcb218bba079a794ad29167ae08fdefa52434684314c
MD5 bed4380f275b39a801e66249e1ce9c44
BLAKE2b-256 cb043f267fbbb83e89f700ec3ddaecc29bc9096877f02da4653d59be19279426

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page