Jesse311 commited on
Commit
bf81007
·
verified ·
1 Parent(s): a681987

Update generation.html

Browse files
Files changed (1) hide show
  1. generation.html +19 -11
generation.html CHANGED
@@ -369,6 +369,19 @@
369
  alert("Please generate an image first.");
370
  return;
371
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
372
 
373
  // 1. Convert current image to base64
374
  const imageBlob = await fetch(currentImageUrl).then(r => r.blob());
@@ -402,16 +415,6 @@
402
  if (!searchResp.ok) throw new Error("Search failed");
403
  const result = await searchResp.json();
404
 
405
- // 4. Clear old results
406
- let resultContainer = document.getElementById("lookalike-results");
407
- if (!resultContainer) {
408
- resultContainer = document.createElement("div");
409
- resultContainer.id = "lookalike-results";
410
- resultContainer.className = "flex flex-wrap mt-6";
411
- document.body.appendChild(resultContainer);
412
- }
413
- resultContainer.innerHTML = "";
414
-
415
  // 5. Process results
416
  for (const r of result.results) {
417
  try {
@@ -432,7 +435,12 @@
432
  body: formData
433
  });
434
 
435
- let finalBlob = cleanResp.ok ? await cleanResp.blob() : blob;
 
 
 
 
 
436
  let imgUrl = URL.createObjectURL(finalBlob);
437
 
438
  // Display
 
369
  alert("Please generate an image first.");
370
  return;
371
  }
372
+ // 4. Clear old results
373
+ let resultContainer = document.getElementById("lookalike-results");
374
+ if (!resultContainer) {
375
+ resultContainer = document.createElement("div");
376
+ resultContainer.id = "lookalike-results";
377
+ resultContainer.className = "mt-6 grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4";
378
+ document.body.appendChild(resultContainer);
379
+ }
380
+ resultContainer.innerHTML = `
381
+ <div class="col-span-full flex justify-center items-center">
382
+ <img src="https://i.gifer.com/YCZH.gif" alt="loading" class="w-20 h-20"/>
383
+ </div>
384
+ `;
385
 
386
  // 1. Convert current image to base64
387
  const imageBlob = await fetch(currentImageUrl).then(r => r.blob());
 
415
  if (!searchResp.ok) throw new Error("Search failed");
416
  const result = await searchResp.json();
417
 
 
 
 
 
 
 
 
 
 
 
418
  // 5. Process results
419
  for (const r of result.results) {
420
  try {
 
435
  body: formData
436
  });
437
 
438
+ if (!cleanResp.ok) {
439
+ console.warn("Skipping image, dewatermark failed:", r);
440
+ continue;
441
+ }
442
+
443
+ let finalBlob = await cleanResp.blob();
444
  let imgUrl = URL.createObjectURL(finalBlob);
445
 
446
  // Display