InvalidArgumentError: Graph execution error: TensorFlow pose estimation using OpenCV

Anirudh

I am trying to build pose detection using cv2, tensorflow in google colab I am encountering with the following error..

Code:

import tensorflow as tf
import tensorflow_hub as hub
import cv2
from matplotlib import pyplot as plt
import numpy as np
from google.colab.patches import cv2_imshow


model = hub.load('https://tfhub.dev/google/movenet/multipose/lightning/1')
movenet = model.signatures['serving_default']


img_original = cv2.imread('/content/brandon-atchison-eexdeq3NleQ-unsplash.jpeg',1)
img_copy = img_original.copy()
input_img = tf.cast(img_original,dtype=tf.int32)
img_copy.shape


tensor = tf.convert_to_tensor(img_original,dtype=tf.int32)
tensor


results = movenet(tensor)

I have created the variable img_copy cuz I need to perform some operations on the image and want the original image as it is. Not sure what is the error I am facing while trying to get results from the movenet model.

Error image

edit: enter image description here

AloneTogether

Try:

results = movenet(tensor[None, ...])

since you are missing the batch dimension, which is needed to feed data to your model. You could also use tf.expand_dims:

tensor = tf.expand_dims(tensor, axis=0)
# resize
tensor = tf.image.resize(tensor, [32 * 186, 32 * 125])

Here is a working example:

import tensorflow_hub as hub

model = hub.load('https://tfhub.dev/google/movenet/multipose/lightning/1')
movenet = model.signatures['serving_default']

tensor = tf.random.uniform((1, 160, 256, 3), minval=0, maxval=255, dtype=tf.int32)
movenet(tensor)

Check the model description and make sure you have the correct shape:

A frame of video or an image, represented as an int32 tensor of dynamic shape: 1xHxWx3, where H and W need to be a multiple of 32 and the larger dimension is recommended to be 256. To prepare the input image tensor, one should resize (and pad if needed) the image such that the above conditions are hold. Please see the Usage section for more detailed explanation. Note that the size of the input image controls the tradeoff between speed vs. accuracy so choose the value that best suits your application. The channel order is RGB with values in [0, 255].

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how can reslove : InvalidArgumentError: Graph execution error?

InvalidArgumentError: Graph execution error - Fruit detection

Tensorflow pose estimation strange behaviour

In need of a Labelencoder code to fix the InvalidArgumentError: Graph execution error when Using deeplabv3+ for a 4 class semantic segmentation

OpenCV: 3D Pose estimation of color markers using StereoCamera system

Drawing checkerboard's reference frame for pose estimation using OpenCV (solvePnP+projectPoints)

OpenCV + OpenGL: proper camera pose using solvePnP

Error Loading Tensorflow Frozen Inference Graph to OpenCV DNN

Tensorflow condition x==y error: A InvalidArgumentError

Human pose estimation/matching on smartphone

dynamically catch exceptions in TensorFlow as part of the graph execution

Both eager and graph execution in tensorflow tests

Error using tensorflow dataset window operation in graph mode with a Session

TensorFlow InvalidArgumentError/Value error occurs with small change of code

Tensorflow error: InvalidArgumentError: Different number of component types.

TensorFlow giving error "InvalidArgumentError: Input is empty" when training or validating

MoveNet Pose Estimation renders inaccurate keypoints

Camera pose estimation from homography or with solvePnP() function

'Too many values to unpack' with solvePnPRansac() - Pose Estimation

Camera pose estimation giving wrong results

How does robot do pose estimation in SLAM?

Camera Pose Estimation Accuracy with ArUco Board

Movement multi person pose estimation does not import

Tensorflow Estimator InvalidArgumentError

Tensorflow invalid shape (InvalidArgumentError)

Tensorflow - matmul is showing InvalidArgumentError

InvalidArgumentError on softmax in tensorflow

Tensorflow: InvalidArgumentError for placeholder

TensorFlow: InvalidArgumentError: In[0] is not a matrix