我在暗网上重新训练了我的模型,并使用了 https:/github.comqqwweeekeras-yolo3 来将我的暗网权重转换为h5。
我用tf-nightly把relu换成了leaky relu,以达到量化的目的,然后我的模型已经被成功转换为tflite模型。
但是,我不能通过调整最近邻接误差来解析模型到edgetpu。https:/coral.aidocsedgetpumodels-intro#supported-operations。那么,为什么会发生这个错误呢,有什么办法可以解决吗?
这是我的tflite转换代码。
import tensorflow as tf
import numpy as np
import sys
def representative_dataset_gen():
for _ in range(250):
yield [np.random.uniform(0.0, 1.0, size=(1, 416, 416, 3)).astype(np.float32)]
if len(sys.argv) != 3:
print(f"Usage: {sys.argv[0]} <keras-model> <output-filename>")
sys.exit(1)
model_fn = sys.argv[1]
out_fn = sys.argv[2]
# Convert and apply full integer quantization
converter = tf.compat.v1.lite.TFLiteConverter.from_keras_model_file(model_fn)
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8,
tf.lite.OpsSet.SELECT_TF_OPS]
#converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]
# Set inputs and outputs of network to 8-bit unsigned integer
converter.inference_input_type = tf.uint8
converter.inference_output_type = tf.uint8
converter.representative_dataset = representative_dataset_gen
tflite_model = converter.convert()
open(sys.argv[2], "wb").write(tflite_model)
我是珊瑚团队的,我打算自己研究yolov3模型,只是还没有带宽去做:) 下面是我收集到的一些提示。
用户在改变了yolov3模型的配置文件后 leaky_relu
到 relu
虽然准确性可能会降低。我知道你已经提过了,但我想把这个放在列表中,供其他用户参考。
其次,我怀疑你使用的是 tf-nightly
或一些较新的tf版本的转换?如果是这样,我建议降级到也许是tf2.2,一些新版本的同样的操作还不被编译器支持。
尝试关闭 MLIR
转换器也,发布了版本的 edgetpu_compiler
不合时宜 MLIR
lmk如果你发现了一些成功,会喜欢给这个镜头也!fyi:我得到了yolov4转换,但建筑师只允许1962 Ops运行在edgegetpu上,所以它是一个无赖没有去。