File size: 872 Bytes
dde25fa e90ef08 77bcdc5 da353ab dde25fa e90ef08 2d590ac e90ef08 dde25fa e90ef08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@2.17.2';
// Since we will download the model from the Hugging Face Hub, we can skip the local model check
env.allowLocalModels = false;
// Reference the elements that we will need
const status = document.getElementById('status');
const msg = document.getElementById('message');
const checkMessage = document.getElementById('checkMessage');
// Create a new pipeline
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);
}
}
|