在Android中报错:

Input tensor has type kTfLiteFloat32: it requires specifying NormalizationOptions metadata to prepro

1.首先安装tflite_support:

pip install tflite_support

2.然后将自己的tflite文件重新转换一下:

https://stackoverflow.com/questions/66727627/failed-to-initialize-detector-input-tensor-has-type-ktflitefloat32-ml-kit

from tflite_support.metadata_writers import object_detector
from tflite_support.metadata_writers import writer_utils
from tflite_support import metadata
ObjectDetectorWriter = object_detector.MetadataWriter
# _MODEL_PATH = "yolo_without_metadata.tflite"
_MODEL_PATH = "/home/gyx/QR/qr_detect_model/convert_model/tflite/ssd_mobilenet_v2_quantized_300x300_uint8.tflite"
# Task Library expects label files that are in the same format as the one below.
_LABEL_FILE = "/home/gyx/QR/qr_detect_model/data_all/label_map.pbtxt"
# _SAVE_TO_PATH = "yolo_with_metadata.tflite"
_SAVE_TO_PATH = "/home/gyx/QR/qr_detect_model/convert_model/tflite/ssd_mobilenet_v2_quantized_300x300_uint8_metadata.tflite"
# Normalization parameters is required when reprocessing the image. It is
# optional if the image pixel values are in range of [0, 255] and the input
# tensor is quantized to uint8. See the introduction for normalization and
# quantization parameters below for more details.
# https://www.tensorflow.org/lite/convert/metadata#normalization_and_quantization_parameters)
_INPUT_NORM_MEAN = 127.5
_INPUT_NORM_STD = 127.5# Create the metadata writer.
writer = ObjectDetectorWriter.create_for_inference(writer_utils.load_file(_MODEL_PATH), [_INPUT_NORM_MEAN], [_INPUT_NORM_STD],[_LABEL_FILE])# Verify the metadata generated by metadata writer.
print(writer.get_metadata_json())# Populate the metadata into the model.
writer_utils.save_file(writer.populate(), _SAVE_TO_PATH)

将转换好的文件放入Android中就不会报错了!

Error-Input tensor has type kTfLiteFloat32: it requires specifying NormalizationOptions metadata to相关推荐

  1. sha256加密时报错 [TMA] Error: input is invalid type

    私密数据通过接口传输时,一般都需要进行加密.而加密方式又有很多,诸如md5,sha1,sha256- 在使用sha256的时候遇到一个报错信息: 经过一番研究,发现sha256加密的内容必须是一个字符 ...

  2. 解决Undefined function or method 'vgg_kmiter' for input arguments of type 'double'.

    Undefined function or method 'vgg_kmiter' for input arguments of type 'double'. Error in ==> vgg_ ...

  3. matlab 缺少awgn,MATLAB运行时出现Undefined function 'awgn' for input arguments of type 'double'....

    MATLAB运行时出现Undefined function 'awgn' for input arguments of type 'double'.0 pp11992016.05.08浏览236次分享 ...

  4. 报错解决transmission: Error: Input/Output error和ls: reading directory '': Input/output error

    transmission: Error: Input/Output error 晚上想用transmission下载新的种子时报错:Error: Input/Output error. 我很奇怪,先运 ...

  5. Action中五个常量解释,(success,error,input,login,none)

    Action中五个常量解释,(success,error,input,login,none) 英文注释 中文释义 staticString ERROR The actionexecution was ...

  6. Linux交叉编译问题strace解决 signalfd.c:15: xlat/sfd_flags.h:17: error: size of array 'type name' is negative

    产品不是很稳定,执行shell容易出现段错误,为了定位打算移植strace到嵌入式板子上,环境是MIPS平台,从github上下载的strace源码,编译ARM平台通过( ubuntu 12.04 交 ...

  7. fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

    xxxxxx.lib(xxxxxx.obj) : fatal error LNK1112: module machine type 'X86' conflicts with target machin ...

  8. configure: error: cannot guess build type; you must specify one解决方法

    configure: error: cannot guess build type; you must specify one解决方法 参考文章: (1)configure: error: canno ...

  9. configure: error: cannot guess build type; you must specify one

    今天在arm上用configure生成makefile时报错:configure: error: cannot guess build type; you must specify one 问题: 不 ...

  10. Undefined function 'adb' for input arguments of type 'double'.

    错误原因:No.1 在调用函数时,应该确保函数文件在matlab当前目录下,不然会报错: Undefined function 'adb' for input arguments of type 'd ...

最新文章

  1. C语言 条件编译详解
  2. 《C++代码设计与重用》——1.2 重用的神话
  3. Spring定时器的使用-多实例下定时重建索引
  4. 修复handsontable自动完成不支持中文的bug
  5. C++ int,float,double,long表示范围
  6. Github 开源:使用控制器操作 WinForm/WPF 控件( Sheng.Winform.Controls.Controller)
  7. 普通的年轻状态机,纯C语言
  8. matlab给0数组赋值,MATLAB中怎么把一个函数的一部分赋值给一个变量或数组,比如怎么把sin(x)大于0的部分赋值给f....
  9. [转]C/C++ 文件读写操作总结
  10. 208. 实现 Trie (前缀树)
  11. permutation 2(HDU-6630)
  12. 枚举的字符串表示形式
  13. Unity(十九):获取编辑器内置样式和内置图标
  14. 诺基亚n1平板电脑刷机教程_Z Launcher详细使用教程_诺基亚 N1_平板电脑新闻-中关村在线...
  15. Linux的tar解压命令
  16. Unity HTC vive移动定位器的开发使用
  17. SpringBoot整合Graylog3.0
  18. angularjs-requirejs-rjs-md5
  19. 【全网详解】从0到1搭建双十一实时交易数据展示平台——Spark+Kafka构建实时分析系统
  20. Python 的异常处理

热门文章

  1. 收藏!这10部关于数学的顶级纪录片,告诉孩子数学跟枯燥不沾边!
  2. Python Roberts算子、Sobel算子——举例说明 ^_^
  3. 2021爱分析·中国房企数字化实践报告
  4. 网页扫雷html css js,GitHub - zsr204/Sweep: js + html + css 实现一个简单的扫雷~~ 附加 难度选择 计时 计雷数 开始 重新开始 功能...
  5. 免费数据集下载网站【dataset】
  6. 佰马DTU连接远程服务器操作教程
  7. matlab边角网间接平差计算,第21讲间接平差实例.ppt
  8. 如何在arcgis中制作土地利用转移矩阵
  9. 微信小程序开发调用接口
  10. matlab编制刚度矩阵,平面3节点三角形单元刚度矩阵matlab程序