File size: 724 Bytes
e90ef08 77bcdc5 e90ef08 77bcdc5 e90ef08 77bcdc5 e90ef08 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import { pipeline, env } from 'https://cdn.jsdelivr.net/npm/@xenova/[email protected]';
// 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');
// Create a new object detection pipeline
status.textContent = 'Loading model...';
const classifier = await pipeline('text-classification', 'Xenova/detr-resnet-50');
status.textContent = 'Ready';
async function checkMessage(){
status.textContent = 'Analysing...';
const output = await classifier(msg.value);
status.textContent = JSON.stringify(output);
}
|