Nekochu commited on
Commit
9fac93f
·
verified ·
1 Parent(s): d0c692f

Moved to WeReCooking: load weights from WeReCooking, keep files already stored in the browser

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app.js +18 -1
README.md CHANGED
@@ -9,7 +9,7 @@ pinned: false
9
  license: other
10
  short_description: dflow_2b 4-step text to image, on your GPU in the browser
11
  models:
12
- - WeReCooking2/DFlow2-4step-ONNX-WebGPU
13
  - data-archetype/dflow_2b
14
  - lvladikov/DFlow2-Distill-4steps-eDMD-LADD-LoRA
15
  - data-archetype/dinac3_96
@@ -25,7 +25,7 @@ in your browser tab on your own GPU through WebGPU and ONNX Runtime Web. Nothing
25
  - Picks the trained size (about 1 MP) when your GPU allows it. 512×512 is a quick preview with far
26
  less detail, since the model was trained at 1 MP and above.
27
 
28
- Weights and conversion details: [WeReCooking2/DFlow2-4step-ONNX-WebGPU](https://huggingface.co/WeReCooking2/DFlow2-4step-ONNX-WebGPU).
29
 
30
  This project uses dflow_2b by Data Archetype. https://huggingface.co/data-archetype/dflow_2b
31
  Non-commercial use only (MG-BY-NC-2.0). Gemma is provided under and subject to the Gemma Terms of Use
 
9
  license: other
10
  short_description: dflow_2b 4-step text to image, on your GPU in the browser
11
  models:
12
+ - WeReCooking/DFlow2-4step-ONNX-WebGPU
13
  - data-archetype/dflow_2b
14
  - lvladikov/DFlow2-Distill-4steps-eDMD-LADD-LoRA
15
  - data-archetype/dinac3_96
 
25
  - Picks the trained size (about 1 MP) when your GPU allows it. 512×512 is a quick preview with far
26
  less detail, since the model was trained at 1 MP and above.
27
 
28
+ Weights and conversion details: [WeReCooking/DFlow2-4step-ONNX-WebGPU](https://huggingface.co/WeReCooking/DFlow2-4step-ONNX-WebGPU).
29
 
30
  This project uses dflow_2b by Data Archetype. https://huggingface.co/data-archetype/dflow_2b
31
  Non-commercial use only (MG-BY-NC-2.0). Gemma is provided under and subject to the Gemma Terms of Use
app.js CHANGED
@@ -412,7 +412,9 @@ class DFlowWeb {
412
 
413
 
414
  const q = new URLSearchParams(location.search);
415
- const REPO = 'WeReCooking2/DFlow2-4step-ONNX-WebGPU';
 
 
416
  // Test hooks: only same-origin paths (or the Hub, for weights) are accepted, so a crafted
417
  // link cannot make this page import someone else's script.
418
  const local = (v) => (v && v.startsWith('/') && !v.startsWith('//') ? v : null);
@@ -480,6 +482,20 @@ function fillSizes() {
480
  ui.size.value = keep && have(keep) ? keep : (DEFAULTS.find(have) || ui.size.options[0]?.value);
481
  }
482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  async function storageLine() {
484
  try {
485
  const est = await navigator.storage?.estimate?.();
@@ -513,6 +529,7 @@ async function init() {
513
  try { // drop files of older page versions
514
  for (const k of await caches.keys()) if (k.startsWith('dflow2-web-') && k !== CACHE) await caches.delete(k);
515
  } catch { /* no Cache API */ }
 
516
  ui.wipe.addEventListener('click', async () => {
517
  if (busy) return;
518
  await caches.delete(CACHE);
 
412
 
413
 
414
  const q = new URLSearchParams(location.search);
415
+ const REPO = 'WeReCooking/DFlow2-4step-ONNX-WebGPU';
416
+ // Earlier homes of the weights: files stored under these URLs are re-filed, not downloaded again.
417
+ const OLD_BASES = ['https://huggingface.co/WeReCooking2/DFlow2-4step-ONNX-WebGPU/resolve/main'];
418
  // Test hooks: only same-origin paths (or the Hub, for weights) are accepted, so a crafted
419
  // link cannot make this page import someone else's script.
420
  const local = (v) => (v && v.startsWith('/') && !v.startsWith('//') ? v : null);
 
482
  ui.size.value = keep && have(keep) ? keep : (DEFAULTS.find(have) || ui.size.options[0]?.value);
483
  }
484
 
485
+ async function migrateCache() {
486
+ try {
487
+ const cache = await caches.open(CACHE);
488
+ const moved = (await cache.keys()).filter((r) => OLD_BASES.some((b) => b !== BASE && r.url.startsWith(b + '/')));
489
+ for (const [i, req] of moved.entries()) {
490
+ status(`Moving the stored model to its new address, one time only (${i + 1} of ${moved.length})…`);
491
+ const old = OLD_BASES.find((b) => req.url.startsWith(b + '/'));
492
+ const res = await cache.match(req);
493
+ if (res) await cache.put(BASE + req.url.slice(old.length), res);
494
+ await cache.delete(req);
495
+ }
496
+ } catch { /* nothing stored, or no Cache API */ }
497
+ }
498
+
499
  async function storageLine() {
500
  try {
501
  const est = await navigator.storage?.estimate?.();
 
529
  try { // drop files of older page versions
530
  for (const k of await caches.keys()) if (k.startsWith('dflow2-web-') && k !== CACHE) await caches.delete(k);
531
  } catch { /* no Cache API */ }
532
+ await migrateCache();
533
  ui.wipe.addEventListener('click', async () => {
534
  if (busy) return;
535
  await caches.delete(CACHE);