easy_vision.python.custom_code

easy_vision.python.custom_code.custom_input

class easy_vision.python.custom_code.custom_input.CustomInput(dataset_config)[source]

Bases: easy_vision.python.input.cv_input.CVInput

__init__(dataset_config)[source]

Init input object

Parameters:dataset_config – easy-vision protobuf object, easy_vision.python.protos.dataset_pb2.DatasetConfig
classmethod create_class(name)
declare_feature_label()[source]
decode_record(record_string)[source]

decode data to tensor_dict

Parameters:record – record_data to be decoded
Returns:a dict of tensors containing both features and labels
Return type:tensor_dict
export_fn(export_config)[source]
export_fn1(export_config)[source]

easy_vision.python.custom_code.custom_model

class easy_vision.python.custom_code.custom_model.CustomClassificationModel(model_config, feature_dict, label_dict=None, mode='predict')[source]

Bases: easy_vision.python.model.cv_model.CVModel

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

Init classification model

Parameters:
  • model_config – a protobuf config object
  • feature_dict – a dict of tensor, used as features
  • label_dict – a dict of tensor, used as labels
  • mode – indicates to build a graph for train, evaluate or predict
  • categories – a list of dicts, each dist has two keys id and name
build_loss_graph()[source]

calculate classification loss

Parameters:
  • NxC tensor, where N is batch num, C is number of classes (self._prediction_dict['logits']) –
  • N tensor (self._label_dict['groundtruth_image_classes']) –
Returns:

a dict of tensor containing different kinds of loss

Return type:

loss_dict

build_metric_graph(eval_config)[source]

add metrics ops to graph

Parameters: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]

build classification network

Returns:a dict of prediction tensors
classmethod create_class(name)
get_outputs()[source]

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

class easy_vision.python.custom_code.custom_model.PyEvaluator[source]

Bases: easy_vision.python.evaluation.evaluator.Evaluator

__init__()[source]

Construct eval ops from tensor

Parameters:list of string, metric names this evaluator will return (metric_names) –
add_batch_image_info(predictions, labels)[source]

store prediction and labels in a internal list

Parameters:
  • batched prediction result, numpy array with shape N (predictions) –
  • batched labels, numpy array with shape N (labels) –
clear()[source]

clear internal storage

evaluate()[source]

python evaluation code which will be run after all test batched data are predicted