calamari_ocr.ocr.predict
- class calamari_ocr.ocr.predict.params.PredictionCharacter(char: str = '', label: int = 0, probability: float = 0)
Bases:
object- char: str = ''
- label: int = 0
- probability: float = 0
- __init__(char: str = '', label: int = 0, probability: float = 0) None
- classmethod from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False) A
- classmethod from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
- classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
- to_dict(encode_json=False) Dict[str, Optional[Union[dict, list, str, int, float, bool]]]
- to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw) str
- class calamari_ocr.ocr.predict.params.PredictionPosition(chars: List[calamari_ocr.ocr.predict.params.PredictionCharacter] = <factory>, local_start: int = 0, local_end: int = 0, global_start: int = 0, global_end: int = 0)
Bases:
object- chars: List[PredictionCharacter]
- local_start: int = 0
- local_end: int = 0
- global_start: int = 0
- global_end: int = 0
- __init__(chars: ~typing.List[~calamari_ocr.ocr.predict.params.PredictionCharacter] = <factory>, local_start: int = 0, local_end: int = 0, global_start: int = 0, global_end: int = 0) None
- classmethod from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False) A
- classmethod from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
- classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
- to_dict(encode_json=False) Dict[str, Optional[Union[dict, list, str, int, float, bool]]]
- to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw) str
- class calamari_ocr.ocr.predict.params.Prediction(id: str = '', sentence: str = '', labels: List[int] = <factory>, positions: List[calamari_ocr.ocr.predict.params.PredictionPosition] = <factory>, logits: Union[<built-in function array>, NoneType] = None, total_probability: float = 0, avg_char_probability: float = 0, is_voted_result: bool = False, line_path: str = '', voter_predictions: Union[List[ForwardRef('Prediction')], NoneType] = None)
Bases:
object- id: str = ''
- sentence: str = ''
- labels: List[int]
- positions: List[PredictionPosition]
- logits: Optional[array] = None
- total_probability: float = 0
- avg_char_probability: float = 0
- is_voted_result: bool = False
- line_path: str = ''
- voter_predictions: Optional[List[Prediction]] = None
- __init__(id: str = '', sentence: str = '', labels: ~typing.List[int] = <factory>, positions: ~typing.List[~calamari_ocr.ocr.predict.params.PredictionPosition] = <factory>, logits: ~typing.Optional[~numpy.array] = None, total_probability: float = 0, avg_char_probability: float = 0, is_voted_result: bool = False, line_path: str = '', voter_predictions: ~typing.Optional[~typing.List[~calamari_ocr.ocr.predict.params.Prediction]] = None) None
- classmethod from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False) A
- classmethod from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
- classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
- to_dict(encode_json=False) Dict[str, Optional[Union[dict, list, str, int, float, bool]]]
- to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw) str
- class calamari_ocr.ocr.predict.params.Predictions(predictions: List[calamari_ocr.ocr.predict.params.Prediction] = <factory>, line_path: str = '')
Bases:
object- predictions: List[Prediction]
- line_path: str = ''
- __init__(predictions: ~typing.List[~calamari_ocr.ocr.predict.params.Prediction] = <factory>, line_path: str = '') None
- classmethod from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False) A
- classmethod from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
- classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
- to_dict(encode_json=False) Dict[str, Optional[Union[dict, list, str, int, float, bool]]]
- to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw) str
- class calamari_ocr.ocr.predict.params.PredictorParams(device: tfaip.device.device_config.DeviceConfigParams = <factory>, pipeline: tfaip.data.databaseparams.DataPipelineParams = <factory>, silent: bool = True, progress_bar: bool = True, run_eagerly: bool = False, include_targets: bool = False, include_meta: bool = False)
Bases:
PredictorParams- silent: bool = True
- __init__(device: ~tfaip.device.device_config.DeviceConfigParams = <factory>, pipeline: ~tfaip.data.databaseparams.DataPipelineParams = <factory>, silent: bool = True, progress_bar: bool = True, run_eagerly: bool = False, include_targets: bool = False, include_meta: bool = False) None
- classmethod from_dict(kvs: Optional[Union[dict, list, str, int, float, bool]], *, infer_missing=False) A
- classmethod from_json(s: Union[str, bytes, bytearray], *, parse_float=None, parse_int=None, parse_constant=None, infer_missing=False, **kw) A
- classmethod schema(*, infer_missing: bool = False, only=None, exclude=(), many: bool = False, context=None, load_only=(), dump_only=(), partial: bool = False, unknown=None) SchemaF[A]
- to_dict(encode_json=False) Dict[str, Optional[Union[dict, list, str, int, float, bool]]]
- to_json(*, skipkeys: bool = False, ensure_ascii: bool = True, check_circular: bool = True, allow_nan: bool = True, indent: Optional[Union[int, str]] = None, separators: Optional[Tuple[str, str]] = None, default: Optional[Callable] = None, sort_keys: bool = False, **kw) str
- class calamari_ocr.ocr.predict.params.PredictionResult(prediction, codec, text_postproc, out_to_in_trans: Callable[[int], int], ground_truth=None)
Bases:
object- __init__(prediction, codec, text_postproc, out_to_in_trans: Callable[[int], int], ground_truth=None)
The output of a networks prediction (PredictionProto) with additional information
It stores all required information for decoding (codec) and interpreting the output.
- Parameters:
prediction (PredictionProto) – prediction the DNN
codec (Codec) – codec required to decode the prediction
text_postproc (TextPostprocessor) – text processor to apply to the decodec prediction to receive the actual prediction sentence
- class calamari_ocr.ocr.predict.predictor.Predictor(params: PredictorParams, data: DataBase, **kwargs)
Bases:
Predictor- static from_checkpoint(params: PredictorParams, checkpoint: str, auto_update_checkpoints=True)
- class calamari_ocr.ocr.predict.predictor.MultiPredictor(voter_params, *args, **kwargs)
Bases:
MultiModelPredictor- classmethod from_paths(checkpoints: List[str], auto_update_checkpoints=True, predictor_params: Optional[PredictorParams] = None, voter_params: Optional[VoterParams] = None, **kwargs) MultiModelPredictor
Create a MultiModePredictor. The data of the first model (in paths) will be used as the defining scenario and data (i.e. the post-processing). All data pre-procs must be identical.
- Parameters:
paths – paths to the scenario_params (see ScenarioBase.params_from_path)
params – PredictorParams
scenario – Type of the ScenarioBase
use_first_params – Only False is supported ATM.
model_paths – Paths to the actual models saved dirs (optional), by default based on paths
models – Already instantiated models (optional), by default created based on paths
predictor_args – Additional args for instantiating the Predictor (that are not part of PredictorParams)
- Returns:
An instantiated and ready to use MultiModelPredictor
- __init__(voter_params, *args, **kwargs)
- create_voter(data_params: DataParams) MultiModelVoter