• Stars
    star
    169
  • Rank 223,196 (Top 5 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Apply different text recognition services to images of handwritten documents.

Handprint

The Handwritten Page Recognition Test is a command-line program that invokes HTR (handwritten text recognition) services on images of document pages. It can produce annotated images showing the results, compare the recognized text to expected text, save the HTR service results as JSON and text files, and more.

Latest release License Python GitHub stars DOI PyPI

Table of Contents

Introduction

Handprint (Handwritten Page Recognition Test) is a tool for comparing alternative services for offline handwritten text recognition (HTR). It was developed for use with documents from the Caltech Archives, but it is completely independent and can be applied to any images of text documents.

Handprint can generate images with recognized text overlaid over them to visualize the results. The image at right shows an example. Among other features, the software can also display bounding boxes, threshold results by confidence values, compare full-text results to expected/ground-truth results, and output the raw results from an HTR service as JSON and text files. It can work with individual images, directories of images, and URLs pointing to images on remote servers. Finally, Handprint can use multiple processor threads for parallel execution.

Services supported include Google's Google Cloud Vision API, Microsoft's Azure Computer Vision API, and Amazon's Textract and Rekognition. The framework for connecting to services could be expanded to support others as well (and contributions are welcome!).

Installation and configuration

The instructions below assume you have a Python interpreter version 3.8 or higher installed on your computer; if that's not the case, please first install Python and familiarize yourself with running Python programs on your system. If you are unsure of which version of Python you have, you can find out by running the following command in a terminal and inspecting the results:

# Note: on Windows, you may have to use "python" instead of "python3"
python3 --version

Note for Mac users: if you are using macOS Catalina (10.15) or later and have never run python3, then the first time you do, macOS will ask you if you want to install the macOS command-line developer tools. Go ahead and do so, as this is the easiest way to get a recent-enough Python 3 on those systems.

Handprint includes several adapters for working with cloud-based HTR services from Amazon, Google, and Microsoft, but does not include credentials for using the services. To be able to use Handprint, you must both install a copy of Handprint on your computer and supply your copy with credentials for accessing the cloud services you want to use. See below for more.

⓵  Install Handprint on your computer

Approach 1: using the standalone Handprint executables

Beginning with version 1.5.1, runnable self-contained single-file executables are available for select operating system and Python version combinations – to use them, you only need a Python 3 interpreter and a copy of Handprint, but do not need to run pip install or other steps. Please click on the relevant heading below to learn more.

macOS macOS

Visit the Handprint releases page and look for the ZIP files with names such as (e.g.) handprint-1.5.4-macos-python3.8.zip. Then:

  1. Download the one matching your version of Python
  2. Unzip the file (if your browser did not automatically unzip it for you)
  3. Open the folder thus created (it will have a name like handprint-1.5.4-macos-python3.8)
  4. Look inside for handprint and move it to a location where you put other command-line programs (e.g., /usr/local/bin)
Linux Linux

Visit the Handprint releases page and look for the ZIP files with names such as (e.g.) handprint-1.5.4-linux-python3.8.zip. Then:

  1. Download the one matching your version of Python
  2. Unzip the file (if your browser did not automatically unzip it for you)
  3. Open the folder thus created (it will have a name like handprint-1.5.4-linux-python3.8)
  4. Look inside for handprint and move it to a location where you put other command-line programs (e.g., /usr/local/bin)
Windows Windows

Standalone executables for Windows are not available at this time. If you are running Windows, please use one of the other methods described below.

Approach 2: using pipx

You can use pipx to install Handprint. Pipx will install it into a separate Python environment that isolates the dependencies needed by Handprint from other Python programs on your system, and yet the resulting handprint command wil be executable from any shell – like any normal application on your computer. If you do not already have pipx on your system, it can be installed in a variety of easy ways and it is best to consult Pipx's installation guide for instructions. Once you have pipx on your system, you can install Handprint with the following command:

pipx install handprint

Pipx can also let you run Handprint directly using pipx run handprint, although in that case, you must always prefix every Handprint command with pipx run. Consult the documentation for pipx run for more information.

Approach 3: using pip

If you prefer, you can install Handprint with pip. If you don't have pip package or are uncertain if you do, please consult the pip installation instructions. Then, to install or upgrade Handprint from the Python package repository, run the following command:

python3 -m pip install handprint --upgrade

⓶  Add cloud service credentials

A one-time configuration step is needed for each cloud-based HTR service after you install Handprint on a computer. This step supplies Handprint with credentials to access the services. In each case, the same command format is used:

handprint -a SERVICENAME CREDENTIALSFILE.json

SERVICENAME must be one of the service names printed by running handprint -l, and CREDENTIALSFILE.json must have one of the formats discussed below. When you run this command, Handprint copies CREDENTIALSFILE.json to a private location, and thereafter uses the credentials to access SERVICENAME. (The private location is different on different systems; for example, on macOS it is ~/Library/Application Support/Handprint/.) Examples are given below.

Microsoft

Microsoft's approach to credentials in Azure involves the use of subscription keys. The format of the credentials file for Handprint needs to contain two fields:

{
 "subscription_key": "YOURKEYHERE",
 "endpoint": "https://ENDPOINT"
}

The value "YOURKEYHERE" will be a string such as "18de248475134eb49ae4a4e94b93461c", and it will be associated with an endpoint URI such as "https://westus.api.cognitive.microsoft.com". To obtain a key and the corresponding endpoint URI, visit https://portal.azure.com and sign in using your account login. (Note: you will need to turn off browser security plugins such as Ad Block and uMatrix if you have them, or else the site will not work.) Once you are authenticated to the Azure portal, you can create credentials for using Azure's machine-learning services. Some notes all about this can be found in the Handprint project Wiki pages on GitHub.

Once you have obtained both a key and an endpoint URI, use a text editor to create a JSON file in the simple format shown above, save that file somewhere on your computer (for the sake of this example, assume it is myazurecredentials.json), and use the command discussed above to make Handprint copy the credentials file:

handprint -a microsoft myazurecredentials.json

Google

Credentials for using a Google service account need to be stored in a JSON file that contains many fields. The overall format looks like this:

{
  "type": "service_account",
  "project_id": "theid",
  "private_key_id": "thekey",
  "private_key": "-----BEGIN PRIVATE KEY-----anotherkey-----END PRIVATE KEY-----\n",
  "client_email": "emailaddress",
  "client_id": "id",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "someurl"
}

Getting one of these is summarized in the Google Cloud docs for Creating a service account, but more explicit instructions can be found in the Handprint project Wiki pages on GitHub. Once you have downloaded a Google credentials file from Google, save the file somewhere on your computer (for the sake of this example, assume it is mygooglecredentials.json), and use the command discussed above to make Handprint copy the credentials file:

handprint -a google mygooglecredentials.json

Amazon

Amazon credentials for AWS take the form of two alphanumeric strings: a key id string and a secret access key string. In addition, the service needs to be invoked with a region identifier. For the purposes of Handprint, these should be stored in a JSON file with the following format:

{
    "aws_access_key_id": "YOUR_KEY_ID_HERE",
    "aws_secret_access_key": "YOUR_ACCESS_KEY_HERE",
    "region_name": "YOUR_REGION_NAME_HERE"
}

Getting this information is, thankfully, a relatively simple process for Amazon's services. Instructions can be found in the Handprint project Wiki pages on GitHub. Once you have obtained the two alphanumeric keys and a region identifier string, use a text editor to create a JSON file in the simple format shown above, save that file somewhere on your computer (for the sake of this example, assume it is myamazoncredentials.json), and use two commands to make Handprint copy the credentials file for the two different Amazon services currently supported by Handprint:

handprint -a amazon-textract myamazoncredentials.json
handprint -a amazon-rekognition myamazoncredentials.json

Usage

Please see the documentation site for detailed documentation for Handprint.

Getting help

If you find an issue, please submit it in the GitHub issue tracker for this repository.

Contributing

I would be happy to receive your help and participation with enhancing Handprint! Please visit the guidelines for contributing for some tips on getting started.

If you plan on doing any development on Handprint, you may want to install the package dependencies listed in requirements-dev.txt, e.g., using a command such as the following. This will install dependencies necessary to run pytest.

python3 -m pip install -r requirements-dev.txt

License

Software produced by the Caltech Library is Copyright © 2018–2022 California Institute of Technology. This software is freely distributed under the BSD 3-clause OSI license. Please see the LICENSE file for more information.

Authors and history

Mike Hucka designed and implemented Handprint beginning in mid-2018.

Acknowledgments

The vector artwork of a hand used as a logo for Handprint was created by Kevin for the Noun Project. It is licensed under the Creative Commons CC-BY 3.0 license.

Handprint benefitted from feedback from several people, notably from Tommy Keswick, Mariella Soprano, Peter Collopy and Stephen Davison.

Handprint makes use of numerous open-source packages, without which it would have been effectively impossible to develop Handprint with the resources we had. I want to acknowledge this debt. In alphabetical order, the packages are:

Finally, I am grateful for computing & institutional resources made available by the California Institute of Technology.

More Repositories

1

datatools

A set of tools for working with JSON, CSV and Excel workbooks
Go
74
star
2

dibs

DIBS is an implementation of a basic controlled digital lending (CDL) system using IIIF to make scanned books available for time-limited viewing.
JavaScript
27
star
3

waystation

Automatically archive your repository's GitHub Pages in the Wayback Machine.
Makefile
23
star
4

dataset

dataset is a command line tool, Go package, shared library and Python package for working with JSON objects as collections
Go
21
star
5

sidewall

Sidewall is a Python library for interacting with the Dimensions search API.
Python
17
star
6

commonpy

Collection of common Python utility functions and classes used in other Caltech Library programs.
Python
15
star
7

bun

A Python package for a basic CLI and GUI user interface
Python
13
star
8

baler

Bad link reporter for GitHub repositories
Makefile
11
star
9

documentarist

Process Caltech Archives' digital documents and photos, and annotate each page or image with information about its contents
Python
11
star
10

caltechdata_api

Python library for using the CaltechDATA API
Python
10
star
11

pokapi

Simple Python object-oriented interface for getting records from FOLIO
Python
9
star
12

foliage

Foliage is the FOLIo chAnGe Editor, a tool to do bulk changes in FOLIO using the network API.
Python
9
star
13

caltechdata

The CaltechDATA InvenioRDM source code
HTML
8
star
14

iga

IGA is the InvenioRDM GitHub Archiver, a standalone program as well as a GitHub Action that lets you automatically archive GitHub software releases in an InvenioRDM repository.
Python
8
star
15

cloud-init-examples

This repository includes an example of cloud-init YAML files for use with multipass VMs.
HTML
6
star
16

topi

Simple Python objects for getting data from TIND
Python
6
star
17

newt

Newt a microservice for integrating Postgres+PostgREST and Pandoc
HTML
6
star
18

template

Template repository for software projects by the Caltech Library
SCSS
5
star
19

cell-atlas

Cell atlas
TeX
5
star
20

ames

Automated Metadata Service
Python
5
star
21

coif

Cover image finder
Python
4
star
22

epxml_to_datacite

Transform Eprints XML to DataCite XML and mint DOIs in Eprints repositories
Python
4
star
23

codemeta2cff

GitHub Action converting a codemeta file to CITATION.cff
4
star
24

boffo

Boffo is an add-on for Google Sheets written by the Caltech Library. It lets you select item barcodes in a spreadsheet and retrieve information about the item records from a FOLIO server.
JavaScript
4
star
25

urlup

Find the ultimate destination for URLs after following redirections.
Python
4
star
26

pairtree

A simple encoder/decoder for converting object identifiers into a Pair Tree Path (path)
Go
4
star
27

eprints2archives

Send records from an EPrints server to the Internet Archive and other web archives
Python
4
star
28

turf

Turf ("TIND.io URL Fixer") is a program to download records from the Caltech TIND.io database and check the URLs that may be embedded within the records.
Python
3
star
29

namaste

Go package and command line implementation of "NAMe AS TExt" metadata embedding for directories.
Go
3
star
30

tmplfn

tmplfn provides a set of common functions useful for working with Go's text/template and html/template packages
Go
3
star
31

collaborator_reports

Generate collaborator reports from data sources
Python
3
star
32

martian

Search Caltech's TIND.io database and download the resulting MARC records
Python
3
star
33

persistent_url_resolver

This repository contains a new version of Caltech Library's Persistent URL Resolver, based on AWS S3.
Python
3
star
34

splitit

Split range values produced by Caltech.tind.io in spreadsheet output
Python
3
star
35

convert_codemeta

Convert and validate codemeta files using crosswalk
Python
3
star
36

corsproxy

Simple CORS proxy server suitable for use as a system daemon on CentOS/RHEL systems
JavaScript
3
star
37

pubarchiver

Package up microPublication.org and other journals for archiving into Portico and PMC
Python
3
star
38

caltechauthors

The CaltechAUTHORS InvenioRDM source code
HTML
3
star
39

rss2

A Golang package for working with RSS 2
Go
3
star
40

cli

Building better command line interfaces for Caltech Library
Go
3
star
41

sidetrack

Simple debug tracing package for Python, with optimization support.
Python
3
star
42

eprints2bags

Download records and documents from an EPrints server and put them in BagIt format.
Python
3
star
43

eprinttools

EPrintTools is a Go package, command line utilities and a service for working with EPrints 3.3.x EPrint XML and REST API
Go
3
star
44

git-desktop

Modified version of the Software Carpentry git-novice lesson that uses GitHub Desktop
Python
3
star
45

py-cli-template

GitHub template project for non-web Python application projects. To use this, DO NOT CLONE OR FORK this repository; click on "Use this template". After it's used to create a new repo, this will run a GitHub Actions workflow to update files and directories, so give it a minute and refresh your browser to see the finished result.
Makefile
3
star
46

orcidtools

A command line tool and example Bash scripts for working with the ORCID v2.0 API
Go
2
star
47

popstar

Phone-Oriented Processing SofTware for ARchives
Makefile
2
star
48

coda_media

Web pages for CODA Movies
HTML
2
star
49

crossrefapi

This is a Go package fork working politely with the CrossRef API.
Go
2
star
50

libguine

Caltech Library customizations for LibGuides CMS
HTML
2
star
51

storage

A Go package wrapper for Caltech Library's remote storage options supporting CRUD operations
Go
2
star
52

lostit

Report lost items in the Caltech Library
JavaScript
2
star
53

2018-10-18-shell-arc

Python
2
star
54

install-golang

A Bash script that bootstraps and installs Go language in your home directory
Shell
2
star
55

RDMworkbook

bookdown files for "The Research Data Management Workbook"
TeX
2
star
56

acacia

Automated CaltechAUTHORS Catalog Ingest Agent
Python
2
star
57

liblog

experiment in tracking website content changes
HTML
2
star
58

inveniordm-migrate

Scripts to migrate content into Invenio RDM
Python
2
star
59

orcid-sciencv-workshop

HTML
2
star
60

caltechlibrary.github.io

Caltech Library's Digital Library Development sandbox.
HTML
2
star
61

unified-search-box

DEPRECIATED: A unified search box for Caltech Library.
HTML
2
star
62

wos_reports

Scripts to generate reports from Web of Science
Python
2
star
63

rc

Rest Client wrapper around Golang's http/http packages targeting ease of implementation working with REST API
Go
2
star
64

andor

A light weight object repository concept
Python
2
star
65

2019-01-22-Python-Workshop

Workshop page for CPA Python Workshop
Jupyter Notebook
2
star
66

wsfn

Go package for standardize web service functionality across our library's go projects
Go
2
star
67

command-line-for-librarians

MMWConf presentation Fall 2016
HTML
1
star
68

ocre

OCR evaluation utilities
Python
1
star
69

cold

Controlled Object Lists Daemon
JavaScript
1
star
70

refoliate

REstore FOLIo sAved insTance rEcords
1
star
71

vcard

A light weight VCard v4 package for harvesting local directory information
Go
1
star
72

2018-08-13-caltech

Python
1
star
73

2018-03-29-caltech

Caltech R Workshop
Python
1
star
74

irdm_harvester

Automatically harvest publications for an InvenioRDM repository
Python
1
star
75

metagenesys

Take the information from a Python setup.cfg file and generate a codemeta.json file
1
star
76

etdb-ipfs-mirror

Code involved in setting up an IPFS mirror of ETDB
Shell
1
star
77

dataset-instruction

Instructional content for the dataset package
HTML
1
star
78

caltechdata_map

Map interface for CaltechDATA files
HTML
1
star
79

library-shell-curl-and-api

An intermediate exploration of Bash, curl and working with content from web API
1
star
80

tccon-caltechdata

Scripts for uploading TCCON data to CaltechDATA
Python
1
star
81

htr-test-cases

Images of documents for testing HTR.
Python
1
star
82

R-Carpentry

Repository for Carpentry Lessons based on R
HTML
1
star
83

checkit

Look up barcodes in Caltech's TIND server
Python
1
star
84

html_footer

Universal footer code to be embedded in various systems for a consistent look.
HTML
1
star
85

doitools

A Go package for working with DOI
Go
1
star
86

archives_drupal

Caltech Archives on Drupal 8
CSS
1
star
87

cl-js

CL-js is a JavaScript library for integration with feeds and other library supplied services. It provides functionality through a global CL object.
JavaScript
1
star
88

caltechdata_plot

Demo interactive plotting tool that uses Bokeh server to produce an interactive plot by calling the caltechDATA (Invenio 3) API
Python
1
star
89

caltechdata_migrate

Assorted scripts for migrating content to CaltechDATA
Python
1
star
90

dibsiiif

Scripts to support the Caltech Library DIBS application
Python
1
star
91

pkgassets

(this has moved into the cli package) See https://github.com/caltechlibrary/cli
Go
1
star
92

searchtools

A Python3 package for working with Elasticsearch and LunrJS.
Python
1
star
93

distillery

WIP
Python
1
star
94

book-template

A Bookdown book template with Caltech customizations
JavaScript
1
star
95

ep-php

EPrints 3.3 REST API wrapper for PHP
PHP
1
star
96

adage

Authors Dimensional Analysis and General Exploration
1
star
97

dataciteapi

A Golang package and command line utility for working with the public DataCite API
Go
1
star
98

archives-hale-processing

Scripts and CSV files for processing the George Ellery Hale Papers for the Caltech Archives.
PHP
1
star
99

cait

Caltech Archives Integration Tools - A collection of tools utilities and services for integrating ArchivesSpace with other systems.
Go
1
star
100

shuffle

A minimal implementation of the Fischer/Yates array shuffle algorithm.
Go
1
star