-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
Description
This code correctly loads the tf-tflite library:
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@3.16.0/dist/tf-core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-cpu@3.16.0/dist/tf-backend-cpu.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite@0.0.1-alpha.8/dist/tf-tflite.min.js"></script>
But this doesn't:
<script type="module">
await import("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@3.16.0/dist/tf-core.min.js");
await import("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-cpu@3.16.0/dist/tf-backend-cpu.min.js");
await import("https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tflite@0.0.1-alpha.8/dist/tf-tflite.min.js");
</script>
If I understand correctly, the two should work equivalently (it does with other libraries that I've tried). The latter code uses the wrong location for the tflite_web_api_cc_simd.js
file which results in a request error. I think this probably has something to do with the scripts trying to use document.currentScript.src
instead of import.meta.url
. It should use the latter if running in a module.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
rthadur commentedon May 12, 2022
@josephrocca please share the error message if possible . Thank you
josephrocca commentedon May 13, 2022
@rthadur Sure:
Note that it incorrectly makes a request to
https://null.jsbin.com/tflite_web_api_cc_simd.js
in this example: https://jsbin.com/lifelugivi/edit?html,outputjsbin.com for some reason returns an empty 202 response (rather than 404) when it makes that request, so there's no request error. If you copy and paste these lines into Chrome browser console on a site that appropriately returns a 404 for non-existent files, then you'll see a request and/or JS-parsing related error:
Again, I'm fairly sure this is just because
import.meta.url
needs to be used to get the correct relative/base URL.shmishra99 commentedon May 10, 2023
Hi @josephrocca ,
I apologize for the delay in my response. After replicating the issue, I have encountered the same error message
tflite_web_api_client.js:1687 GET file:///Users/sh/TFJS/issue6402/tflite_web_api_cc_simd.js net::ERR_FILE_NOT_FOUND
. It appears that the filetflite_web_api_cc_simd.js
is being loaded from the local directory instead of the server. Thank you for bringing this issue to our attention.CC: @jinjingforever