Update index.js
Browse files
index.js
CHANGED
|
@@ -22,6 +22,7 @@ const example = document.getElementById('example');
|
|
| 22 |
|
| 23 |
let ortSessionA, ortSessionB, ortSessionC, ortSessionD, ortSessionE;
|
| 24 |
let config;
|
|
|
|
| 25 |
|
| 26 |
async function initializeSessions() {
|
| 27 |
status.textContent = 'Loading model...';
|
|
@@ -361,22 +362,22 @@ async function updatePreview(url) {
|
|
| 361 |
await initializeSessions();
|
| 362 |
|
| 363 |
// UI Event Handlers
|
| 364 |
-
|
| 365 |
e.preventDefault();
|
| 366 |
-
|
| 367 |
-
|
|
|
|
| 368 |
});
|
| 369 |
|
| 370 |
-
|
| 371 |
const file = e.target.files[0];
|
| 372 |
if (!file) return;
|
| 373 |
|
| 374 |
const reader = new FileReader();
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
}
|
| 380 |
reader.readAsDataURL(file);
|
| 381 |
});
|
| 382 |
|
|
|
|
| 22 |
|
| 23 |
let ortSessionA, ortSessionB, ortSessionC, ortSessionD, ortSessionE;
|
| 24 |
let config;
|
| 25 |
+
let currentImage = '';
|
| 26 |
|
| 27 |
async function initializeSessions() {
|
| 28 |
status.textContent = 'Loading model...';
|
|
|
|
| 362 |
await initializeSessions();
|
| 363 |
|
| 364 |
// UI Event Handlers
|
| 365 |
+
exampleButton.addEventListener('click', (e) => {
|
| 366 |
e.preventDefault();
|
| 367 |
+
e.stopPropagation();
|
| 368 |
+
currentImage = EXAMPLE_URL;
|
| 369 |
+
status.textContent = promptInput.value.trim() ? 'Press Enter to analyze' : 'Add a prompt and press Enter';
|
| 370 |
});
|
| 371 |
|
| 372 |
+
uploadInput.addEventListener('change', (e) => {
|
| 373 |
const file = e.target.files[0];
|
| 374 |
if (!file) return;
|
| 375 |
|
| 376 |
const reader = new FileReader();
|
| 377 |
+
reader.onload = (e) => {
|
| 378 |
+
currentImage = e.target.result;
|
| 379 |
+
status.textContent = promptInput.value.trim() ? 'Press Enter to analyze' : 'Add a prompt and press Enter';
|
| 380 |
+
};
|
|
|
|
| 381 |
reader.readAsDataURL(file);
|
| 382 |
});
|
| 383 |
|