Spaces:
Running
Running
Tobias Cornille
commited on
Commit
·
5c804a1
1
Parent(s):
4424728
Update index.js
Browse files
index.js
CHANGED
|
@@ -13,7 +13,7 @@ const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs
|
|
| 13 |
|
| 14 |
// Create a new object detection pipeline
|
| 15 |
status.textContent = 'Loading model...';
|
| 16 |
-
const detector = await pipeline('zero-shot-object-detection', 'Xenova/owlvit-base-patch32');
|
| 17 |
status.textContent = 'Ready';
|
| 18 |
|
| 19 |
example.addEventListener('click', (e) => {
|
|
@@ -42,17 +42,11 @@ async function detect(img) {
|
|
| 42 |
imageContainer.style.backgroundImage = `url(${img})`;
|
| 43 |
|
| 44 |
status.textContent = 'Analysing...';
|
| 45 |
-
|
| 46 |
-
const image = new Image();
|
| 47 |
-
image.src = img;
|
| 48 |
|
| 49 |
const candidate_labels = ['human face', 'rocket', 'helmet', 'american flag'];
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
status.textContent = '';
|
| 54 |
-
relativeOutput.forEach(renderBox);
|
| 55 |
-
};
|
| 56 |
|
| 57 |
}
|
| 58 |
|
|
|
|
| 13 |
|
| 14 |
// Create a new object detection pipeline
|
| 15 |
status.textContent = 'Loading model...';
|
| 16 |
+
const detector = await pipeline('zero-shot-object-detection', 'Xenova/owlvit-base-patch32', {percentage: true});
|
| 17 |
status.textContent = 'Ready';
|
| 18 |
|
| 19 |
example.addEventListener('click', (e) => {
|
|
|
|
| 42 |
imageContainer.style.backgroundImage = `url(${img})`;
|
| 43 |
|
| 44 |
status.textContent = 'Analysing...';
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
const candidate_labels = ['human face', 'rocket', 'helmet', 'american flag'];
|
| 47 |
+
const output = await detector(img, candidate_labels);
|
| 48 |
+
status.textContent = '';
|
| 49 |
+
relativeOutput.forEach(renderBox);
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
}
|
| 52 |
|