Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
|
@@ -11,16 +11,16 @@ const example = document.getElementById('example');
|
|
| 11 |
|
| 12 |
const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/city-streets.jpg';
|
| 13 |
|
|
|
|
|
|
|
| 14 |
// Create a new object detection pipeline
|
| 15 |
status.textContent = 'Loading model...';
|
| 16 |
const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
|
| 17 |
|
| 18 |
-
//
|
| 19 |
-
processor.feature_extractor.size = { width:
|
| 20 |
|
| 21 |
-
const model = await AutoModel.from_pretrained('Xenova/yolov9-c'
|
| 22 |
-
// quantized: false,
|
| 23 |
-
});
|
| 24 |
status.textContent = 'Ready';
|
| 25 |
|
| 26 |
example.addEventListener('click', (e) => {
|
|
@@ -71,10 +71,10 @@ function renderBox([xmin, ymin, xmax, ymax, score, id]) {
|
|
| 71 |
boxElement.className = 'bounding-box';
|
| 72 |
Object.assign(boxElement.style, {
|
| 73 |
borderColor: color,
|
| 74 |
-
left: 100 * xmin /
|
| 75 |
-
top: 100 * ymin /
|
| 76 |
-
width: 100 * (xmax - xmin) /
|
| 77 |
-
height: 100 * (ymax - ymin) /
|
| 78 |
})
|
| 79 |
|
| 80 |
// Draw label
|
|
|
|
| 11 |
|
| 12 |
const EXAMPLE_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/city-streets.jpg';
|
| 13 |
|
| 14 |
+
const IMAGE_SIZE = 128;
|
| 15 |
+
|
| 16 |
// Create a new object detection pipeline
|
| 17 |
status.textContent = 'Loading model...';
|
| 18 |
const processor = await AutoProcessor.from_pretrained('Xenova/yolov9-c');
|
| 19 |
|
| 20 |
+
// For this demo, we resize the image to IMAGE_SIZE x IMAGE_SIZE
|
| 21 |
+
processor.feature_extractor.size = { width: IMAGE_SIZE, height: IMAGE_SIZE }
|
| 22 |
|
| 23 |
+
const model = await AutoModel.from_pretrained('Xenova/yolov9-c');
|
|
|
|
|
|
|
| 24 |
status.textContent = 'Ready';
|
| 25 |
|
| 26 |
example.addEventListener('click', (e) => {
|
|
|
|
| 71 |
boxElement.className = 'bounding-box';
|
| 72 |
Object.assign(boxElement.style, {
|
| 73 |
borderColor: color,
|
| 74 |
+
left: 100 * xmin / IMAGE_SIZE + '%',
|
| 75 |
+
top: 100 * ymin / IMAGE_SIZE + '%',
|
| 76 |
+
width: 100 * (xmax - xmin) / IMAGE_SIZE + '%',
|
| 77 |
+
height: 100 * (ymax - ymin) / IMAGE_SIZE + '%',
|
| 78 |
})
|
| 79 |
|
| 80 |
// Draw label
|