pdufour commited on
Commit
e6643db
1 Parent(s): 5ef5062

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +10 -9
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
- example.addEventListener('click', (e) => {
365
  e.preventDefault();
366
- updatepreview(EXAMPLE_URL);
367
- parse(EXAMPLE_URL, 'Describe this image.');
 
368
  });
369
 
370
- fileUpload.addEventListener('change', async function(e) {
371
  const file = e.target.files[0];
372
  if (!file) return;
373
 
374
  const reader = new FileReader();
375
-
376
- reader.onload = async (e2) => {
377
- updatePreview(e2.target.result);
378
- handleQuery(e2.target.result);
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