0

I'm trying to make a custom layer to make a Canny edges detection, but I can't convert the image tensor into a NumPy Array to send it to CV2.Canny()

'''

class canny(tf.keras.layers.Layer):

def __init__(self):

    super(canny, self).__init__()



def call(self, img):

    img = img.eval(session=tf.compat.v1.Session())    

    edg_img = cv2.Canny(img, 100, 200)

return tf.convert_to_tensor(edg_img)

'''

I get this error

'''File "", line 10, in call * img = img.eval(session=tf.compat.v1.Session())

InvalidArgumentError: Graph execution error:'''
  • Does this answer your question? [Convert a tensor to numpy array in Tensorflow?](https://stackoverflow.com/questions/34097281/convert-a-tensor-to-numpy-array-in-tensorflow) – Yoshikage Kira Apr 09 '22 at 06:13

0 Answers0