API Documentation¶
- evaluate_ocr.filter_pred(pred) List[str]¶
Filters predictions
- Parameters:
pred – The loaded predictions
- Returns:
A list of strings
- evaluate_ocr.levenshtein_distance(s1: str, s2: str) int¶
Computes the Levenshtein Distance between two strings
- Parameters:
s1 (str) – The first string
s2 (str) – The second string
- Returns:
the Levenshtein Distance between two strings
>>> levenshtein_distance("kitten", "sitting") 4
- Reference:
V. I. Levenshtein, “Binary codes capable of correcting deletions, insertions, and reversals”, Soviet Physics Doklady, vol. 10, no. 8, pp. 707-710, 1966.
- class utils.IOUMetric(num_classes)¶
Class to calculate mean-iou using fast_hist method
- class utils.MaskLoader(root='datasets', dataset='coco_2017_train', size=28, transform=False)¶
Dataloader for Local Mask.
- Parameters:
root (string) – filepath to dataset folder.
dataset (string) – mask to use (eg. ‘train’, ‘val’).
size (tuple) – The size used for train/val (height, width).
transform (callable, optional) – transformation to perform on the input mask.
- utils.direct_sigmoid(x)¶
Apply the sigmoid operation.
- utils.inverse_sigmoid(x)¶
Apply the inverse sigmoid operation. y = -ln(1-x/x)
- utils.inverse_transform(X, components_, explained_variance_, mean_=None, whiten=False)¶
Transform data back to its original space. In other words, return an input X_original whose transform would be X. :param X: New data, where n_samples is the number of samples
and n_components is the number of components.
- Parameters:
components (array-like, shape (n_components, n_features)) –
mean (array-like, shape (n_features,)) –
explained_variance (array-like, shape (n_components,)) – Variance explained by each of the selected components.
whiten (bool, optional) – When True (False by default) the
components_vectors are divided byn_samplestimescomponents_to ensure uncorrelated outputs with unit component-wise variances. Whitening will remove some information from the transformed signal (the relative variance scales of the components) but can sometimes improve the predictive accuracy of the downstream estimators by making data respect some hard-wired assumptions.
- Return type:
X_original array-like, shape (n_samples, n_features)
- utils.transform(X, components_, explained_variance_, mean_=None, whiten=False)¶
Apply dimensionality reduction to X. X is projected on the first principal components previously extracted from a training set. :param X: New data, where n_samples is the number of samples
and n_features is the number of features.
- Parameters:
components (array-like, shape (n_components, n_features)) –
mean (array-like, shape (n_features,)) –
explained_variance (array-like, shape (n_components,)) – Variance explained by each of the selected components.
whiten (bool, optional) – When True (False by default) the
components_vectors are divided byn_samplestimescomponents_to ensure uncorrelated outputs with unit component-wise variances. Whitening will remove some information from the transformed signal (the relative variance scales of the components) but can sometimes improve the predictive accuracy of the downstream estimators by making data respect some hard-wired assumptions.
- Returns:
X_new
- Return type:
array-like, shape (n_samples, n_components)