Load Tensorflow js model from local file system in javascript

前端 未结 7 1224
一个人的身影
一个人的身影 2020-11-30 10:31

I have converted a keras model to tensorflow json format and saved it locally in my computer. I am trying to load that json model in a javascript code using the below comman

7条回答
  •  自闭症患者
    2020-11-30 11:19

    You could use insecure chrome instance:

    C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --disable-web-security --disable-gpu --user-data-dir=C:/Temp
    

    Than you could add this script to redefine fetch function

    async function fetch(url) {
      return new Promise(function(resolve, reject) {
        var xhr = new XMLHttpRequest
        xhr.onload = function() {
          resolve(new Response(xhr.responseText, {status: 200}))
        }
        xhr.onerror = function() {
          reject(new TypeError('Local request failed'))
        }
        xhr.open('GET', url)
        xhr.send(null)
      })
    }
    

    After that be shure that you use the right model loader my comment about loader issue

    BUT your weights will be incorrect - as I understand there are some encoding problems.

提交回复
热议问题