michalfaber / tensorflow_Realtime_Multi-Person_Pose_Estimation

Multi-Person Pose Estimation project for Tensorflow 2.0 with a small and fast model based on MobilenetV3
Other
215 stars 65 forks source link

openpose_2branches_vgg transformed to tflite inference time 7 minutes #26

Closed AndreyStille closed 3 years ago

AndreyStille commented 3 years ago

tflite_model_file = '/content/tensorflow_Realtime_Multi-Person_Pose_Estimation/openpose_2branches.tflite'
interpreter = tf.lite.Interpreter(model_path=tflite_model_file)
inp_index = interpreter.get_input_details()[0]["index"]
out_details = sorted(interpreter.get_output_details(), key=lambda k: k['index']) 
heatmap_idx = out_details[-1]["index"]
paf_idx = out_details[-2]["index"]

%%time
test_image = 'resources/ski_368.jpg'
img = cv2.imread(test_image) # B,G,R order
img = np.expand_dims(img, 0)
input_tensor= tf.convert_to_tensor(img, np.uint8)
interpreter.allocate_tensors()
interpreter.set_tensor(inp_index, input_tensor)
interpreter.invoke()
heatmaps = interpreter.get_tensor(heatmap_idx)
pafs = interpreter.get_tensor(paf_idx)
cfg = get_default_configuration()
coordinates = get_coordinates(cfg, heatmaps)

CPU times: user 6min 50s, sys: 205 ms, total: 6min 50s Wall time: 6min 49s