tensorflow / tfjs-wechat

WeChat Mini-program plugin for TensorFlow.js
https://tensorflow.org/js
552 stars 104 forks source link

new android wechat version 7.0.10 load cocossd model error #43

Closed aohan237 closed 4 years ago

aohan237 commented 4 years ago

as the title said, on android wechat7.0.10, load cocossd model error, shows tensorshape is zero error

any older version of android wechat works fine

iooops commented 4 years ago

Same here. On Android Wechat 7.0.10, posenet model detections always have 0 score. Please solve this issue as soon as possible.

aohan237 commented 4 years ago

@iooops

it seems to be the wx.createOffscreenCanvas() problem create a canvas by hand will be solve.

https://github.com/HunterXuan/wx-tfjs-demo/issues/19

<camera frame-size="medium" bindinitdone="cameraInit" binderror="cameraError">
<cax id="stage"></cax>
<canvas type="webgl" id="myCanvas" hidden="{{ true }}"></canvas>
</camera>

this solution will be fine. just add a webgl canvas on camera by hand .


it seems that android wechat 7.0.10 is a milestone update . it updates things on webgl and tests do not cover too much about it so be careful with android wechat 7.0.10

iooops commented 4 years ago

How did you configure it in plugin.configPlugin?

aohan237 commented 4 years ago
            if (!hasConfigPlugin) {
                plugin.configPlugin({
                    fetchFunc: fetchWechat.fetchFunc(),
                    tf,
                    canvas: wx.createOffscreenCanvas()
                }, false);
                //hasConfigPlugin = true;
            }
iooops commented 4 years ago

What about the created webgl canvas?

aohan237 commented 4 years ago

@iooops the first answer...

iooops commented 4 years ago

Do you have sample repo?

aohan237 commented 4 years ago

sorry ,no

iooops commented 4 years ago

Ok I figured it out. Here's my solution.

var res = wx.getSystemInfoSync()
let iOS = res.system.startsWith('iOS')
const query = wx.createSelectorQuery()
query.select('#myCanvas').node().exec((res) => {
  const canvas = res[0].node
  const gl = canvas.getContext('webgl')
  console.log('!!',canvas)
  plugin.configPlugin({
    // polyfill fetch function
    fetchFunc: fetchWechat.fetchFunc(),
    // inject tfjs runtime
    tf,
    // provide webgl canvas
    canvas: iOS ? wx.createOffscreenCanvas() : canvas,
    backendName: 'wechat-webgl-' + Math.random()
  });
  this.init()
})
pyu10055 commented 4 years ago

@aohan237 thanks, WeChat engineers are looking into the problem, will update here if it is fixed.

aohan237 commented 4 years ago

@pyu10055 thanks for updating information,too

pyu10055 commented 4 years ago

@aohan237 Updates from WeChat, this will be fixed in the upcoming wechat common lib version 2.10.1 (hopeful released by tomorrow). Please try it out, and let us know if this issue is fixed. thanks.

allrightzhu commented 4 years ago

@aohan237 Updates from WeChat, this will be fixed in the upcoming wechat common lib version 2.10.1 (hopeful released by tomorrow). Please try it out, and let us know if this issue is fixed. thanks.

Wechat common lib version 2.10.1 didn't fix this problem

pyu10055 commented 4 years ago

@allrightzhu any luck with the latest wechat version 2.10.3? thanks

allrightzhu commented 4 years ago

@allrightzhu any luck with the latest wechat version 2.10.3? thanks

It's ok on new version.

pyu10055 commented 4 years ago

thanks for confirming.