You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm working on this "crop_to_bounding_box()" function in order to Crop an image to a specified bounding box.
But I get this error in "crop_to_bounding_box()" function
Tensorflow.RuntimeError: 'Attempting to capture an EagerTensor without building a function.'
any suggestion, please
the code :
var image = tf.image.decode_jpeg(tf.io.read_file(filname),1);
// Set the variable values here
//Offset variables values
var offset_height = 20;
var offset_width = 20;
// Target variables values
var target_height = 20;
var target_width = 20;
var graph = tf.Graph().as_default();
var ts = tf.image.crop_to_bounding_box(image, offset_height, offset_width, target_height, target_width);
Alternatives
No response
The text was updated successfully, but these errors were encountered:
Hi, this error is because the tf.image has not been updated for a long time and many implementations still stay in tf1.x. I've submit a partial fix for ir in #1043 . However with that, you need to specify the image shape yourself, which may lead to some inconvenience. Here's the example code:
vargraph=tf.Graph().as_default();// Make sure the graph mode is on before reading the imagevarimage=tf.image.decode_jpeg(tf.io.read_file("xxx"),1);// Set the variable values here//Offset variables valuesvaroffset_height=20;varoffset_width=20;// Target variables valuesvartarget_height=20;vartarget_width=20;image.shape=(400,500,1);// need to specify the image shapevarts=tf.image.crop_to_bounding_box(image,offset_height,offset_width,target_height,target_width);graph.Exit();
If you don't want to specify the image shape manually, you can read the image under eager mode first and get the shape before jumping into the code above, though that will sacrifice some performance.
I'll update the whole tf.image module next month, which will completely fix this issue. It's a work that costs time so now I can only give a quick but not so good fix for it. Thank you for reporting us this issue. :)
Besides, we'll publish a new library Tensorflow.NET.OpencvAdapter soon, which enables using Tensorflow.NET with OpencvSharp. It may also be an alternative. Besides, SharpCV may works but I'm not sure for that.
Description
Hi, I'm working on this "crop_to_bounding_box()" function in order to Crop an image to a specified bounding box.
But I get this error in "crop_to_bounding_box()" function
Tensorflow.RuntimeError: 'Attempting to capture an EagerTensor without building a function.'
any suggestion, please
the code :
Alternatives
No response
The text was updated successfully, but these errors were encountered: