xyolo icon indicating copy to clipboard operation
xyolo copied to clipboard

tf.function 对不同分辨率的图片无效

Open maty4545 opened this issue 4 years ago • 0 comments

因为compute_output中输入的参数类型, 为python的list, 而tf.function对于python基础类型, 只支持相同值下的加速 @tf.function def compute_output(self, image_data, image_shape):

tf.function对于TensorFlow 张量或 NumPy 数组, 支持相同类型下的加速, 故, 应修改为: def detect_image(self, img: typing.Union[Image.Image, str]) -> typing.List[ typing.Tuple[str, int, float, int, int, int, int]]: ...... ...... out_boxes, out_scores, out_classes = self.compute_output( image_data, tf.constant([image.size[1], image.size[0]]))

@tf.function def compute_output(self, image_data, image_shape): # Generate output tensor targets for filtered bounding boxes. # self.input_image_shape = K.placeholder(shape=(2,)) # self.input_image_shape = tf.constant(image_shape) self.input_image_shape = image_shape

maty4545 avatar Jan 13 '21 02:01 maty4545