easy_vision.python.model.text_end2end

easy_vision.python.model.text_end2end.text_end2end_helper

easy_vision.python.model.text_end2end.text_end2end_helper.build_instance_keypoints_inds(keypoints)[source]
Build instance_keypoints inds for ThinPlateSpline, boxes inds indicates
the feature map [NHWC] each boxes will crop on.
Parameters:keypoints – A float32 tensor with shape [batch_size, num_instances, num_keypoints, 2].
Returns:
tensor(int32), an array of image ids of each instance belongs to
one example: [[ 0, 0, 0, 0 …], [1, 1, 1, …], [2,2,2… ]]
easy_vision.python.model.text_end2end.text_end2end_helper.concat_bucket_tensor(key, tensor_dicts, pad_value=0)[source]

Concat tensor in bucket tensor_dicts :param key: tensor name :param tensor_dicts: list of bucket tensor dict to be concatenated :param pad_value: constant pad value for tf.pad

Returns:concatenated tensor
easy_vision.python.model.text_end2end.text_end2end_helper.fixed_height_tps(features, normalized_keypoints, instance_inds, aspect_ratios, height, random_distortion=False)[source]

ThinPlateSpline to a fixed size feature :param features: A float32 feature tensor with shape

[batch_size, height, width, depth]
Parameters:
  • normalized_keypoints – normalized keypoints coords on image with shape [num_instance, num_keypoints, 2]
  • instance_inds – an array of image ids of each instance belongs to one example with shape [num_instance]
  • aspect_ratios – aspect_ratio of keypoint boxes with shape [num_instance]
  • height – ThinPlateSpline output feature height
Returns:

ThinPlateSpline output features with shape

[num_instance, height, width, depth]

stn_features_shape: ThinPlateSpline output feature valid shape with

shape [num_instance, 2]

Return type:

stn_features

easy_vision.python.model.text_end2end.text_end2end_helper.fixed_sized_tps(features, normalized_keypoints, instance_inds, aspect_ratios, height, width, random_distortion=False)[source]

ThinPlateSpline to a fixed size feature :param features: A float32 feature tensor with shape

[batch_size, height, width, depth]
Parameters:
  • normalized_keypoints – normalized keypoints coords on image with shape [num_instance, num_keypoints, 2]
  • instance_inds – an array of image ids of each instance belongs to one example with shape [num_instance]
  • aspect_ratios – aspect_ratio of keypoint boxes with shape [num_instance]
  • height – ThinPlateSpline output feature height
  • width – ThinPlateSpline output feature width
  • random_distortion – with random distort keypoints or not
Returns:

ThinPlateSpline output features with shape

[num_instance, height, width, depth]

stn_features_shape:ThinPlateSpline output feature valid shape with

shape [num_instance, 2]

Return type:

stn_features

easy_vision.python.model.text_end2end.text_end2end_model

class easy_vision.python.model.text_end2end.text_end2end_model.TextEnd2EndModel(model_config, feature_dict, label_dict=None, mode='predict', categories=None, char_dict_path=None)[source]

Bases: easy_vision.python.model.cv_model.CVModel

__init__(model_config, feature_dict, label_dict=None, mode='predict', categories=None, 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

get_scopes_of_levels()[source]

return a list of variable scope list order by levels ( outputs -> heads -> backbone -> inputs).

easy_vision.python.model.text_end2end.text_feature_gather

class easy_vision.python.model.text_end2end.text_feature_gather.FixedHeightFeatureGather(config, is_training)[source]

Bases: easy_vision.python.model.text_end2end.text_feature_gather.TextFeatureGather

Gather text feature within ROI defined to a fixed height feature

__init__(config, is_training)[source]

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

max_aspect_ratio
min_aspect_ratio
num_buckets
class easy_vision.python.model.text_end2end.text_feature_gather.FixedHeightPyramidFeatureGather(config, is_training)[source]

Bases: easy_vision.python.model.text_end2end.text_feature_gather.TextFeatureGather

Gather text feature within ROI defined to a fixed height feature

__init__(config, is_training)[source]

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

max_aspect_ratio
min_aspect_ratio
num_buckets
class easy_vision.python.model.text_end2end.text_feature_gather.FixedSizeFeatureGather(config, is_training)[source]

Bases: easy_vision.python.model.text_end2end.text_feature_gather.TextFeatureGather

Gather text feature within ROIs defined to fixed size features

__init__(config, is_training)[source]

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

max_aspect_ratio
min_aspect_ratio
num_buckets
class easy_vision.python.model.text_end2end.text_feature_gather.TextFeatureGather(config, is_training)[source]

Bases: object

Gather text feature within ROIs defined by normalized_keypoints

__init__(config, is_training)[source]

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

gather(feature_dict)[source]

crop and correct distortion for roi features

Parameters:contain following keys (feature_dict) –
config.input_layer: backbone feature maps with shape
[batch_size, height, width, depth]
normalized_keypoints: detection keypoints within value range [0, 1]
with shape [num_instance, num_keypoints, 2]
instance_inds: an array of image ids of each instance belongs to
one example with shape [num_instance]

aspect_ratios: aspect_ratio of keypoint boxes with shape [num_instance] normalized_boxes: (optional) detection boxes with value range [0, 1]

with shape [num_instance, 4], used when visualization

visualized_image: (optional) image after preprocess

Returns:text_stn_features: cropped and corrected distortion roi features text_stn_features_shape: true shape of text_stn_features text_roi_features: if visualize, return cropped roi features text_roi_images: if visualize, return cropped image text_stn_images: if visualize, return cropped and corrected distortion image text_stn_images_shape: if visualize, return true shape of text_stn_images text_stn_keypoints: alias for normalized_keypoints
Return type:result_dict contain following keys
ignore_recog_classes
max_aspect_ratio
min_aspect_ratio
num_buckets
subsample_batch_size
easy_vision.python.model.text_end2end.text_feature_gather.build(model_config, is_training)[source]

build feature gather according to specify type