Spaces:
Paused
Paused
Update share_btn.py
Browse files- share_btn.py +7 -4
share_btn.py
CHANGED
|
@@ -24,15 +24,18 @@ share_js = """async () => {
|
|
| 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 =
|
| 31 |
if(isPng){
|
| 32 |
-
const fileName = `sd-perception-${
|
| 33 |
return new File([blob], fileName, { type: 'image/png' });
|
| 34 |
}else{
|
| 35 |
-
const fileName = `sd-perception-${
|
| 36 |
return new File([blob], fileName, { type: 'image/jpeg' });
|
| 37 |
}
|
| 38 |
}
|
|
@@ -69,7 +72,7 @@ ${inputPrompt}
|
|
| 69 |
preview: true
|
| 70 |
});
|
| 71 |
const paramsStr = params.toString();
|
| 72 |
-
window.open(`https://huggingface.co/spaces/multimodalart/
|
| 73 |
shareBtnEl.style.removeProperty('pointer-events');
|
| 74 |
shareIconEl.style.removeProperty('display');
|
| 75 |
loadingIconEl.style.display = 'none';
|
|
|
|
| 24 |
}
|
| 25 |
|
| 26 |
async function getInputImgFile(imgEl){
|
| 27 |
+
console.log(imgEl)
|
| 28 |
const res = await fetch(imgEl.src);
|
| 29 |
+
console.log(res)
|
| 30 |
const blob = await res.blob();
|
| 31 |
+
console.log(blob.type)
|
| 32 |
const imgId = Date.now() % 200;
|
| 33 |
+
const isPng = blob.type == 'image/png';
|
| 34 |
if(isPng){
|
| 35 |
+
const fileName = `sd-perception-${imgId}.png`;
|
| 36 |
return new File([blob], fileName, { type: 'image/png' });
|
| 37 |
}else{
|
| 38 |
+
const fileName = `sd-perception-${imgId}.jpg`;
|
| 39 |
return new File([blob], fileName, { type: 'image/jpeg' });
|
| 40 |
}
|
| 41 |
}
|
|
|
|
| 72 |
preview: true
|
| 73 |
});
|
| 74 |
const paramsStr = params.toString();
|
| 75 |
+
window.open(`https://huggingface.co/spaces/multimodalart/face-to-all/discussions/new?${paramsStr}`, '_blank');
|
| 76 |
shareBtnEl.style.removeProperty('pointer-events');
|
| 77 |
shareIconEl.style.removeProperty('display');
|
| 78 |
loadingIconEl.style.display = 'none';
|