|
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2'; |
|
|
|
|
|
env.allowLocalModels = false; |
|
|
|
|
|
const status = document.getElementById('status'); |
|
const msg = document.getElementById('message'); |
|
const checkMessage = document.getElementById('checkMessage'); |
|
|
|
status.textContent = 'Loading model...'; |
|
const pipe = await pipeline('text-classification', 'bajrangCoder/roberta_spam_onnx_quantised'); |
|
status.textContent = 'Ready'; |
|
|
|
checkMessage.onclick = async () => { |
|
try{ |
|
status.textContent = 'Analysing...'; |
|
const output = await pipe(msg.value); |
|
console.log(output) |
|
status.textContent = JSON.stringify(output); |
|
} catch(err) { |
|
console.log("Error: ", err); |
|
} |
|
} |
|
|