community_icon_html = """""" loading_icon_html = """""" download_icon_html = """ """ share_js = """async () => { async function uploadFile(file){ const UPLOAD_URL = 'https://huggingface.co/uploads'; const response = await fetch(UPLOAD_URL, { method: 'POST', headers: { 'Content-Type': file.type, 'X-Requested-With': 'XMLHttpRequest', }, body: file, /// <- File inherits from Blob }); const url = await response.text(); return url; } async function getInputImgFile(imgCanvas){ const blob = await new Promise(resolve => imgCanvas.toBlob(resolve)); const imgId = Date.now() % 200; const fileName = 'image-cleaner-${{imgId}}.png'; return new File([blob], fileName, { type: 'image/png' }); } async function getOutoutImgFile(imgEl){ const res = await fetch(imgEl.src); const blob = await res.blob(); const imgId = Date.now() % 200; const fileName = 'image-cleaner-${{imgId}}.png'; return new File([blob], fileName, { type: 'image/png' }); } var gradioEl = document.querySelector('body > gradio-app').shadowRoot; if (!gradioEl) { gradioEl = document.querySelector('body > gradio-app'); } const inputImgCanvas = gradioEl.querySelector('canvas[key="drawing"]'); const outputImgEl = gradioEl.querySelector('#image_output img'); const promptTxt = ''; ///gradioEl.querySelector('#input-text textarea').value; let titleTxt = 'my perfect work'; ///promptTxt; if(titleTxt.length > 100){ titleTxt = titleTxt.slice(0, 100) + ' ...'; } const shareBtnEl = gradioEl.querySelector('#share-btn'); const shareIconEl = gradioEl.querySelector('#share-btn-share-icon'); const loadingIconEl = gradioEl.querySelector('#share-btn-loading-icon'); if(!outputImgEl){ return; }; shareBtnEl.style.pointerEvents = 'none'; shareIconEl.style.display = 'none'; loadingIconEl.style.removeProperty('display'); const inputImgFile = await getInputImgFile(inputImgCanvas); const outputImgFile = await getOutoutImgFile(outputImgEl); const files = [inputImgFile, outputImgFile]; const urls = await Promise.all(files.map((f) => uploadFile(f))); const htmlImgs = urls.map(url => ``); const [inputImgUrl, outputImgUrl] = htmlImgs; var descriptionMd = `