tensorflow lite 如何使用双三次?

How tensorflow lite use bicubic?

我正在为Android使用Tensorflow lite,官方Python代码在使用TF.lite.Interpreter之前使用了以下代码,但是这段代码使用了TensorFlow模块,该模块在TF.lite.Interpreter中不可用Android Java。 TensorFlow Lite应该如何实现bicubic Resize方法?

img_resized = tf.image.resize(img, [width, height], method='bicubic', preserve_aspect_ratio=False)
img_input = img_resized.numpy()
reshape_img = img_input.reshape(1, width, height, 3)
tensor = tf.convert_to_tensor(reshape_img, dtype=tf.float32)

# load model
print("Load model...")
interpreter = tf.lite.Interpreter(model_path=model_name)

官方Python代码使用model.tflite,我只在AndroidTensorFlow Lite中找到这两种方法,不是bicubic:

ResizeOp.ResizeMethod.BILINEAR
ResizeOp.ResizeMethod.NEAREST_NEIGHBOR

TFLite 没有双三次调整大小。这里有三个选项:

  1. 如果是预处理的一部分 - 在 java 侧进行
  2. 尝试使用选定的 TF 操作:添加 converter.target_spec.supported_ops = [ tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops. tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops. ] 并将 implementation 'org.tensorflow:tensorflow-lite-select-tf-ops:0.0.0-nightly' 添加到您的 build.gradle。 Details
  3. 如果 1 和 2 不起作用 - 友好的社区将提供您自己实施