fffiloni commited on
Commit
4784d4e
1 Parent(s): e0380f0

Update share_btn.py

Browse files
Files changed (1) hide show
  1. share_btn.py +20 -2
share_btn.py CHANGED
@@ -22,6 +22,20 @@ share_js = """async () => {
22
  const url = await response.text();
23
  return url;
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  async function getVideoBlobFile(videoEL){
27
  const res = await fetch(videoEL.src);
@@ -50,12 +64,16 @@ share_js = """async () => {
50
  shareIconEl.style.display = 'none';
51
  loadingIconEl.style.removeProperty('display');
52
 
53
-
 
54
  const videoOutFile = await getVideoBlobFile(outputVideo);
55
  const dataOutputVid = await uploadFile(videoOutFile);
56
 
57
  const descriptionMd = `
58
- #### Prompt:
 
 
 
59
  ${captionTxt}
60
 
61
  #### Zeroscope video result:
 
22
  const url = await response.text();
23
  return url;
24
  }
25
+
26
+ async function getInputImgFile(imgEl){
27
+ const res = await fetch(imgEl.src);
28
+ const blob = await res.blob();
29
+ const imgId = Date.now() % 200;
30
+ const isPng = imgEl.src.startsWith(`data:image/png`);
31
+ if(isPng){
32
+ const fileName = `sd-perception-${{imgId}}.png`;
33
+ return new File([blob], fileName, { type: 'image/png' });
34
+ }else{
35
+ const fileName = `sd-perception-${{imgId}}.jpg`;
36
+ return new File([blob], fileName, { type: 'image/jpeg' });
37
+ }
38
+ }
39
 
40
  async function getVideoBlobFile(videoEL){
41
  const res = await fetch(videoEL.src);
 
64
  shareIconEl.style.display = 'none';
65
  loadingIconEl.style.removeProperty('display');
66
 
67
+ const inputFile = await getInputImgFile(imageInit);
68
+ const urlInputImg = await uploadFile(inputFile);
69
  const videoOutFile = await getVideoBlobFile(outputVideo);
70
  const dataOutputVid = await uploadFile(videoOutFile);
71
 
72
  const descriptionMd = `
73
+ #### Image Init:
74
+ <img src='${urlInputImg}' style='max-height: 350px;'>
75
+
76
+ #### Caption:
77
  ${captionTxt}
78
 
79
  #### Zeroscope video result: