Saravanan666/pypi-org huggingface dataset:
Package: ocraccuracyreporter
============Overview============Your OCR pipeline may have various stages and may use various tools.You need a simple way to run sample/s as a whole or piece by piece and have a way to say that the OCR accuracy is say 98%.=========Usage=========>>> pip install ocraccuracyreporter>>> from ocraccuracyreporter.oar import oar.. topic:: initialising the reporter>>> oreport = oar(expected='john', given='joh', label='name')>>> print(oreport)>>> name,john,joh,86,100,86,86,94,1or you may have various ocr results for the same item, so you may want to initialise the expected alonewith or without a label>>> oreport = oar(expected='john', label='name')>>> oreport.given = 'joh'>>> repr(oreoprt)if you are creating a csv report with header info>>>label,expected,given,ratio,partial_ratio,token_sort_ratio,token_set_ratio,jaro_winkler,distancename,john,joh,86,100,86,86,94,1.. topic:: Items in the reportratio - uses pure Levenshtein Distance based matching(100 - means perfect match)partial_ratio - matches based on best substringstoken_sort_ratio - tokenizes the strings and sorts them alphabeticallytoken_set_ratio - tokenizes the strings and compared the intersectionjaro_winkler - this algorithm giving more weight to common prefix(for example, some parts are good, missing others)distance - this shows how many characters are really different in givencompared to expected=========Class variables=========label  - a meaningful name for the ocr string.expected - expected resultgiven - result you got out of ocr pipelinetotal_expected_char_count - calculated expected char counttotal_expected_word_count - calculated expected word counttotal_given_char_count - calculated given char counttotal_given_word_count - calculated given word count
Package: ocrd-calamari
ocrd_calamariRecognize text usingCalamari OCR.Introductionocrd_calamarioffers aOCR-Dcompliant workspace processor for the functionality of Calamari OCR. It uses OCR-D workspaces (METS) withPAGE XMLdocuments as input and output.This processor only operates on the text line level and so needs a line segmentation (and by extension a binarized
image) as its input.In addition to the line text it may also output word and glyph segmentation
including per-glyph confidence values and per-glyph alternative predictions as
provided by the Calamari OCR engine, using atextequiv_levelofwordorglyph. Note that while Calamari does not provide word segmentation, this
processor produces word segmentation inferred from text
segmentation and the glyph positions. The provided glyph and word segmentation
can be used for text extraction and highlighting, but is probably not useful for
further image-based processing.InstallationFrom PyPIpip install ocrd_calamariFrom Repopipinstall.Install modelsDownload models trained on GT4HistOCR data:make gt4histocr-calamari1
ls gt4histocr-calamari1Manual download:model.tar.xzExample UsageBefore usingocrd-calamari-recognizeget some example data and model, and
prepare the document for OCR:# Download model and example data
make gt4histocr-calamari1
make actevedef_718448162

# Create binarized images and line segmentation using other OCR-D projects
cd actevedef_718448162
ocrd-olena-binarize -P impl sauvola-ms-split -I OCR-D-IMG -O OCR-D-IMG-BIN
ocrd-tesserocr-segment-region -I OCR-D-IMG-BIN -O OCR-D-SEG-REGION
ocrd-tesserocr-segment-line -I OCR-D-SEG-REGION -O OCR-D-SEG-LINEFinally recognize the text using ocrd_calamari and the downloaded model:ocrd-calamari-recognize -P checkpoint_dir "../gt4histocr-calamari1" -I OCR-D-SEG-LINE -O OCR-D-OCR-CALAMARIYou may want to have a look at theocrd-tool.jsondescriptions
for additional parameters and default values.Development & TestingFor information regarding development and testing, please seeREADME-DEV.md.
Package: ocrd-fork-bagit-profile
DescriptionA simple Python module for validating BagIt profiles. See theBagIt
Profiles Specificationfor more information.This module is intended for use withbagit-pythonbut does not extend it.Installationbagit_profile.pyis a single-file python module that you can drop into
your project as needed or you can install globally with:git clonehttps://github.com/bagit-profiles/bagit-profiles-validator.gitcdbagit-profiles-validatorsudo python setup.py installor:pip install bagit_profileUsageimportbagitimportbagit_profileInstantiate an existing Bag usingbagit.python bag =bagit.Bag('mydir')Instantiate a profile, supplying its URI.python my_profile =bagit_profile.Profile('http://example.com/bagitprofile.json')Validate ‘Serialization’ and ‘Accept-Serialization’. This must be done
before .validate(bag) is called. ‘mydir’ is the path to the Bag.ifmy_profile.validate_serialization('mydir'):print"Serialization validates"else:print"Serialization does not validate"Validate the rest of the profile.ifmy_profile.validate(bag):print"Validates"else:print"Does not validate"Or from the commandline:bagit_profile.py'http://uri.for.profile/profile.json'path/to/bagTest suitepython setup.py testDevelopmentFork the
repositoryDo something awesome!Submit a pull
requestexplianing what your code doesLicenseCC0
Package: ocrd-fork-dinglehopper
dinglehopperdinglehopper is an OCR evaluation tool and readsALTO,PAGEand text files.  It
compares a ground truth (GT) document page with a OCR result page to compute
metrics and a word/character differences report.GoalsUsefulAs a UI toolFor an automated evaluationAs a libraryUnicode supportInstallationIt's best to use pip, e.g.:sudo pip install .UsageUsage: dinglehopper [OPTIONS] GT OCR [REPORT_PREFIX]

  Compare the PAGE/ALTO/text document GT against the document OCR.

  dinglehopper detects if GT/OCR are ALTO or PAGE XML documents to extract
  their text and falls back to plain text if no ALTO or PAGE is detected.

  The files GT and OCR are usually a ground truth document and the result of
  an OCR software, but you may use dinglehopper to compare two OCR results.
  In that case, use --no-metrics to disable the then meaningless metrics and
  also change the color scheme from green/red to blue.

  The comparison report will be written to $REPORT_PREFIX.{html,json}, where
  $REPORT_PREFIX defaults to "report". The reports include the character
  error rate (CER) and the word error rate (WER).

  By default, the text of PAGE files is extracted on 'region' level. You may
  use "--textequiv-level line" to extract from the level of TextLine tags.

Options:
  --metrics / --no-metrics  Enable/disable metrics and green/red
  --textequiv-level LEVEL   PAGE TextEquiv level to extract text from
  --progress                Show progress bar
  --help                    Show this message and exit.For example:dinglehopper some-document.gt.page.xml some-document.ocr.alto.xmlThis generatesreport.htmlandreport.json.dinglehopper-extractThe tooldinglehopper-extractextracts the text of the given input file on
stdout, for example:dinglehopper-extract --textequiv-level line OCR-D-GT-PAGE/00000024.page.xmlOCR-DAs a OCR-D processor:ocrd-dinglehopper -I OCR-D-GT-PAGE,OCR-D-OCR-TESS -O OCR-D-OCR-TESS-EVALThis generates HTML and JSON reports in theOCR-D-OCR-TESS-EVALfilegroup.The OCR-D processor has these parameters:ParameterMeaning-P metrics falseDisable metrics and the green-red color scheme (default: enabled)-P textequiv_level line(PAGE) Extract text from TextLine level (default: TextRegion level)For example:ocrd-dinglehopper -I ABBYY-FULLTEXT,OCR-D-OCR-CALAMARI -O OCR-D-OCR-COMPARE-ABBYY-CALAMARI -P metrics falseDeveloper informationPlease refer toREADME-DEV.md.
Package: ocrd-fork-pylsd
pylsd1. Introductionpylsd is the python bindings forLSD - Line Segment Detector.2. InstallThis package uses distutils, which is the default way of installing python modules. To install in your home directory, securely run the following:git clone https://github.com/primetang/pylsd.git
cd pylsd
python setup.py installOr directly throughpipto install it:pip install pylsd3. UsageWe can use the package by usingfrom pylsd.lsd import lsd, andlines = lsd(src)is the call format for thelsdfunction, wheresrcis a Grayscale Image (H * Wnumpy.array), and the return valuelinesis the Detected Line Segment,linesis anN * 5numpy.array, each row represents a straight line, the 5-dimensional vector is:[point1.x, point1.y, point2.x, point2.y, width]According to these presentations, we can use it just like the following code (here is the link):by using cv2 moduleimportcv2importnumpyasnpimportosfrompylsd.lsdimportlsdfullName='car.jpg'folder,imgName=os.path.split(fullName)src=cv2.imread(fullName,cv2.IMREAD_COLOR)gray=cv2.cvtColor(src,cv2.COLOR_BGR2GRAY)lines=lsd(gray)foriinxrange(lines.shape[0]):pt1=(int(lines[i,0]),int(lines[i,1]))pt2=(int(lines[i,2]),int(lines[i,3]))width=lines[i,4]cv2.line(src,pt1,pt2,(0,0,255),int(np.ceil(width/2)))cv2.imwrite(os.path.join(folder,'cv2_'+imgName.split('.')[0]+'.jpg'),src)by using PIL(Image) modulefromPILimportImage,ImageDrawimportnumpyasnpimportosfrompylsd.lsdimportlsdfullName='house.png'folder,imgName=os.path.split(fullName)img=Image.open(fullName)gray=np.asarray(img.convert('L'))lines=lsd(gray)draw=ImageDraw.Draw(img)foriinxrange(lines.shape[0]):pt1=(int(lines[i,0]),int(lines[i,1]))pt2=(int(lines[i,2]),int(lines[i,3]))width=lines[i,4]draw.line((pt1,pt2),fill=(0,0,255),width=int(np.ceil(width/2)))img.save(os.path.join(folder,'PIL_'+imgName.split('.')[0]+'.jpg'))The following is the result:car.jpg by using cv2 modulehouse.png by using PIL(Image) module
Package: ocrd-froc
ocrd_frocPerform font classification and text recognition (in one step) on historic documents.> Open and deserialize PAGE input files and their respective images,
> iterating over the element hierarchy down to the text line level.

> Then for each line, retrieve the raw image and feed it to the font
> classifier and/or the  OCR.

> Annotate font predictions by name and score as a comma-separated
> list under ``./TextStyle/@fontFamily``, if any.

> Annotate the text prediction as a string under ``./TextEquiv``.

> If ``method`` is `adaptive`, then use `SelOCR` if font classification is confident
> enough, otherwise use `COCR`.

> Finally, produce a new PAGE output file by serialising the resulting hierarchy.InstallationModelsDefaultThe default.froc model is composed of a SelOCR network and a COCR
architecture, and is trained to classify and OCR textlines on the following 12 classes:AntiquaBastardaFrakturTexturaSchwabacherGreek*ItalicHebrew*Gotico-antiquaManuscript*RotundaNo class/Ignore* Greek, Hebrew and Manuscript font groups do not currently provide good
results due to a lack of training data.UsageOCR-D processor interface ocrd-frocTo be used with PAGE-XML documents in an OCR-D annotation workflow.Parameters:

   "ocr_method" [string - "none"]
    The method to use for text recognition
    Possible values: ["none", "SelOCR", "COCR", "adaptive"]
   "replace_textstyle" [bool - true]
    Whether to replace existing textStyle
   "network" [string]
    The file name of the neural network to use, including sufficient path
    information. Defaults to the model bundled with ocrd_froc.
   "fast_cocr" [boolean - true]
    Whether to use optimization steps on the COCR strategy
   "adaptive_treshold" [number - 95]
    Treshold of certitude needed to use SelOCR when using the adaptive
    strategy
   "font_class_priors" [array - []]
    List of font classes which are known to be present on the data when
    using the adaptive/SelOCR strategies. When this option is specified,
    every font classes not included will be ignored. If 'other' is
    included in the list, font classification will not be outputted and
    a generic model will be used for transcriptions.
Package: ocrd-kraken
ocrd_krakenOCR-D wrapper for the Kraken OCR engineIntroductionThis package offersOCR-Dcompliantworkspace processorsfor (some of) the functionality ofKraken.(Each processor is a parameterizable step in a configurableworkflowof theOCR-D functional model.
There are usually various alternative processor implementations for each step.
Data is represented withMETSandPAGE.)It includes image preprocessing (binarization), layout analysis (region and line+baseline segmentation), and text recognition.InstallationWith DockerThis is the best option if you want to run the software in a container.You need to haveDockerdocker pull ocrd/krakenTo run with Docker:docker run -v path/to/workspaces:/data ocrd/kraken ocrd-kraken-recognize ...Native, from PyPIThis is the best option if you want to use the stable, released version.pip install ocrd_krakenNative, from gitUse this option if you want to change the source code or install the latest, unpublished changes.We strongly recommend to usevenv.git clone https://github.com/OCR-D/ocrd_kraken
cd ocrd_kraken
sudo make deps-ubuntu # or manually from git or via ocrd_all
make deps        # or pip install -r requirements.txt
make install     # or pip install .ModelsKraken uses data-driven (neural) models for segmentation and recognition, but comes with no pretrained "official" models.
There is apublic repositoryof community-provided models, which can also
be queried and downloaded from viakrakenstandalone CLI.
(SeeKraken docsfor details.)For the OCR-D wrapper, since all OCR-D processors must resolve file/data resources in astandardized way, there is a general mechanism for managing models, i.e. installing and using them by name. We currently manage our own list of recommended models (without delegating to the above repo).Models always use the filename suffix.mlmodel, but are just loaded by their basename.See theOCR-D model guideandocrd resmgr --helpUsageFor details, see docstrings in the individual processors andocrd-tool.jsondescriptions,
or simply--help.AvailableOCR-D processorsare:ocrd-kraken-binarize(nlbin – not recommended)addsAlternativeImagefiles (per page, region or line) to the output fileGrpocrd-kraken-segment(all-in-one segmentation – recommended for handwriting and simply layouted prints)addsTextRegions,TableRegions,ImageRegions,MathsRegions,NoiseRegions,ReadingOrderandAlternativeImagetoPage(depending on model training)addsTextLines toTextRegions, including theirBaselineocrd-kraken-recognizeaddsWords toTextLinesaddsGlyphs toWordsaddsTextEquivTestingmake testThis downloads test data fromhttps://github.com/OCR-D/assetsunderrepo/assets, and runs some basic tests of the Python API.SetPYTEST_ARGS="-s --verbose"to see log output (-s) and individual test results (--verbose).
Package: ocrd-pc-segmentation
page-segmentation module for OCR-dIntroductionThis module implements a page segmentation algorithm based on a Fully
Convolutional Network (FCN). The FCN creates a classification for each pixel in
a binary image. This result is then segmented per class using XY cuts.RequirementsFor GPU-Support:CUDAandCUDNNother requirements are installed via Makefile / pip, seerequirements.txtin repository root.InstallationIf you want to use GPU support, set the environment variableTENSORFLOW_GPUto a nonempty value, otherwise leave it unset. Then:makedepsto install dependencies andmakeinstallto install the package.Both are python packages installed via pip, so you may want to activate
a virtalenv before installing.Usageocrd-pc-segmentationfollows theocrd CLI.It expects a binary page image and produces region entries in the PageXML file.ConfigurationThe following parameters are recognized in the JSON parameter file:overwrite_regions: remove previously existing text regionsxheight: height of character "x" in pixels used during training.model: pixel-classifier model path. The special values__DEFAULT__and__LEGACY__load the bundled default model or previous default model respectively.gpu_allow_growth: required for GPU use with some graphic cards
(set to true, if you get CUDNN_INTERNAL_ERROR)resize_height: scale down pixelclassifier output to this height before postprocessing. Independent of training / used model.
(performance / quality tradeoff, defaults to 300)TestingThere is a simple CLI test, that will run the tool on a single image from the assets repository.make test-cliTrainingTo train models for the pixel classifier, seeits README
Package: ocrd-publaynet
ocrd_publaynetconvert PubLayNet data into METS/PAGE-XMLIntroductionThis offersOCR-Dcompliant (i.e.METS-XML/PAGE-XMLbased) conversion forPubLayNetor similar,MS-COCO-based, ground-truth data.InstallationSystem packagesInstall GNUmakeandwgetif you wish to use the Makefile.# on Debian / Ubuntu:
sudo apt install make wgetInstall Python3 regardless:# on Debian / Ubuntu:
sudo apt install python3 python3-pip python3-venvEquivalently:# on Debian / Ubuntu:
sudo make deps-ubuntuPython packagesIt is strongly recommended to usevenv. You can create and install a virtual environment of your own (which the Makefile will re-use when activated), or have the Makefile do that for you.pip install -r requirements.txt
pip install .Equivalently:make installUsagecommand-line interfaceocrd-import-mscocoOnce installed, the following executable becomes available:Usage: ocrd-import-mscoco [OPTIONS] COCOFILE DIRECTORY

  Convert MS-COCO JSON to METS/PAGE XML files.

  Load JSON ``cocofile`` (in MS-COCO format) and chdir to ``directory``
  (which it refers to).

  Start a METS file mets.xml with references to the image files (under
  fileGrp ``OCR-D-IMG``) and their corresponding PAGE-XML annotations (under
  fileGrp ``OCR-D-GT-SEG-BLOCK``), as parsed from ``cocofile`` and written
  using the same basename.

Options:
  --help  Show this message and exit.apply onPubLayNetTo apply on the validation subsection:ocrd-import-mscoco publaynet/val.json publaynet/valThis will create a METSpublaynet/val/mets.xmland PAGE filespublaynet/val/*.xmlfor all image files.To apply on the training subsection:ocrd-import-mscoco publaynet/train.json publaynet/trainThis will create a METSpublaynet/train/mets.xmland PAGE filespublaynet/train/*.xmlfor all image files.Equivalently (including download/extraction if necessary):make convertNote: PubLayNet itself requires approximately 103 GB of disk space. If you already have it (elsewhere), but still wish to use the Makefile to convert the files, make sure to symlink it here, so it does not get downloaded twice:ln -s your/path/to/publaynet publaynetall Makefile targetsRules to install ocrd-import-mscoco, and to use it on
PubLayNet (by downloading, extracting and converting).

Targets:
	help: this message
	deps-ubuntu: install system dependencies for Ubuntu
	all: alias for `install download convert`
	install: alias for `pip install .`
	download: alias for `publaynet.tar.gz`
	convert: alias for `publaynet/val/mets.xml publaynet/train/mets.xml`
	uninstall: alias for `pip uninstall ocrd_publaynet`
	clean-xml: remove results of conversion (METS and PAGE files in `publaynet`)
	clean: remove `publaynet` altogether

Variables:
	VIRTUAL_ENV: absolute path to (re-)use for the virtual environment
	PYTHON: name of the Python binary
	PIP: name of the Python packaging binary
Package: ocrd-segment
ocrd_segmentThis repository aims to provide a number ofOCR-Dcompliantprocessorsfor layout analysis and evaluation.InstallationIn yourPython virtual environment, run:pip install ocrd_segmentUsageContains processors for various tasks:exporting segment images (including results from preprocessing like cropping/masking, deskewing, dewarping or binarization) along with polygon coordinates and metadata:ocrd-segment-extract-pages(for pages, also exportsMS-COCOformat and pageview plots)ocrd-segment-extract-regions(for regions, also exportsMS-COCOformat))ocrd-segment-extract-lines(for lines, also exports text and .xlsx)ocrd-segment-extract-words(for words, also exports text)ocrd-segment-extract-glyphs(for glyphs, also exports text)importing layout segmentations from other formats:ocrd-segment-from-masks(for mask/label images, i.e. semantic segmentation)ocrd-segment-from-coco(forMS-COCOannotation)post-processing or repairing layout segmentations:ocrd-segment-repair(validity and consistency of all coordinates; also, for regions, reduce overlaps/redundancy between neighbours, and/or simplify polygons, and/or shrink to the alpha shape of foreground contours)ocrd-segment-project(remake segment coordinates into the concave hull / alpha shape of their constituents)ocrd-segment-replace-original(rebase all segments on cropped+deskewed border frame as new full page)ocrd-segment-replace-page(2 input fileGrps; overwrite segmentation below page of first fileGrp by all segments of second fileGrp, rebasing all coordinates; "inverse" ofreplace-original)ocrd-segment-replace-text(insert text below page from single-segment text files; "inverse" ofextract-*)comparing different layout segmentations:ocrd-segment-evaluate:construction: (2 input fileGrps; align, compare and evaluate page segmentations; early stage)page-segment-evaluate(same with standalone CLI)pattern-based segmentation (input file groups N=1, based on a PAGE template, e.g. from Aletheia, and some XSLT or Python to apply it to the input file group)ocrd-segment-via-template:construction: (unpublished)data-driven segmentation (input file groups N=1, based on a statistical model, e.g. Neural Network)ocrd-segment-via-model:construction: (unpublished)For detailed behaviour, see--helpon each processor CLI.
For detailed description on input/output and parameters, seeocrd-tool.jsonor--dump-jsonon each processor CLI.TestingNone yet.
Package: ocredis
ocredis is a wrapper for the popular [redis-py](https://github.com/andymccurdy/redis-py)ocredis provides observability using OpenCensus for distributed tracing and metrics.Installing itpipinstallocredisUsing itYou can initialize exactly how you would for redis.Redis.
In fact it is meant to be a drop replacement.Change the import statement from>>>importredisto>>>importocredisChange the client initialization from>>>client=redis.Redis(host=host,port=port)to>>>client=ocredis.OcRedis(host=host,port=port)`and obviously enabling OpenCensus metrics and exporters as perhttps://opencensus.io/exporters/supported-exporters/python/>>>ocredis.register_views()and the rest is trivial to use then.For example>>>importocredis>>>ocredis.register_views()>>>r=ocredis.OcRedis(host='localhost',port=6379)>>>r.set('foo','bar')True>>>r.get('foo')'bar'Metrics availablecallslatencykey_lengthvalue_lengthMetricView NameUnitTagsLatencyredispy/latencyms‘error’, ‘method’, ‘status’Callsredispy/calls1‘error’, ‘method’, ‘status’Key lengthsredispy/key_lengthBy‘error’, ‘method’, ‘status’Value lengthsredispy/value_lengthBy‘error’, ‘method’, ‘status’TestsTests can be run by using pytest, for examplepytest
Package: ocrer
ocrerWhat is this?by: axinerocrerThis is a ocrer.InstallationThis package can be installed using pip (Python3):pip install ocrerCopyrightCopyright (c) 2022 axinerPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.