收藏
回答

微信小程序createInferenceSession#run闪退

问题类型 API/组件名称 终端类型 微信版本 基础库版本
Bug createInferenceSession 微信安卓客户端 8.0.69 3.10.3

createInferenceSession:fail Developer Tools do not support this API debugging at this time. Please use Weixin for development

const session = wx.createInferenceSession({
  model: modelPath,
  // typicalShape: {image: [1, 3, 192, 192]},
  precisionLevel: 3, // 硬件加速
  allowNPU: false,
  allowQuantize: false
});

session.onLoad(() => {
  // onLoad会正常调用
  // 2. 开启摄像头流
  const context = wx.createCameraContext();
  const listener = context.onCameraFrame((frame) => {
  // 避免推理过快导致堆栈阻塞,可以加一个 isInferencing 锁
  if (this.isInferencing) return;
  //...
  const rgbData = preProcessNCHW(frame.data, 192, 192);
  //...
  // 执行下面的代码,微信立即闪退
  const res = await session.run({
    image: {
        shape: [1,3,192,192],
        data: rgbData.buffer,
        type: 'float32'
      },
    });
   });
   listener.start();
});
session.onError((e) => {
  // 闪退时收集到错误
 // createInferenceSession:fail Developer Tools do not support this API debugging at this time. Please use Weixin for development
});
回答关注问题邀请回答
收藏

1 个回答

  • 智能回答 智能回答 本次回答由AI生成
    02-13
    有用
    回复
登录 后发表内容