Spaces:
Running
Running
Delete index.js
Browse files
index.js
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]';
|
2 |
-
|
3 |
-
// Reference the elements that we will need
|
4 |
-
const status = document.getElementById('status');
|
5 |
-
const inputText = document.getElementById('text-field');
|
6 |
-
const inputSubmitBtn = document.getElementById('submit');
|
7 |
-
|
8 |
-
// Create a new object detection pipeline
|
9 |
-
// status.textContent = 'Loading model...';
|
10 |
-
const classifier = await pipeline('token-classification', 'Setosm/bert-finetuned-for-medical-ner');
|
11 |
-
// status.textContent = 'Ready';
|
12 |
-
|
13 |
-
inputSubmitBtn.addEventListener('click', async (e) => {
|
14 |
-
e.preventDefault();
|
15 |
-
let result = await classifier(inputText.value);
|
16 |
-
console.log(result);
|
17 |
-
showOutput();
|
18 |
-
});
|
19 |
-
|
20 |
-
function showOutput() {
|
21 |
-
|
22 |
-
}
|
23 |
-
|
24 |
-
// example.addEventListener('click', (e) => {
|
25 |
-
// e.preventDefault();
|
26 |
-
// detect(EXAMPLE_URL);
|
27 |
-
// });
|
28 |
-
|
29 |
-
// fileUpload.addEventListener('change', function (e) {
|
30 |
-
// const file = e.target.files[0];
|
31 |
-
// if (!file) {
|
32 |
-
// return;
|
33 |
-
// }
|
34 |
-
|
35 |
-
// const reader = new FileReader();
|
36 |
-
|
37 |
-
// // Set up a callback when the file is loaded
|
38 |
-
// reader.onload = e2 => detect(e2.target.result);
|
39 |
-
|
40 |
-
// reader.readAsDataURL(file);
|
41 |
-
// });
|
42 |
-
|
43 |
-
|
44 |
-
// // Detect objects in the image
|
45 |
-
// async function detect(img) {
|
46 |
-
// imageContainer.innerHTML = '';
|
47 |
-
// imageContainer.style.backgroundImage = `url(${img})`;
|
48 |
-
|
49 |
-
// status.textContent = 'Analysing...';
|
50 |
-
// const output = await detector(img, {
|
51 |
-
// threshold: 0.5,
|
52 |
-
// percentage: true,
|
53 |
-
// });
|
54 |
-
// status.textContent = '';
|
55 |
-
// output.forEach(renderBox);
|
56 |
-
// }
|
57 |
-
|
58 |
-
// Render a bounding box and label on the image
|
59 |
-
// function renderBox({ box, label }) {
|
60 |
-
// const { xmax, xmin, ymax, ymin } = box;
|
61 |
-
|
62 |
-
// // Generate a random color for the box
|
63 |
-
// const color = '#' + Math.floor(Math.random() * 0xFFFFFF).toString(16).padStart(6, 0);
|
64 |
-
|
65 |
-
// // Draw the box
|
66 |
-
// const boxElement = document.createElement('div');
|
67 |
-
// boxElement.className = 'bounding-box';
|
68 |
-
// Object.assign(boxElement.style, {
|
69 |
-
// borderColor: color,
|
70 |
-
// left: 100 * xmin + '%',
|
71 |
-
// top: 100 * ymin + '%',
|
72 |
-
// width: 100 * (xmax - xmin) + '%',
|
73 |
-
// height: 100 * (ymax - ymin) + '%',
|
74 |
-
// })
|
75 |
-
|
76 |
-
// // Draw label
|
77 |
-
// const labelElement = document.createElement('span');
|
78 |
-
// labelElement.textContent = label;
|
79 |
-
// labelElement.className = 'bounding-box-label';
|
80 |
-
// labelElement.style.backgroundColor = color;
|
81 |
-
|
82 |
-
// boxElement.appendChild(labelElement);
|
83 |
-
// imageContainer.appendChild(boxElement);
|
84 |
-
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|