community_icon_html = """""" loading_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 getVideoBlobFile(videoEL){ const res = await fetch(videoEL.src); const blob = await res.blob(); const videoId = Date.now() % 200; const fileName = `propainter-${{videoId}}.mp4`; const videoBlob = new File([blob], fileName, { type: 'video/mp4' }); console.log(videoBlob); return videoBlob; } const gradioEl = document.querySelector("gradio-app").shadowRoot || document.querySelector('body > gradio-app'); const outputVideoMasked = gradioEl.querySelector('#res-masked video'); const outputVideoCleaned = gradioEl.querySelector('#res_cleaned video'); const shareBtnEl = gradioEl.querySelector('#share-btn'); const shareIconEl = gradioEl.querySelector('#share-btn-share-icon'); const loadingIconEl = gradioEl.querySelector('#share-btn-loading-icon'); shareBtnEl.style.pointerEvents = 'none'; shareIconEl.style.display = 'none'; loadingIconEl.style.removeProperty('display'); const videoOutFileMasked = await getVideoBlobFile(outputVideoMasked); const dataOutputVidMasked = await uploadFile(videoOutFileMasked); const videoOutFileCleaned = await getVideoBlobFile(outputVideoCleaned); const dataOutputVidCleaned = await uploadFile(videoOutFileCleaned); const descriptionMd = ` #### Video Masked with SAM: ${dataOutputVidMasked} #### ProPainter result: ${dataOutputVidCleaned} `; const params = new URLSearchParams({ title: "Please provide a title :)", description: descriptionMd, }); const paramsStr = params.toString(); window.open(`https://huggingface.co/spaces/fffiloni/ProPainter/discussions/new?${paramsStr}`, '_blank'); shareBtnEl.style.removeProperty('pointer-events'); shareIconEl.style.removeProperty('display'); loadingIconEl.style.display = 'none'; }"""