1

Goal:
Enable to run the tensorflow.js toxicity classifier demo in the local computer.

Problem:
Based on instruction "https://github.com/tensorflow/tfjs/issues/149"

"You cannot call imports in a browser since browsers don't support such imports. Instead of loading tfjs as import * as tf from '@tensorflow/tfjs';, you need to import the library by either transpiring the node module and load it as a bundle using tools like webpack or load it using ready-to-use cdn mentioned here."

I have removed "import * as tf from '@tensorflow/tfjs';" and started to use

<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@latest"></script>

But I still retrieve an error message

"Uncaught (in promise) ReferenceError: toxicity is not defined at predict (index.js:71) at index.js:95"

What part do I need to fix in order for everything to be working?
https://jsbin.com/wiqigayoqu/edit?html,js,console,output

Thank you!

Info:
*I'm new in Tensorflow.js
*The raw of the source code is located "https://github.com/tensorflow/tfjs-models/tree/master/toxicity/demo"
* https://github.com/tensorflow/tfjs-models/tree/master/toxicity
*I don't know if you are enabled to see the code problem at jsbin and I have used the file index.html and index.js from "https://github.com/tensorflow/tfjs-models/tree/master/toxicity/demo" and used it in my local computer.

enter image description here

enter image description here

1 Answer 1

0

https://stackblitz.com/edit/typescript-tkmkho

Apply the code as typescript in stackblitz.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.