How to use @tensorflow-models/toxicity - 1 common examples

To help you get started, we’ve selected a few @tensorflow-models/toxicity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / tfjs-models / toxicity / demo / index.js View on Github external
const predict = async () => {
  model = await toxicity.load();
  labels = model.model.outputNodes.map(d => d.split('/')[0]);

  const tableWrapper = document.querySelector('#table-wrapper');
  tableWrapper.insertAdjacentHTML(
      'beforeend', `<div class="row">
    <div class="text">TEXT</div>
    ${labels.map(label =&gt; {
              return `<div class="label">${label.replace('_', ' ')}</div>`;
            }).join('')}
  </div>`);

  const predictions = await classify(samples.map(d =&gt; d.text));
  addPredictions(predictions);

  document.querySelector('#classify-new-text')
      .addEventListener('click', (e) =&gt; {

@tensorflow-models/toxicity

Toxicity model in TensorFlow.js

Apache-2.0
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Popular @tensorflow-models/toxicity functions

Similar packages