easy_vision.python.model.text_recognition

easy_vision.python.model.text_recognition.text_attn_head

class easy_vision.python.model.text_recognition.text_attn_head.TextAttentionHead(feature_dict, head_config, vocab_size, label_dict=None, mode='predict', is_end2end=False)[source]

Bases: easy_vision.python.model.cv_head.CVHead

Attention head for text recognition

__init__(feature_dict, head_config, vocab_size, label_dict=None, mode='predict', is_end2end=False)[source]
Parameters:
  • feature_dict – a dict of feature tensors
  • head_config – protos.text_head_pb2.TextAttentionHead
  • vocab_size – the number of characters
  • label_dict – a dict of labels tensors
  • is_training – train or not(eval/predict)
  • is_end2end – in end2end ocr mode or not
build_loss_graph()[source]
build_postprocess_graph()[source]

for post process of the head it is necessary to separate predict and postprocess because postprocess is not needed during train but needed during test

build_predict_graph()[source]

easy_vision.python.model.text_recognition.text_ctc_head

class easy_vision.python.model.text_recognition.text_ctc_head.TextCTCHead(feature_dict, head_config, vocab_size, label_dict=None, mode='predict', is_end2end=False)[source]

Bases: easy_vision.python.model.cv_head.CVHead

CTC head for text recognition

__init__(feature_dict, head_config, vocab_size, label_dict=None, mode='predict', is_end2end=False)[source]
Parameters:
  • feature_dict – a dict of feature tensors
  • head_config – protos.text_head_pb2.TextCTCHead
  • vocab_size – the number of characters
  • label_dict – a dict of labels tensors
  • is_training – train or not(eval/predict)
  • is_end2end – in end2end ocr mode or not
build_loss_graph()[source]
build_postprocess_graph()[source]

for post process of the head it is necessary to separate predict and postprocess because postprocess is not needed during train but needed during test

build_predict_graph()[source]

easy_vision.python.model.text_recognition.text_recognition_helper

easy_vision.python.model.text_recognition.text_recognition_helper.summary_text_recognition_metric(groundtruth_text, sequence_predict_ids, sequence_probability, char_dict)[source]

Summary metrics for text recognition

Parameters:
  • groundtruth_text – batch of groundtruth text, a string tensor of shape [batch_size]
  • sequence_predict_ids – batch of predict text character ids, a int32 tensor of shape [batch_size, max_sequence_length]
  • sequence_probability – batch of predict text probabilities, a float32 tensor of shape [batch_size]
  • char_dict – A instance of CharDict
easy_vision.python.model.text_recognition.text_recognition_helper.unpad_and_concat(inputs_tensor, num_valids_tensor)[source]

unpad and concat valid tensor

easy_vision.python.model.text_recognition.text_recognition_model

class easy_vision.python.model.text_recognition.text_recognition_model.TextRecognitionModel(model_config, feature_dict, label_dict=None, mode='predict', char_dict_path=None)[source]

Bases: easy_vision.python.model.cv_model.CVModel

__init__(model_config, feature_dict, label_dict=None, mode='predict', char_dict_path=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

build_loss_graph()[source]
build_metric_graph(eval_config)[source]

add metrics ops to graph :param eval_config: protobufer object, see python/protos/eval.proto.

Returns:a dict of metric_op, each metric_op is a tuple of (update_op, value_op)
Return type:metric_dict
build_predict_graph()[source]
classmethod create_class(name)
get_outputs()[source]

return a list of output key, which can be used to index output tensor result in prediction_dict

easy_vision.python.model.text_recognition.text_transformer_head

class easy_vision.python.model.text_recognition.text_transformer_head.TextTransformerHead(feature_dict, head_config, vocab_size, label_dict=None, mode='predict', is_end2end=False)[source]

Bases: easy_vision.python.model.cv_head.CVHead

Transformer head for text recognition

__init__(feature_dict, head_config, vocab_size, label_dict=None, mode='predict', is_end2end=False)[source]
Parameters:
  • feature_dict – a dict of feature tensors
  • head_config – protos.text_head_pb2.TextAttentionHead
  • vocab_size – the number of characters
  • label_dict – a dict of labels tensors
  • is_training – train or not(eval/predict)
  • is_end2end – in end2end ocr mode or not
build_loss_graph()[source]
build_postprocess_graph()[source]

for post process of the head it is necessary to separate predict and postprocess because postprocess is not needed during train but needed during test

build_predict_graph()[source]