mishig HF staff commited on
Commit
3005416
1 Parent(s): 0734d7c

Add download btn

Browse files
Files changed (1) hide show
  1. src/routes/+page.svelte +27 -0
src/routes/+page.svelte CHANGED
@@ -127,6 +127,7 @@
127
  return imgEl;
128
  })
129
  )) as CanvasImageSource[];
 
130
 
131
  isShowSketch = true;
132
  let i = 0;
@@ -197,6 +198,30 @@
197
  }
198
  }
199
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  function copySketch() {
201
  const context = sketchEl.getContext('2d');
202
 
@@ -309,6 +334,7 @@
309
  return false;
310
  };
311
  addClearCanvasControl();
 
312
  makeLinksTargetBlank();
313
  });
314
  </script>
@@ -387,3 +413,4 @@ The model is licensed with a [CreativeML Open RAIL-M](https://huggingface.co/spa
387
  ### Biases and content acknowledgment
388
  Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the [LAION-5B dataset](https://laion.ai/blog/laion-5b/), which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4)
389
  </article>
 
 
127
  return imgEl;
128
  })
129
  )) as CanvasImageSource[];
130
+ outputImgs.push(initialSketchBitmap);
131
 
132
  isShowSketch = true;
133
  let i = 0;
 
198
  }
199
  }
200
 
201
+ function addDownloadCanvasControl() {
202
+ const div = document.createElement('div');
203
+ div.className = 'drawing-board-control';
204
+
205
+ const btn = document.createElement('button');
206
+ btn.innerHTML = '⬇️';
207
+ btn.onclick = () => {
208
+ if (!canvas) {
209
+ return;
210
+ }
211
+ const link = document.createElement('a');
212
+ const imgId = Date.now() % 200;
213
+ link.download = `diffuse-the-rest-${imgId}.png`;
214
+ link.href = canvas.toDataURL();
215
+ link.click();
216
+ };
217
+ div.append(btn);
218
+
219
+ const controlsEl = document.querySelector('.drawing-board-controls');
220
+ if (controlsEl) {
221
+ controlsEl.appendChild(div);
222
+ }
223
+ }
224
+
225
  function copySketch() {
226
  const context = sketchEl.getContext('2d');
227
 
 
334
  return false;
335
  };
336
  addClearCanvasControl();
337
+ addDownloadCanvasControl();
338
  makeLinksTargetBlank();
339
  });
340
  </script>
 
413
  ### Biases and content acknowledgment
414
  Despite how impressive being able to turn text into image is, beware to the fact that this model may output content that reinforces or exacerbates societal biases, as well as realistic faces, pornography and violence. The model was trained on the [LAION-5B dataset](https://laion.ai/blog/laion-5b/), which scraped non-curated image-text-pairs from the internet (the exception being the removal of illegal content) and is meant for research purposes. You can read more in the [model card](https://huggingface.co/CompVis/stable-diffusion-v1-4)
415
  </article>
416
+