当前位置:网站首页>The problem of disorganized data output by mnn model
The problem of disorganized data output by mnn model
2022-08-03 23:53:00 【Master Luwen】
I have used Ali's for the past two daysMNN:
https://github.com/alibaba/MNN
还挺好用的,Just do not know withopenclHow to use the backend enginePython API调用
I encountered a small hole,The output data is so disorganized:
而不是这样的:
反复debug,发现:
It turns out that the output of the model cannot be directly getData()
output_tensor = interpreter.getSessionOutput(session) # 获得模型的输出
tmp_output = MNN.Tensor((1, 2, 224, 224), # Temporary variable used for output
MNN.Halide_Type_Float,
np.ones([1, 2, 224, 224]).astype(np.float32),
MNN.Tensor_DimensionType_Caffe)
output_tensor.copyToHostTensor(tmp_output) # Give the output of the model to tmp_output 变量
x = tmp_output.getNumpyData()[0] # 获取 numpy 格式的数据
这段代码没啥问题,But put the last line:
x = tmp_output.getNumpyData()[0] # 获取 numpy 格式的数据
替换为:
x = output_tensor.getNumpyData()[0] # 获取 numpy 格式的数据
It becomes a mess of data,It may be that there is a problem with the data first and then the column??
他俩都是 MNN.Tensor
的数据类型
所以我感觉,MNN模型输出的Tensor,Convert to the corresponding format firstMNN.Tensor_DimensionType_Caffe
,才能打印出来
In other words, this step is to convert the data format:
tmp_output = MNN.Tensor((1, 2, 224, 224), # Temporary variable used for output
MNN.Halide_Type_Float,
np.ones([1, 2, 224, 224]).astype(np.float32),
MNN.Tensor_DimensionType_Caffe)
边栏推荐
猜你喜欢
随机推荐
【深度学习】基于tensorflow的服装图像分类训练(数据集:Fashion-MNIST)
免费的公共WiFi不要乱连,遭中间人攻击了吧?
雅思大作文写作模版
libnet
Apple told Qualcomm: I bought a new campus for $445 million and may plan to speed up self-development of baseband chips
状态机实验
LeetCode 19:删除链表的倒数第 N 个结点
C语言实验十五 文件
View the version number of CUDA, pytorch, etc.
POE交换机全方位解读(上)
Salesforce's China business may see new changes, rumors may be closing
电子邮件安全或面临新威胁!
V8中的快慢数组(附源码、图文更易理解)
Scala basics [regular expressions, framework development principles]
禾匠编译错误记录
curl使用指南
The longest substring that cannot have repeating characters in a leetcode/substring
FPGA按键消抖+蜂鸣器
The Beijing E-sports Metaverse Forum was successfully held
通过whl安装第三方包