MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / run_eval

Function run_eval

tensorflow/lite/tutorials/mnist_tflite.py:46–68  ·  view source on GitHub ↗

Performs evaluation for input image over specified model. Args: interpreter: TFLite interpreter initialized with model to execute. input_image: Image input to the model. Returns: output: output tensor of model being executed.

(interpreter, input_image)

Source from the content-addressed store, hash-verified

44
45
46def run_eval(interpreter, input_image):
47 """Performs evaluation for input image over specified model.
48
49 Args:
50 interpreter: TFLite interpreter initialized with model to execute.
51 input_image: Image input to the model.
52
53 Returns:
54 output: output tensor of model being executed.
55 """
56
57 # Get input and output tensors.
58 input_details = interpreter.get_input_details()
59 output_details = interpreter.get_output_details()
60
61 # Test model on the input images.
62 input_image = np.reshape(input_image, input_details[0]['shape'])
63 interpreter.set_tensor(input_details[0]['index'], input_image)
64
65 interpreter.invoke()
66 output_data = interpreter.get_tensor(output_details[0]['index'])
67 output = np.squeeze(output_data)
68 return output
69
70
71def main(_):

Callers 1

mainFunction · 0.85

Calls 6

get_input_detailsMethod · 0.80
get_output_detailsMethod · 0.80
reshapeMethod · 0.80
set_tensorMethod · 0.80
invokeMethod · 0.45
get_tensorMethod · 0.45

Tested by

no test coverage detected